Initial commit with correct working GD script
This commit is contained in:
commit
cd5fe60963
BIN
N51E007.hgt
Normal file
BIN
N51E007.hgt
Normal file
Binary file not shown.
1
icon.svg
Normal file
1
icon.svg
Normal file
@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="128" height="128"><rect width="124" height="124" x="2" y="2" fill="#363d52" stroke="#212532" stroke-width="4" rx="14"/><g fill="#fff" transform="translate(12.322 12.322)scale(.101)"><path d="M105 673v33q407 354 814 0v-33z"/><path fill="#478cbf" d="m105 673 152 14q12 1 15 14l4 67 132 10 8-61q2-11 15-15h162q13 4 15 15l8 61 132-10 4-67q3-13 15-14l152-14V427q30-39 56-81-35-59-83-108-43 20-82 47-40-37-88-64 7-51 8-102-59-28-123-42-26 43-46 89-49-7-98 0-20-46-46-89-64 14-123 42 1 51 8 102-48 27-88 64-39-27-82-47-48 49-83 108 26 42 56 81zm0 33v39c0 276 813 276 814 0v-39l-134 12-5 69q-2 10-14 13l-162 11q-12 0-16-11l-10-65H446l-10 65q-4 11-16 11l-162-11q-12-3-14-13l-5-69z"/><path d="M483 600c0 34 58 34 58 0v-86c0-34-58-34-58 0z"/><circle cx="725" cy="526" r="90"/><circle cx="299" cy="526" r="90"/></g><g fill="#414042" transform="translate(12.322 12.322)scale(.101)"><circle cx="307" cy="532" r="60"/><circle cx="717" cy="532" r="60"/></g></svg>
|
After Width: | Height: | Size: 994 B |
37
icon.svg.import
Normal file
37
icon.svg.import
Normal file
@ -0,0 +1,37 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://516p06wj654n"
|
||||
path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://icon.svg"
|
||||
dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
svg/scale=1.0
|
||||
editor/scale_with_editor_scale=false
|
||||
editor/convert_colors_with_editor_theme=false
|
106
lidar.gd
Normal file
106
lidar.gd
Normal file
@ -0,0 +1,106 @@
|
||||
@tool
|
||||
extends MeshInstance3D
|
||||
@export var update=false
|
||||
|
||||
var height = Array()
|
||||
var grid
|
||||
var lng_w
|
||||
var lat_l = 111.321
|
||||
var v_step
|
||||
var h_step
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
_getHeights()
|
||||
_widthOfLongitude(51)
|
||||
v_step = grid / lat_l
|
||||
h_step = ((lng_w/1000) / lat_l) * v_step
|
||||
_generateTerrain()
|
||||
|
||||
|
||||
func _getHeights():
|
||||
if FileAccess.file_exists("res://N51E007.hgt"):
|
||||
var file = FileAccess.open("res://N51E007.hgt", FileAccess.READ)
|
||||
file.big_endian = true
|
||||
var size = file.get_length()
|
||||
grid = int(sqrt(size/2))
|
||||
#uv_step = 1 / grid
|
||||
for x in range(0, grid):
|
||||
var row = Array()
|
||||
for y in range(0, grid):
|
||||
row.append(file.get_16())
|
||||
height.append(row)
|
||||
height.reverse()
|
||||
|
||||
|
||||
func _widthOfLongitude(lng):
|
||||
var dm = cos(deg_to_rad(lng)) * lat_l
|
||||
lng_w = round(dm * 1000)
|
||||
|
||||
|
||||
func _generateTerrain():
|
||||
var a_mesh = ArrayMesh.new()
|
||||
var verts := PackedVector3Array()
|
||||
var indices := PackedInt32Array()
|
||||
var normals := PackedVector3Array()
|
||||
var curind = 0
|
||||
|
||||
for x in range(0, grid-2):
|
||||
for y in range(0, grid-2):
|
||||
var xp = x*h_step
|
||||
var yp = y*v_step
|
||||
var v1 = Vector3(xp, _getHeight(x, y), -yp)
|
||||
var v2 = Vector3(xp, _getHeight(x, y+1), -yp-v_step)
|
||||
var v3 = Vector3(xp+h_step, _getHeight(x+1, y), -yp)
|
||||
|
||||
var side1 = v2-v1
|
||||
var side2 = v2-v3
|
||||
var normal1 = side1.cross(side2)
|
||||
|
||||
var v4 = Vector3(xp, _getHeight(x, y+1), -yp-v_step)
|
||||
var v5 = Vector3(xp+h_step, _getHeight(x+1, y+1), -yp-v_step)
|
||||
var v6 = Vector3(xp+h_step, _getHeight(x+1, y), -yp)
|
||||
|
||||
var side3 = v5-v4
|
||||
var side4 = v5-v6
|
||||
var normal2 = side3.cross(side4)
|
||||
|
||||
verts.append(v1)
|
||||
verts.append(v2)
|
||||
verts.append(v3)
|
||||
verts.append(v4)
|
||||
verts.append(v5)
|
||||
verts.append(v6)
|
||||
|
||||
normals.append(normal1)
|
||||
normals.append(normal1)
|
||||
normals.append(normal1)
|
||||
normals.append(normal2)
|
||||
normals.append(normal2)
|
||||
normals.append(normal2)
|
||||
|
||||
indices.append(curind+0)
|
||||
indices.append(curind+1)
|
||||
indices.append(curind+2)
|
||||
indices.append(curind+3)
|
||||
indices.append(curind+4)
|
||||
indices.append(curind+5)
|
||||
curind = curind+6
|
||||
|
||||
var array = []
|
||||
array.resize(Mesh.ARRAY_MAX)
|
||||
array[Mesh.ARRAY_VERTEX] = verts
|
||||
array[Mesh.ARRAY_INDEX] = indices
|
||||
array[Mesh.ARRAY_NORMAL] = normals
|
||||
a_mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES, array)
|
||||
mesh = a_mesh
|
||||
|
||||
|
||||
|
||||
func _getHeight(x, y):
|
||||
return height[y][x]
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
4
lidar.tres
Normal file
4
lidar.tres
Normal file
@ -0,0 +1,4 @@
|
||||
[gd_resource type="StandardMaterial3D" format=3 uid="uid://csub3tefbxyos"]
|
||||
|
||||
[resource]
|
||||
emission = Color(1, 1, 1, 1)
|
28
lidar.tscn
Normal file
28
lidar.tscn
Normal file
@ -0,0 +1,28 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://bycv6uqx3ruk8"]
|
||||
|
||||
[ext_resource type="Script" path="res://lidar.gd" id="1_54dbw"]
|
||||
|
||||
[sub_resource type="Environment" id="Environment_ngpq5"]
|
||||
background_mode = 1
|
||||
background_color = Color(0.58581, 0.673741, 0.868176, 1)
|
||||
|
||||
[sub_resource type="CameraAttributesPractical" id="CameraAttributesPractical_c0u6f"]
|
||||
|
||||
[node name="Node3D" type="Node3D"]
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
|
||||
script = ExtResource("1_54dbw")
|
||||
|
||||
[node name="Camera3D" type="Camera3D" parent="."]
|
||||
transform = Transform3D(-1, -8.74228e-08, 2.5411e-21, -3.82137e-15, 4.37114e-08, 1, -8.74228e-08, 1, -4.37114e-08, 0, 99.8156, 0)
|
||||
current = true
|
||||
far = 60000.0
|
||||
|
||||
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
|
||||
environment = SubResource("Environment_ngpq5")
|
||||
camera_attributes = SubResource("CameraAttributesPractical_c0u6f")
|
||||
|
||||
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 0.72118, 0.692748, 0, -0.692748, 0.72118, 16.4428, 103.755, 12.2305)
|
||||
light_energy = 0.405
|
||||
shadow_enabled = true
|
0
lidar.tscn-0igfeB
Normal file
0
lidar.tscn-0igfeB
Normal file
0
lidar.tscn-1SXUtf
Normal file
0
lidar.tscn-1SXUtf
Normal file
0
lidar.tscn-TLMdhn
Normal file
0
lidar.tscn-TLMdhn
Normal file
0
lidar.tscn-ZmJlrG
Normal file
0
lidar.tscn-ZmJlrG
Normal file
0
lidar.tscn-gy9kfh
Normal file
0
lidar.tscn-gy9kfh
Normal file
0
lidar.tscn-hPkEpt
Normal file
0
lidar.tscn-hPkEpt
Normal file
0
lidar.tscn-lW8qDe
Normal file
0
lidar.tscn-lW8qDe
Normal file
0
lidar.tscn-pHKR72
Normal file
0
lidar.tscn-pHKR72
Normal file
16
project.godot
Normal file
16
project.godot
Normal file
@ -0,0 +1,16 @@
|
||||
; Engine configuration file.
|
||||
; It's best edited using the editor UI and not directly,
|
||||
; since the parameters that go here are not all obvious.
|
||||
;
|
||||
; Format:
|
||||
; [section] ; section goes between []
|
||||
; param=value ; assign values to parameters
|
||||
|
||||
config_version=5
|
||||
|
||||
[application]
|
||||
|
||||
config/name="lidar"
|
||||
run/main_scene="res://lidar.tscn"
|
||||
config/features=PackedStringArray("4.3", "Forward Plus")
|
||||
config/icon="res://icon.svg"
|
Loading…
x
Reference in New Issue
Block a user