Main.gd 849 B

123456789101112131415161718192021222324252627282930313233
  1. extends Spatial
  2. # Declare member variables here. Examples:
  3. # var a = 2
  4. # var b = "text"
  5. var tileGenScene = preload("res://TileGenerator.tscn")
  6. # Called when the node enters the scene tree for the first time.
  7. func _ready():
  8. for y in range(0,10):
  9. for x in range(0,5):
  10. var moontile = tileGenScene.instance()
  11. moontile.init(y,x)
  12. #moontile.scale=Vector3(1000,1000,1000)
  13. $Tiles.add_child(moontile)
  14. # Called every frame. 'delta' is the elapsed time since the previous frame.
  15. #func _process(delta):
  16. # pass
  17. func latLonToGlobal(latPos, lonPos, offset=Vector3()):
  18. var height = 1737.4 + offset.z
  19. var lat = float(latPos+offset.x)*PI/180
  20. var w = cos(lat)
  21. var y = sin(lat)
  22. var u = float(lonPos) / 360
  23. var lon = float(lonPos+offset.y)*PI/180
  24. var x = sin(lon)
  25. var z = cos(lon)
  26. return Vector3(x * height * w, y*height, z * height * w)