Explorar el Código

add chunk space

sl@cccfr.de hace 2 años
padre
commit
80f3cfd3f1
Se han modificado 6 ficheros con 20 adiciones y 7 borrados
  1. 1 0
      Main.tscn
  2. 5 5
      Player.gd
  3. 4 1
      Tile.gd
  4. 5 0
      chunk.gd
  5. 4 0
      chunk.tscn
  6. 1 1
      shader/ground_shader.tres

+ 1 - 0
Main.tscn

@@ -132,5 +132,6 @@ material/0 = null
 
 [node name="plane" type="MeshInstance" parent="."]
 transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 2.98035, 2.37647, 0.319568 )
+visible = false
 mesh = SubResource( 11 )
 material/0 = null

+ 5 - 5
Player.gd

@@ -90,15 +90,15 @@ func _physics_process(delta):
 			dir -= forward
 			
 		# Jump
-		if not is_on_floor():
-			if Input.is_action_pressed("move_up"):
-				dir += up
+		#if is_on_floor():
+		#if Input.is_action_pressed("move_up"):
+		#	dir += up
 		if Input.is_action_pressed("move_down"):
 			dir -= up
 			
 		#Jump
-		#if Input.is_action_pressed("move_jump") and is_on_floor():
-		#	velocity += jump_vector * Jump_speed - (jump_vector * -1).normalized() * velocity.dot(jump_vector * -1)
+		if Input.is_action_pressed("move_up"):# and is_on_floor():
+			velocity += up * Jump_speed - (up * -1).normalized() * velocity.dot(up * -1)
 	
 		#Sprint toggle
 		if can_sprint and Input.is_action_just_pressed("move_sprint"): #and is_on_floor():

+ 4 - 1
Tile.gd

@@ -15,6 +15,7 @@ var radius:float = 10
 var scaleFact:int = 1
 
 var origin:Vector3
+var center:Vector3
 
 func setParams(latMinIN, latMaxIN, lonMinIN, lonMaxIN, resolutionIN, radiusIN:float, scaleIN):	
 	latMin = latMinIN
@@ -153,7 +154,9 @@ func convertToCartesian(verts:PoolVector3Array):
 	var v_idx = 0
 	for vert in verts:
 		if not origin:
-			origin = vert			
+			origin = vert
+		if v_idx == len(verts)/2:
+			center = vert
 		carVerts[v_idx] = Common.latLonToGlobal(vert, Vector3())#, origin)
 		v_idx+=1
 	#print("Cartesian")

+ 5 - 0
chunk.gd

@@ -12,6 +12,9 @@ var resolution:int = 512
 var radius:float = 10
 var scaleFact:int = 1
 
+var origin:Vector3
+var center:Vector3
+
 func setParams(latMinIN, latMaxIN, lonMinIN, lonMaxIN, resolutionIN, radiusIN:float, scaleFactIN):
 	latMin = latMinIN
 	latMax = latMaxIN
@@ -25,6 +28,8 @@ func setParams(latMinIN, latMaxIN, lonMinIN, lonMaxIN, resolutionIN, radiusIN:fl
 func _ready():
 	.get_node("Mesh").setParams(latMin, latMax, lonMin, lonMax, resolution, radius, scaleFact)
 	.get_node("Mesh").genMesh()
+	.get_node("Origin").transform.origin = .get_node("Mesh").origin
+	.get_node("Center").transform.origin = .get_node("Mesh").center
 	#.translate(.get_node("Mesh").origin)
 
 # Called every frame. 'delta' is the elapsed time since the previous frame.

+ 4 - 0
chunk.tscn

@@ -9,3 +9,7 @@ script = ExtResource( 1 )
 [node name="Mesh" type="MeshInstance" parent="."]
 use_in_baked_light = true
 script = ExtResource( 2 )
+
+[node name="Origin" type="Position3D" parent="."]
+
+[node name="Center" type="Position3D" parent="."]

+ 1 - 1
shader/ground_shader.tres

@@ -99,7 +99,7 @@ shader_param/roughness = 1.0
 shader_param/point_size = 1.0
 shader_param/metallic_texture_channel = Plane( 1, 0, 0, 0 )
 shader_param/roughness_texture_channel = Plane( 1, 0, 0, 0 )
-shader_param/normal_scale = 1.0
+shader_param/normal_scale = -1.0
 shader_param/ao_texture_channel = Plane( 1, 0, 0, 0 )
 shader_param/ao_light_affect = 0.0
 shader_param/depth_scale = 0.05