I am creating a 3D sphere of the Earth for Unity and I need to have one polygon for each country. Each country has a set of 2D points which are proyected into 3D points based on proyection. But when I create the polygon some vertices are joining incorrectly. I used Maya to create the polygons with this code
with open("C:\\Users\\patilanz\\Downloads\\geo_countries_medium.json") as f:
d = json.load(f)
def to_3d(x,y):
#convert from degrees to radians
longitude = math.radians(x)
latitude = math.radians(y)
# select a radius:
radius = 10
# project to 3d
return (
radius * math.cos(latitude) * math.cos(longitude),
radius * math.cos(latitude) * math.sin(longitude),
radius * math.sin(latitude)
)
for feat in d.get("features"):
r = []
coords = feat.get("geometry").get("coordinates")
type = feat.get("geometry").get("type")
for coord in coords:
for c in coord:
if type == "MultiPolygon":
r = []
for a in c:
r.append(to_3d(a[0],a[1]))
poly = cmds.polyCreateFacet(p=r)
poly = cmds.rename(feat.get("properties").get("name"))
else:
r.append(to_3d(c[0],c[1]))
if not type == "MultiPoligon":
poly = cmds.polyCreateFacet(p=r)
poly = cmds.rename(feat.get("properties").get("name"))
cmds.polySphere(r = 10 * 0.98)
The problem of incorrect joining vertices
I found that this guy was trying to do the same think https://forum.processing.org/one/topic/drawing-countries-on-top-of-a-3d-sphere-from-set-of-boundaries.html
But I don't know how to implement that in Maya or in Unity.