ソースを参照

fix topoloader

Malf 2 年 前
コミット
199a72fb64
共有6 個のファイルを変更した24 個の追加14 個の削除を含む
  1. 3 3
      Main.gd
  2. 2 1
      Main.tscn
  3. 8 7
      Player.gd
  4. 2 1
      TextureLoader.gd
  5. 8 1
      TopoLoader.gd
  6. 1 1
      flat_tile.gd

+ 3 - 3
Main.gd

@@ -8,14 +8,14 @@ extends Spatial
 var Chunk = preload("res://chunk.tscn")
 
 var minlat = 0
-var maxlat = 1
+var maxlat = 2
 var minlon = 0
-var maxlon = 1
+var maxlon = 2
 var steplat = 1
 var steplon = 1
 
 var resolution = 512
-var radius = 1737.4
+var radius = 1737.4#*1000
 
 var curlat = 0
 var curlon = 0

+ 2 - 1
Main.tscn

@@ -36,7 +36,8 @@ environment = SubResource( 2 )
 script = ExtResource( 2 )
 
 [node name="Camera" type="Camera" parent="Player"]
-transform = Transform( 1, 0, 0, 0, 0.905309, 0.424753, 0, -0.424753, 0.905309, 0, 2.72781, 4.43474 )
+transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.978945, -0.910777 )
+far = 500.0
 
 [node name="CollisionShape" type="CollisionShape" parent="Player"]
 transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, 0 )

+ 8 - 7
Player.gd

@@ -13,13 +13,13 @@ export (bool) var can_sprint = true #Alow player to toggle sprint movment.
 export (float) var move_speed = 8 #Players movement speed
 export (float) var move_speed_sprint = 16 #Players sprint movement speed
 export (bool) var move_sprint = false #Player sprinting toggle
-export (float) var move_acceleration = 7 #Players acceleration to movment speed 
+export (float) var move_acceleration = 7 #Players acceleration to movment speed
 export (float) var move_deacceleration = 10 #Players deacceleration from movment speed
 export (bool) var mouse_captured = true #Toggles mouse captured mode
 export (float) var mouse_sensitivity_x = 0.3 #Mouse sensitivity X axis
 export (float) var mouse_sensitivity_y = 0.3 #Mouse sensitivity Y axis
-export (float) var mouse_max_up = 90 #Mouse max look angle up
-export (float) var mouse_max_down = -80 #Mouse max look angle down
+export (float) var mouse_max_up = 45 #Mouse max look angle up
+export (float) var mouse_max_down = -50 #Mouse max look angle down
 export (float) var Jump_speed = 6 #Players jumps speed
 export (bool) var allow_fall_input = true #Alow player to input movment when falling
 export (bool) var stop_on_slope = false #Toggle sliding on slopes
@@ -37,7 +37,7 @@ onready var forward = global_transform.basis.y
 onready var right = forward.cross(up).normalized()
 
 func _ready():
-	move_and_slide(Common.latLonToGlobal(Vector3(0,0,1750)), Vector3.UP)
+	move_and_slide(Common.latLonToGlobal(Vector3(0,0,1737.4)), Vector3.UP)
 	if mouse_captured:
 		Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
 	pass
@@ -46,6 +46,7 @@ func _process(delta):
 	var pos = self.global_transform.origin
 	.get_parent().get_node("UI/1").text="x:%s y:%s z:%s" %[pos.x, pos.y, pos.z]
 	.get_parent().get_node("UI/2").text="latlonhight: "+str(Common.globalToLatLon(pos))+","+str(pos.length())
+	#.get_parent().get_node("UI/4").text="chunkDist: %s" % get_node("/Tiles").get_child(0).get_global_transform().origin
 
 	floor_normal = pos.normalized()
 	gravaty_vector = floor_normal * -1
@@ -90,13 +91,13 @@ func _physics_process(delta):
 		#	velocity += jump_vector * Jump_speed - (jump_vector * -1).normalized() * velocity.dot(jump_vector * -1)
 	
 		#Sprint toggle
-		if can_sprint and Input.is_action_just_pressed("move_sprint") and is_on_floor():
+		if can_sprint and Input.is_action_just_pressed("move_sprint"): #and is_on_floor():
 			move_sprint = true
 			
-		if can_sprint and not Input.is_action_pressed("move_sprint") and is_on_floor():
+		if can_sprint and not Input.is_action_pressed("move_sprint"): #and is_on_floor():
 			move_sprint = false
 
-	velocity = velocity.linear_interpolate(dir * move_speed, move_acceleration * delta)
+	velocity = velocity.linear_interpolate(dir * (move_speed_sprint if move_sprint else move_speed), move_acceleration * delta)
 	if !is_on_floor():
 		velocity += gravaty_vector * gravaty * delta
 	velocity = move_and_slide(velocity, up)

+ 2 - 1
TextureLoader.gd

@@ -22,7 +22,8 @@ func loadTexture(lat, lon):
 	return tex
 	
 func getTexName(lat, lon):
-	return "%s/m-%s-%s.png" % [filePrexif, lat, lon]
+	return "%s/m-%s-%s.png" % [filePrexif, (lat+90)%180, (lon+180)%360]
+	#return "user://grid.png"
 
 # Called every frame. 'delta' is the elapsed time since the previous frame.
 #func _process(delta):

+ 8 - 1
TopoLoader.gd

@@ -39,7 +39,14 @@ func cacheArea(latMinIN, latMaxIN, lonMinIN, lonMaxIN):
 	var lat = latMinIN
 	while lat <= latMaxIN:
 		cache[lat]={}
-		file.seek((latMax*resolution*samplesPerLine*4 - lat*resolution*samplesPerLine*4) + lonMinIN*resolution*4)
+		var line = lat*resolution*samplesPerLine*4
+		# the origin of each .img file lies in it's upper left corner
+		# so we need to read the files from the end on the northern hemisphere
+		if lat >= 0:
+			var origin = latMax*resolution*samplesPerLine*4
+			file.seek((origin - line) + lonMinIN*resolution*4)
+		else:
+			file.seek(line + lonMinIN*resolution*4)
 		var lon = lonMinIN
 		while lon <= lonMaxIN:
 			cache[lat][lon] = file.get_float()

+ 1 - 1
flat_tile.gd

@@ -3,7 +3,7 @@ extends MeshInstance
 var Point = preload("res://point.tscn")
 var TopoLoader = preload("res://TopoLoader.gd")
 var TextureLoader = preload("res://TextureLoader.gd")
-var grid = load("res://tex/grid.png")
+#var grid = load("res://tex/grid.png")
 
 var latMin:float = 0
 var latMax:float = 1