Pārlūkot izejas kodu

fixed coordinates mapping

sl@cccfr.de 3 gadi atpakaļ
vecāks
revīzija
72b5fc92bc
7 mainītis faili ar 38 papildinājumiem un 61 dzēšanām
  1. 1 0
      .gitignore
  2. 13 2
      Main.gd
  3. 4 3
      Main.tscn
  4. 6 3
      Player.gd
  5. 9 10
      Tile.gd
  6. 5 0
      project.godot
  7. 0 43
      test.tscn

+ 1 - 0
.gitignore

@@ -1,3 +1,4 @@
 tex/
 *.tar.gz
 .import/
+test.tscn

+ 13 - 2
Main.gd

@@ -8,8 +8,8 @@ var tileGenScene = preload("res://TileGenerator.tscn")
 
 # Called when the node enters the scene tree for the first time.
 func _ready():
-	for y in range(0,15):
-		for x in range(0,4):
+	for y in range(0,10):
+		for x in range(0,5):
 			var moontile = tileGenScene.instance()
 			moontile.init(y,x)
 			#moontile.scale=Vector3(1000,1000,1000)
@@ -19,3 +19,14 @@ func _ready():
 # Called every frame. 'delta' is the elapsed time since the previous frame.
 #func _process(delta):
 #	pass
+func latLonToGlobal(latPos, lonPos, offset=Vector3()):
+	var height = 1737.4 + offset.z
+	var lat = float(latPos+offset.x)*PI/180
+	var w = cos(lat)
+	var y = sin(lat)
+	var u = float(lonPos) / 360
+	var lon = float(lonPos+offset.y)*PI/180
+	var x = sin(lon)
+	var z = cos(lon)
+	return Vector3(x * height * w, y*height, z * height * w)
+			

+ 4 - 3
Main.tscn

@@ -3,12 +3,13 @@
 [ext_resource path="res://Main.gd" type="Script" id=1]
 [ext_resource path="res://Player.gd" type="Script" id=2]
 
-[sub_resource type="ProceduralSky" id=1]
+[sub_resource type="ProceduralSky" id=4]
+sun_latitude = 135.0
+sun_energy = 4.66
 
 [sub_resource type="Environment" id=2]
 background_mode = 2
-background_sky = SubResource( 1 )
-ambient_light_energy = 3.43
+background_sky = SubResource( 4 )
 
 [sub_resource type="SphereShape" id=3]
 

+ 6 - 3
Player.gd

@@ -68,10 +68,13 @@ func _physics_process(delta):
 	
 	var relativeDir = (forward * input.y + right * input.x + up * input.z)
 	
+	var moveSpeed2 = moveSpeed
+	if Input.is_action_pressed("sprint"):
+		moveSpeed2 = moveSpeed * 3
 	# set the velocity
-	vel.x = relativeDir.x * moveSpeed
-	vel.z = relativeDir.z * moveSpeed
-	vel.y = relativeDir.y * moveSpeed
+	vel.x = relativeDir.x * moveSpeed2
+	vel.z = relativeDir.z * moveSpeed2
+	vel.y = relativeDir.y * moveSpeed2
 	
 	# move the player
 	vel = move_and_slide(vel, Vector3.UP)

+ 9 - 10
Tile.gd

@@ -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.

+ 5 - 0
project.godot

@@ -46,6 +46,11 @@ move_down={
 "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777238,"unicode":0,"echo":false,"script":null)
  ]
 }
+sprint={
+"deadzone": 0.5,
+"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777237,"unicode":0,"echo":false,"script":null)
+ ]
+}
 
 [physics]
 

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 0 - 43
test.tscn