sl@cccfr.de 2 jaren geleden
bovenliggende
commit
85241333a5
2 gewijzigde bestanden met toevoegingen van 26 en 25 verwijderingen
  1. 10 10
      Main.gd
  2. 16 15
      flat_tile.gd

+ 10 - 10
Main.gd

@@ -7,18 +7,18 @@ extends Spatial
 #var tileGenScene = preload("res://TileGenerator.tscn")
 var Chunk = preload("res://chunk.tscn")
 
-var minlat = -3
-var maxlat = 3
+var minlat = 0
+var maxlat = 8
 var minlon = 0
-var maxlon = 6
+var maxlon = 36
 
 var curlat = 0
 var curlon = 0
 
 func _ready():
 	Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
-	curlat = minlat*30
-	curlon = minlon*60
+	curlat = minlat*10
+	curlon = minlon*10
 	
 func _input(event):
 	if event.is_action_pressed("ui_cancel"):
@@ -29,16 +29,16 @@ func _input(event):
 			get_tree().set_input_as_handled()
 
 func _process(delta):
-	if curlat < maxlat*30:
-		if curlon < maxlon*60:
+	if curlat < maxlat*10:
+		if curlon < maxlon*10:
 			var chunk = Chunk.instance()
-			chunk.setParams(curlat,curlat+30,curlon,curlon+60,2)
+			chunk.setParams(curlat,curlat+10,curlon,curlon+10,2)
 			#moontile.scale=Vector3(1000,1000,1000)
 			$Tiles.add_child(chunk)
 			.get_node("UI/3").text="lastLatLon="+str(curlat)+":"+str(curlon)
-			curlon += 60
+			curlon += 10
 		else:
-			curlat +=30
+			curlat +=10
 			curlon = 0
 			if curlat >= maxlat:
 				print("loading complete")

+ 16 - 15
flat_tile.gd

@@ -33,26 +33,27 @@ func genMesh():
 	var arr = []
 	arr.resize(Mesh.ARRAY_MAX)
 	arr[Mesh.ARRAY_VERTEX] = verts
-	arr[Mesh.ARRAY_TEX_UV] = genUV()
+	#arr[Mesh.ARRAY_TEX_UV] = genUV()
 	arr[Mesh.ARRAY_NORMAL] = genNormals(verts)
 	arr[Mesh.ARRAY_INDEX] = genIndex()
 	mesh = Mesh.new()
 	mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES, arr)
 	
-	
-	var i = 0.0
-	for vert in verts:
-		var point = Point.instance()
-		point.translate(vert)
-		var mat = SpatialMaterial.new()#point.mesh.surface_get_material(0)
-		mat.albedo_color = Color(i,0,0,1)
-		i+=0.1
-		point.mesh.surface_set_material(0,mat)
-		.get_parent().add_child(point)
+	var drawBubbles = true
+	if drawBubbles:
+		var i = 0.0
+		for vert in verts:
+			var point = Point.instance()
+			point.translate(vert)
+			var mat = SpatialMaterial.new()#point.mesh.surface_get_material(0)
+			mat.albedo_color = Color(i,0,0,1)
+			i+=0.1
+			point.mesh.surface_set_material(0,mat)
+			.get_parent().add_child(point)
 
 func genNormals(verts:PoolVector3Array):
 	var normals = PoolVector3Array()
-	normals.resize((resolution+1) * (resolution+1))
+	normals.resize(len(verts))
 	var v_idx = 0
 	for vert in verts:
 		normals[v_idx] = vert.normalized()
@@ -76,11 +77,11 @@ func genUV():
 
 func genIndex():
 	var indices = PoolIntArray()
-	indices.resize(6* ((resolution+1) * (resolution+1)))
+	indices.resize(6* ((resolution) * (resolution)))
 	
 	var i_idx = 0
-	for row in range(0, resolution+1):
-		for col in range(0,resolution+1):
+	for row in range(0, resolution):
+		for col in range(0,resolution):
 			var v_idx = row*(resolution+1)+col
 			
 			indices[i_idx] = v_idx