Camera mouse look and trees

This commit is contained in:
Adog64 2024-03-06 20:59:34 -05:00
parent ec869732ba
commit 2037197774
31 changed files with 450768 additions and 27 deletions

200019
godot/Astronaut.obj Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,22 @@
[remap]
importer="wavefront_obj"
importer_version=1
type="Mesh"
uid="uid://08c26tip7nme"
path="res://.godot/imported/Astronaut.obj-92115e44a180c145ee00d7f0745dfbae.mesh"
[deps]
files=["res://.godot/imported/Astronaut.obj-92115e44a180c145ee00d7f0745dfbae.mesh"]
source_file="res://Astronaut.obj"
dest_files=["res://.godot/imported/Astronaut.obj-92115e44a180c145ee00d7f0745dfbae.mesh", "res://.godot/imported/Astronaut.obj-92115e44a180c145ee00d7f0745dfbae.mesh"]
[params]
generate_tangents=true
scale_mesh=Vector3(1, 1, 1)
offset_mesh=Vector3(0, 0, 0)
optimize_mesh=true
force_disable_mesh_compression=false

7
godot/EvergreenTree.tscn Normal file
View File

@ -0,0 +1,7 @@
[gd_scene load_steps=2 format=3 uid="uid://bckgedkkuiuwa"]
[ext_resource type="ArrayMesh" uid="uid://wqu5ixp1cj0x" path="res://tree.obj" id="1_1we85"]
[node name="EvergreenTree" type="MeshInstance3D"]
lod_bias = 0.001
mesh = ExtResource("1_1we85")

View File

@ -5,15 +5,15 @@
[ext_resource type="Texture2D" uid="uid://0evqagsrs13i" path="res://Earth-LikeGradient.tres" id="2_7sfjj"]
[ext_resource type="Script" path="res://Scripts/PlanetGeneration/PlanetMeshFace.gd" id="2_gjljs"]
[sub_resource type="FastNoiseLite" id="FastNoiseLite_jxd44"]
[sub_resource type="FastNoiseLite" id="FastNoiseLite_jb0os"]
noise_type = 0
frequency = 1.0
fractal_octaves = 10
[sub_resource type="Resource" id="Resource_fsixp"]
[sub_resource type="Resource" id="Resource_im6ku"]
script = ExtResource("2_5f7j5")
radius = 50.0
noise_map = SubResource("FastNoiseLite_jxd44")
radius = 2000.0
noise_map = SubResource("FastNoiseLite_jb0os")
amplitude = 0.1
planet_color = ExtResource("2_7sfjj")
flatness = 6.0
@ -27,7 +27,7 @@ refraction_texture_channel = 2
[node name="Planet" type="Node3D"]
script = ExtResource("1_0ns5c")
planet_data = SubResource("Resource_fsixp")
planet_data = SubResource("Resource_im6ku")
[node name="Up" type="Node3D" parent="."]
script = ExtResource("2_gjljs")
@ -55,6 +55,6 @@ normal = Vector3(0, 0, -1)
[node name="CSGSphere3D" type="CSGSphere3D" parent="."]
material_override = SubResource("StandardMaterial3D_bs67n")
radius = 50.0
radius = 2000.0
radial_segments = 100
rings = 100

17
godot/Player.tscn Normal file
View File

@ -0,0 +1,17 @@
[gd_scene load_steps=3 format=3 uid="uid://dmyni0e38gals"]
[ext_resource type="Script" path="res://Scripts/Player/Camera3D.gd" id="2_yhea5"]
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_o57nv"]
[node name="Player" type="CharacterBody3D"]
script = ExtResource("2_yhea5")
[node name="Pivot" type="Node3D" parent="."]
[node name="Camera3D" type="Camera3D" parent="Pivot"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.4989, 0)
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
shape = SubResource("CapsuleShape3D_o57nv")

View File

@ -4,7 +4,7 @@ extends Resource
class_name PlanetData
@export var radius : float = 50:
@export var radius : float = 2000:
get:
return radius
set(value):

View File

@ -27,7 +27,7 @@ var material = load("res://PlanetColoring.tres")
var center_of_mass : Vector3
const THRESHOLDS = [512*512, 128*128, 64*64, 32*32]
const THRESHOLDS = [INF, 4096*4096, 2048*2048, 1024*1024, 512*512, 256*256, 128*128]
const RESOLUTION = 17
func split(planet_data : PlanetData):
@ -80,7 +80,7 @@ func update_from_camera_pos(planet_data : PlanetData, camera : Camera3D = null):
if (self.level < (THRESHOLDS.size() - 1) and dist < THRESHOLDS[self.level] and self.is_leaf):
split(planet_data)
elif (dist > THRESHOLDS[self.level] + 4 and not self.is_leaf):
elif (dist > THRESHOLDS[self.level] + THRESHOLDS[self.level]/2 and not self.is_leaf):
join()
regenerate_mesh(planet_data)
@ -110,6 +110,7 @@ func regenerate_mesh(planet_data):
var b_axis : Vector3 = normal.cross(a_axis)
for y in range(RESOLUTION):
for x in range(RESOLUTION):
var i : int = x + y*RESOLUTION
# Relative position of the current point inside the tile
@ -130,7 +131,16 @@ func regenerate_mesh(planet_data):
# Calculate center of mass of current tile.
if (percent.x == 0.5 and percent.y == 0.5):
center_of_mass = point_on_planet
# Generate surface objects
if (level == THRESHOLDS.size()-1 and elevation > planet_data.radius and randf() > 0.98 and elevation < planet_data.radius*1.02):
# Create a new instance of a tree
var test_tree = load("res://EvergreenTree.tscn").instantiate()
var tree_axis_a = Vector3(point_on_sphere.y, point_on_sphere.z, point_on_sphere.x).normalized()
var tree_axis_b = point_on_sphere.cross(tree_axis_a).normalized()
test_tree.transform = Transform3D(tree_axis_b/2, point_on_sphere/2, tree_axis_a/2, point_on_planet)
call_deferred("add_child", test_tree)
vertex_array[i] = point_on_planet
if x != RESOLUTION-1 and y != RESOLUTION-1:
index_array[tri_index + 2] = i
@ -175,6 +185,14 @@ func _update_mesh(arrays : Array, planet_data):
return
mesh_instance.mesh = _mesh
if (level == THRESHOLDS.size()-1):
mesh_instance.create_trimesh_collision()
# DEBUG SHADING
#mesh_instance.material_override = StandardMaterial3D.new()
#mesh_instance.material_override.albedo_color = Color.from_hsv(float(level)/(THRESHOLDS.size()-1), 1, 1)
mesh_instance.material_override = material
mesh_instance.material_override.set_shader_parameter("min_elevation", planet_data.min_elevation - 0.2)
mesh_instance.material_override.set_shader_parameter("max_elevation", planet_data.max_elevation)

View File

@ -1,14 +1,14 @@
extends Camera3D
extends CharacterBody3D
@export var velocity: Vector3
@export var acceleration: Vector3
var g : float = 0.01
@export var mouse_sensitivity : float = 0.01
var g : float = 0.006
# Called when the node enters the scene tree for the first time.
func _ready():
global_position = Vector3(0,0,-150)
global_position = Vector3(0,0,-4000)
acceleration = -global_position.normalized()
velocity = Vector3(0.5, 0.5, 0)
velocity = Vector3(1.3, 1.8, 0)
# Called every frame. 'delta' is the elapsed time since the previous frame.
@ -17,4 +17,11 @@ func _process(delta):
velocity += acceleration
global_translate(velocity)
Global.camera_position = global_position
look_at(Vector3(0,0,0))
print(get_slide_collision_count())
func _unhandled_input(event):
if event is InputEventMouseMotion:
rotate_y(-event.relative.x * mouse_sensitivity)
$Pivot.rotate_x(-event.relative.y * mouse_sensitivity)
$Pivot.rotation.x = clamp($Pivot.rotation.x, -1.2, 1.2)

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
godot/Tree 02/DB2X2_L01.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 845 KiB

View File

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://misxmfcnbplt"
path.s3tc="res://.godot/imported/DB2X2_L01.png-5f3496ae39cb32e006cb097824d31e39.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
[deps]
source_file="res://Tree 02/DB2X2_L01.png"
dest_files=["res://.godot/imported/DB2X2_L01.png-5f3496ae39cb32e006cb097824d31e39.s3tc.ctex"]
[params]
compress/mode=2
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
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=0

BIN
godot/Tree 02/DB2X2_L02.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 378 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://06uxbcbfvt1c"
path="res://.godot/imported/DB2X2_L02.png-51d86149f5c0c0df21043a19bec8e524.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Tree 02/DB2X2_L02.png"
dest_files=["res://.godot/imported/DB2X2_L02.png-51d86149f5c0c0df21043a19bec8e524.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

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://ba0psdcdui0pt"
path="res://.godot/imported/DB2X2_L02_NRM.png-9e8c5688f3da242ffeb0f37adfb9c420.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Tree 02/DB2X2_L02_NRM.png"
dest_files=["res://.godot/imported/DB2X2_L02_NRM.png-9e8c5688f3da242ffeb0f37adfb9c420.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

BIN
godot/Tree 02/Render.jpeg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 479 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://byln1a5vrcf7p"
path="res://.godot/imported/Render.jpeg-da5825a190dd636adf2f3cc37eaed2ac.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Tree 02/Render.jpeg"
dest_files=["res://.godot/imported/Render.jpeg-da5825a190dd636adf2f3cc37eaed2ac.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

14
godot/Tree 02/Tree.mtl Normal file
View File

@ -0,0 +1,14 @@
newmtl Trank_bark
Ka 1.000000 1.000000 1.000000
Kd 1.000000 1.000000 1.000000
Ks 0.000000 0.000000 0.000000
Ns 16
map_Kd bark_0004.jpg
newmtl DB2X2_L01
Ka 1.000000 1.000000 1.000000
Kd 1.000000 1.000000 1.000000
Ks 0.000000 0.000000 0.000000
Ns 16
map_Kd DB2X2_L01.png

115168
godot/Tree 02/Tree.obj Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,22 @@
[remap]
importer="wavefront_obj"
importer_version=1
type="Mesh"
uid="uid://4yqnykw8xhji"
path="res://.godot/imported/Tree.obj-cd92af512cca915c9724506a8e566f48.mesh"
[deps]
files=["res://.godot/imported/Tree.obj-cd92af512cca915c9724506a8e566f48.mesh"]
source_file="res://Tree 02/Tree.obj"
dest_files=["res://.godot/imported/Tree.obj-cd92af512cca915c9724506a8e566f48.mesh", "res://.godot/imported/Tree.obj-cd92af512cca915c9724506a8e566f48.mesh"]
[params]
generate_tangents=true
scale_mesh=Vector3(1, 1, 1)
offset_mesh=Vector3(0, 0, 0)
optimize_mesh=true
force_disable_mesh_compression=false

133748
godot/Tree 02/Tree_01.ma Normal file

File diff suppressed because it is too large Load Diff

BIN
godot/Tree 02/bark_0004.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 692 KiB

View File

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dtm4j5pnm12w1"
path.s3tc="res://.godot/imported/bark_0004.jpg-b999250879d3bf2d3a62e2ef0562ae74.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
[deps]
source_file="res://Tree 02/bark_0004.jpg"
dest_files=["res://.godot/imported/bark_0004.jpg-b999250879d3bf2d3a62e2ef0562ae74.s3tc.ctex"]
[params]
compress/mode=2
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
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=0

View File

@ -2,9 +2,9 @@
[ext_resource type="PackedScene" uid="uid://clkrjexk1mje0" path="res://PlanetGeneration.tscn" id="1_65in3"]
[ext_resource type="Texture2D" uid="uid://osf4dpcksyxa" path="res://cc71d02a-1e5a-4aa3-a8f2-44f262a17d38_scaled.jpg" id="1_vooe1"]
[ext_resource type="Script" path="res://Scripts/Player/Camera3D.gd" id="2_4ip6j"]
[ext_resource type="Script" path="res://Scripts/PlanetGeneration/PlanetData.gd" id="2_gy4ke"]
[ext_resource type="Texture2D" uid="uid://0evqagsrs13i" path="res://Earth-LikeGradient.tres" id="3_orhq2"]
[ext_resource type="PackedScene" uid="uid://dmyni0e38gals" path="res://Player.tscn" id="6_e2qso"]
[sub_resource type="PanoramaSkyMaterial" id="PanoramaSkyMaterial_vl6wy"]
panorama = ExtResource("1_vooe1")
@ -22,15 +22,15 @@ ambient_light_energy = 2.59
tonemap_mode = 2
glow_enabled = true
[sub_resource type="FastNoiseLite" id="FastNoiseLite_ubgvy"]
[sub_resource type="FastNoiseLite" id="FastNoiseLite_q0yxn"]
noise_type = 0
frequency = 1.0
fractal_octaves = 10
[sub_resource type="Resource" id="Resource_12q14"]
[sub_resource type="Resource" id="Resource_qohml"]
script = ExtResource("2_gy4ke")
radius = 50.0
noise_map = SubResource("FastNoiseLite_ubgvy")
radius = 2000.0
noise_map = SubResource("FastNoiseLite_q0yxn")
amplitude = 0.1
planet_color = ExtResource("3_orhq2")
flatness = 6.0
@ -45,10 +45,7 @@ shadow_enabled = true
environment = SubResource("Environment_qj44i")
[node name="Planet" parent="." instance=ExtResource("1_65in3")]
planet_data = SubResource("Resource_12q14")
planet_data = SubResource("Resource_qohml")
[node name="Camera3D" type="Camera3D" parent="."]
transform = Transform3D(0.90061, -0.173246, -0.398607, 0, 0.917122, -0.398607, 0.434628, 0.358989, 0.825969, -35.8229, -10.2513, 382.498)
script = ExtResource("2_4ip6j")
velocity = Vector3(-0.469469, -0.469469, -1.12083)
acceleration = Vector3(0.0039095, 0.0039095, -0.00833256)
[node name="Player" parent="." instance=ExtResource("6_e2qso")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 43.381, -3136.67)

62
godot/tree.mtl Normal file
View File

@ -0,0 +1,62 @@
# Blender 4.0.2 MTL File: 'tree.blend'
# www.blender.org
newmtl Material.001
Ns 250.000000
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.117483 0.071380
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
newmtl Material.002
Ns 250.000000
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.047033 0.038684
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
newmtl Material.003
Ns 250.000000
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.046169 0.030582
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
newmtl Material.004
Ns 250.000000
Ka 1.000000 1.000000 1.000000
Kd 0.033941 0.800000 0.012709
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
newmtl Material.005
Ns 250.000000
Ka 1.000000 1.000000 1.000000
Kd 0.024127 0.161538 0.001506
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
newmtl Material.006
Ns 250.000000
Ka 1.000000 1.000000 1.000000
Kd 0.246567 0.800142 0.118680
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2

1446
godot/tree.obj Normal file

File diff suppressed because it is too large Load Diff

22
godot/tree.obj.import Normal file
View File

@ -0,0 +1,22 @@
[remap]
importer="wavefront_obj"
importer_version=1
type="Mesh"
uid="uid://wqu5ixp1cj0x"
path="res://.godot/imported/tree.obj-44a9d469a60703448807b4ef54c3e397.mesh"
[deps]
files=["res://.godot/imported/tree.obj-44a9d469a60703448807b4ef54c3e397.mesh"]
source_file="res://tree.obj"
dest_files=["res://.godot/imported/tree.obj-44a9d469a60703448807b4ef54c3e397.mesh", "res://.godot/imported/tree.obj-44a9d469a60703448807b4ef54c3e397.mesh"]
[params]
generate_tangents=true
scale_mesh=Vector3(1, 1, 1)
offset_mesh=Vector3(0, 0, 0)
optimize_mesh=true
force_disable_mesh_compression=false