|
@@ -19,6 +19,10 @@ var scaleFact:int = 1
|
|
|
var origin:Vector3
|
|
|
var center:Vector3
|
|
|
|
|
|
+var heightmap:Image
|
|
|
+var overlay_heightmap = false
|
|
|
+var mat:ShaderMaterial
|
|
|
+
|
|
|
var initialized = false
|
|
|
|
|
|
func initialize(latMinIN, latMaxIN, lonMinIN, lonMaxIN, resolutionIN, radiusIN:float, scaleIN):
|
|
@@ -48,6 +52,11 @@ func initTexture():
|
|
|
var exists = texl.open(latMin, lonMin)
|
|
|
return exists
|
|
|
|
|
|
+func _process(delta):
|
|
|
+ if Input.is_action_just_pressed("overlay"):
|
|
|
+ overlay_heightmap = not overlay_heightmap
|
|
|
+ mat.set_shader_param("overlay_heightmap", overlay_heightmap)
|
|
|
+
|
|
|
func genMesh():
|
|
|
#print("generating Mesh:")
|
|
|
#print("latMin: " + str(latMin))
|
|
@@ -65,9 +74,13 @@ func genMesh():
|
|
|
arr[Mesh.ARRAY_INDEX] = genIndex()
|
|
|
mesh = Mesh.new()
|
|
|
mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES, arr)
|
|
|
- var mat = groundShader.duplicate()
|
|
|
+ mat = groundShader.duplicate()
|
|
|
#mat.albedo_color = Color(0.7,0.7,0.7,1)
|
|
|
mat.set_shader_param("texture_albedo_big", texl.loadTexture())
|
|
|
+ heightmap = tl.createHeightmap()
|
|
|
+ var heighttex = ImageTexture.new()
|
|
|
+ heighttex.create_from_image(heightmap, 0)
|
|
|
+ mat.set_shader_param("texture_heightmap", heighttex)
|
|
|
mesh.surface_set_material(0,mat)
|
|
|
.create_trimesh_collision()
|
|
|
|
|
@@ -155,7 +168,11 @@ func genSphereCoords():
|
|
|
for x in range(0,resolution+1):
|
|
|
var lat = latMin+latStep*y
|
|
|
var lon = lonMin+lonStep*x
|
|
|
- verts[v_idx] = Vector3(lat, lon, radius+tl.read(lat,lon)*scaleFact)
|
|
|
+ var height = tl.read(lat,lon)
|
|
|
+ if not height and height != 0:
|
|
|
+ push_error("could not get height")
|
|
|
+ return
|
|
|
+ verts[v_idx] = Vector3(lat, lon, radius+height*scaleFact)
|
|
|
v_idx+=1
|
|
|
tl.close()
|
|
|
return verts
|