|
@@ -1,6 +1,7 @@
|
|
extends MeshInstance
|
|
extends MeshInstance
|
|
|
|
|
|
var Point = preload("res://point.tscn")
|
|
var Point = preload("res://point.tscn")
|
|
|
|
+var TopoLoader = preload("res://TopoLoader.gd")
|
|
|
|
|
|
var latMin:float = 0
|
|
var latMin:float = 0
|
|
var latMax:float = 1
|
|
var latMax:float = 1
|
|
@@ -109,6 +110,9 @@ func genIndex():
|
|
return indices
|
|
return indices
|
|
|
|
|
|
func genSphereCoords():
|
|
func genSphereCoords():
|
|
|
|
+ var tl = TopoLoader.new()
|
|
|
|
+ tl.open()
|
|
|
|
+ tl.cacheArea(latMin, latMax, lonMin, lonMax)
|
|
var verts = PoolVector3Array()
|
|
var verts = PoolVector3Array()
|
|
var size = (resolution+1) * (resolution+1)#(lonMax-lonMin)*resolution * (latMax-latMin)*resolution
|
|
var size = (resolution+1) * (resolution+1)#(lonMax-lonMin)*resolution * (latMax-latMin)*resolution
|
|
verts.resize(size)
|
|
verts.resize(size)
|
|
@@ -118,19 +122,11 @@ func genSphereCoords():
|
|
var v_idx = 0
|
|
var v_idx = 0
|
|
for y in range(0,resolution+1):
|
|
for y in range(0,resolution+1):
|
|
for x in range(0,resolution+1):
|
|
for x in range(0,resolution+1):
|
|
- verts[v_idx] = Vector3(latMin+latStep*y, lonMin+lonStep*x, radius)
|
|
|
|
|
|
+ var lat = latMin+latStep*y
|
|
|
|
+ var lon = lonMin+lonStep*x
|
|
|
|
+ verts[v_idx] = Vector3(lat, lon, radius+tl.read(lat,lon))
|
|
v_idx+=1
|
|
v_idx+=1
|
|
- #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))
|
|
|
|
|
|
+ tl.close()
|
|
return verts
|
|
return verts
|
|
|
|
|
|
|
|
|
|
@@ -141,7 +137,7 @@ func convertToCartesian(verts:PoolVector3Array):
|
|
for vert in verts:
|
|
for vert in verts:
|
|
if not origin:
|
|
if not origin:
|
|
origin = vert
|
|
origin = vert
|
|
- carVerts[v_idx] = Common.latLonToGlobal(vert.x, vert.y, vert.z, Vector3(), origin)
|
|
|
|
|
|
+ carVerts[v_idx] = Common.latLonToGlobal(vert.x, vert.y, vert.z, Vector3())#, origin)
|
|
v_idx+=1
|
|
v_idx+=1
|
|
#print("Cartesian")
|
|
#print("Cartesian")
|
|
#print(len(carVerts))
|
|
#print(len(carVerts))
|