|
@@ -8,22 +8,19 @@ var resolution = 512
|
|
|
var radius = 1737.4
|
|
|
var rng = RandomNumberGenerator.new()
|
|
|
|
|
|
+var datafile = "user://sldem2015_512_00n_30n_000_045_float.img"
|
|
|
var samplesPerLine = 23040
|
|
|
var lines = 15360
|
|
|
var offset = 1737.4
|
|
|
var scaleFact = 1
|
|
|
|
|
|
func init(startLat, startLon):
|
|
|
+
|
|
|
self.latMin = startLat
|
|
|
self.latMax = startLat + 1
|
|
|
self.lonMin = startLon
|
|
|
self.lonMax = startLon + 1
|
|
|
-
|
|
|
-class DataFile:
|
|
|
- var filename: String
|
|
|
- var file: File
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
|
func _ready():
|
|
|
|
|
@@ -36,7 +33,7 @@ func _ready():
|
|
|
var texture = ImageTexture.new()
|
|
|
var image = Image.new()
|
|
|
#image.load("res://m-"+str(latMin+90)+"-"+str(lonMin+180)+".png")
|
|
|
- image.load("res://tex/grid.png")
|
|
|
+ image.load("user://colorTiles/m-" + str(latMin+90)+"-"+str(lonMin+180)+".png")
|
|
|
texture.create_from_image(image)
|
|
|
var material=SpatialMaterial.new()
|
|
|
material.albedo_texture = texture
|
|
@@ -44,7 +41,7 @@ func _ready():
|
|
|
|
|
|
func genMesh():
|
|
|
var file = File.new()
|
|
|
- file.open("user://sldem2015_512_00n_30n_000_045_float.img", File.READ)
|
|
|
+ file.open(datafile, File.READ)
|
|
|
#for lala in range(10):
|
|
|
# file.seek(lala*samplesPerLine*4)
|
|
|
# var blubb = ""
|
|
@@ -89,7 +86,9 @@ func genMesh():
|
|
|
var vert = Vector3()
|
|
|
# Loop over rings.
|
|
|
for latPos in range(latMin*resolution, latMax*resolution):
|
|
|
- file.seek(latPos*samplesPerLine*4 + latMin*samplesPerLine*4 + lonMin*resolution*4)
|
|
|
+ #jump to last line in file - current local lat - local startLat + local startLon
|
|
|
+ file.seek(lines*samplesPerLine*4-latPos*samplesPerLine*4 - latMin*samplesPerLine*4 + lonMin*resolution*4)
|
|
|
+ #file.seek(latPos*samplesPerLine*4 + latMin*samplesPerLine*4 + lonMin*resolution*4)
|
|
|
#file.seek(latPos*samplesPerLine*4 + lonMin*resolution*4)
|
|
|
#file.seek(((latMax*resolution-1-latPos)*samplesPerLine + lonMin*resolution)*4)
|
|
|
#var v = float(latPos-latMin*resolution) / ((latMax-latMin) * resolution)
|
|
@@ -110,7 +109,7 @@ func genMesh():
|
|
|
vert = Vector3(scaleFact * x * height * w, scaleFact * y*height, scaleFact * z * height * w)
|
|
|
verts[point] = vert
|
|
|
normals[point] = vert.normalized()
|
|
|
- uvs[point] = Vector2(u, v)
|
|
|
+ uvs[point] = Vector2(u, 1-v)
|
|
|
point += 1
|
|
|
|
|
|
# Create triangles in ring using indices.
|