|
@@ -39,6 +39,7 @@ func genMesh():
|
|
|
mesh = Mesh.new()
|
|
|
mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES, arr)
|
|
|
|
|
|
+
|
|
|
var i = 0.0
|
|
|
for vert in verts:
|
|
|
var point = Point.instance()
|
|
@@ -75,13 +76,11 @@ func genUV():
|
|
|
|
|
|
func genIndex():
|
|
|
var indices = PoolIntArray()
|
|
|
- indices.resize(6* (resolution+1) * (resolution+1)*6)
|
|
|
+ indices.resize(6* ((resolution+1) * (resolution+1)))
|
|
|
|
|
|
var i_idx = 0
|
|
|
- var row = 0
|
|
|
- while row < resolution:
|
|
|
- var col = 0
|
|
|
- while col < resolution:
|
|
|
+ for row in range(0, resolution+1):
|
|
|
+ for col in range(0,resolution+1):
|
|
|
var v_idx = row*(resolution+1)+col
|
|
|
|
|
|
indices[i_idx] = v_idx
|
|
@@ -97,9 +96,6 @@ func genIndex():
|
|
|
i_idx+=1
|
|
|
indices[i_idx] = v_idx + 1
|
|
|
i_idx+=1
|
|
|
-
|
|
|
- col += 1
|
|
|
- row += 1
|
|
|
|
|
|
print("indices")
|
|
|
print(len(indices))
|
|
@@ -110,15 +106,22 @@ func genSphereCoords():
|
|
|
var size = (resolution+1) * (resolution+1)#(lonMax-lonMin)*resolution * (latMax-latMin)*resolution
|
|
|
verts.resize(size)
|
|
|
|
|
|
+ var lonStep = (lonMax - lonMin)/resolution
|
|
|
+ var latStep = (latMax - latMin)/resolution
|
|
|
var v_idx = 0
|
|
|
- var lat := float(latMin)
|
|
|
- while lat <= float(latMax):
|
|
|
- var lon := float(lonMin)
|
|
|
- while lon <= float(lonMax):
|
|
|
- verts[v_idx] = Vector3(lat, lon, radius)
|
|
|
+ for y in range(0,resolution+1):
|
|
|
+ for x in range(0,resolution+1):
|
|
|
+ verts[v_idx] = Vector3(latMin+latStep*y, lonMin+lonStep*x, radius)
|
|
|
v_idx+=1
|
|
|
- lon += (lonMax-lonMin)/resolution
|
|
|
- lat += (latMax-latMin)/resolution
|
|
|
+ #var v_idx = 0
|
|
|
+ #var lat := float(latMin)
|
|
|
+ #while lat <= float(latMax):
|
|
|
+ # var lon := float(lonMin)
|
|
|
+ # while lon <= float(lonMax):
|
|
|
+ # verts[v_idx] = Vector3(lat, lon, radius)
|
|
|
+ # v_idx+=1
|
|
|
+ # lon += (lonMax-lonMin)/resolution
|
|
|
+ # lat += (latMax-latMin)/resolution
|
|
|
print("verts")
|
|
|
print(len(verts))
|
|
|
return verts
|