Much stuff wow
This commit is contained in:
parent
7255cbdf64
commit
734730beee
45 changed files with 697 additions and 119 deletions
|
|
@ -1,7 +1,6 @@
|
|||
[gd_scene load_steps=5 format=3 uid="uid://c27fogucecn0r"]
|
||||
[gd_scene load_steps=4 format=3 uid="uid://c27fogucecn0r"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://lcedx3lau6v5" path="res://Entities/Tree/scripts/tree.gd" id="1_702jv"]
|
||||
[ext_resource type="PackedScene" uid="uid://bwhpbjdyl577e" path="res://Entities/Tree/assets/tree.glb" id="1_s6kdm"]
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_s6kdm"]
|
||||
radius = 0.2
|
||||
|
|
@ -12,11 +11,9 @@ height = 0.5
|
|||
[node name="Tree" type="Node3D"]
|
||||
script = ExtResource("1_702jv")
|
||||
|
||||
[node name="TreeModel" parent="." instance=ExtResource("1_s6kdm")]
|
||||
[node name="TreeCollision" type="StaticBody3D" parent="." groups=["tree"]]
|
||||
|
||||
[node name="TreeCollision" type="StaticBody3D" parent="TreeModel" groups=["tree"]]
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="TreeModel/TreeCollision"]
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="TreeCollision"]
|
||||
shape = SubResource("CapsuleShape3D_s6kdm")
|
||||
|
||||
[node name="InteractRange" type="Area3D" parent="."]
|
||||
|
|
|
|||
|
|
@ -1,2 +0,0 @@
|
|||
class_name TreeDataResource
|
||||
extends Resource
|
||||
Binary file not shown.
|
|
@ -1,37 +0,0 @@
|
|||
[remap]
|
||||
|
||||
importer="scene"
|
||||
importer_version=1
|
||||
type="PackedScene"
|
||||
uid="uid://c5squxlbapts8"
|
||||
path="res://.godot/imported/flowers-tall.glb-95d03d8d03dfdd00c1156b3c9d948d51.scn"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Entities/Tree/assets/flowers-tall.glb"
|
||||
dest_files=["res://.godot/imported/flowers-tall.glb-95d03d8d03dfdd00c1156b3c9d948d51.scn"]
|
||||
|
||||
[params]
|
||||
|
||||
nodes/root_type=""
|
||||
nodes/root_name=""
|
||||
nodes/apply_root_scale=true
|
||||
nodes/root_scale=1.0
|
||||
nodes/import_as_skeleton_bones=false
|
||||
nodes/use_node_type_suffixes=true
|
||||
meshes/ensure_tangents=true
|
||||
meshes/generate_lods=true
|
||||
meshes/create_shadow_meshes=true
|
||||
meshes/light_baking=1
|
||||
meshes/lightmap_texel_size=0.2
|
||||
meshes/force_disable_compression=false
|
||||
skins/use_named_skins=true
|
||||
animation/import=true
|
||||
animation/fps=30
|
||||
animation/trimming=false
|
||||
animation/remove_immutable_tracks=true
|
||||
animation/import_rest_as_RESET=false
|
||||
import_script/path=""
|
||||
_subresources={}
|
||||
gltf/naming_version=1
|
||||
gltf/embedded_image_handling=1
|
||||
Binary file not shown.
|
|
@ -1,37 +0,0 @@
|
|||
[remap]
|
||||
|
||||
importer="scene"
|
||||
importer_version=1
|
||||
type="PackedScene"
|
||||
uid="uid://10c6aovvh80f"
|
||||
path="res://.godot/imported/flowers.glb-e088e23c831479646c36442d07fa990a.scn"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Entities/Tree/assets/flowers.glb"
|
||||
dest_files=["res://.godot/imported/flowers.glb-e088e23c831479646c36442d07fa990a.scn"]
|
||||
|
||||
[params]
|
||||
|
||||
nodes/root_type=""
|
||||
nodes/root_name=""
|
||||
nodes/apply_root_scale=true
|
||||
nodes/root_scale=1.0
|
||||
nodes/import_as_skeleton_bones=false
|
||||
nodes/use_node_type_suffixes=true
|
||||
meshes/ensure_tangents=true
|
||||
meshes/generate_lods=true
|
||||
meshes/create_shadow_meshes=true
|
||||
meshes/light_baking=1
|
||||
meshes/lightmap_texel_size=0.2
|
||||
meshes/force_disable_compression=false
|
||||
skins/use_named_skins=true
|
||||
animation/import=true
|
||||
animation/fps=30
|
||||
animation/trimming=false
|
||||
animation/remove_immutable_tracks=true
|
||||
animation/import_rest_as_RESET=false
|
||||
import_script/path=""
|
||||
_subresources={}
|
||||
gltf/naming_version=1
|
||||
gltf/embedded_image_handling=1
|
||||
Binary file not shown.
|
|
@ -1,37 +0,0 @@
|
|||
[remap]
|
||||
|
||||
importer="scene"
|
||||
importer_version=1
|
||||
type="PackedScene"
|
||||
uid="uid://cltv073ea1df6"
|
||||
path="res://.godot/imported/grass.glb-e355d999e18b247a452756b0c0298f3f.scn"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Entities/Tree/assets/grass.glb"
|
||||
dest_files=["res://.godot/imported/grass.glb-e355d999e18b247a452756b0c0298f3f.scn"]
|
||||
|
||||
[params]
|
||||
|
||||
nodes/root_type=""
|
||||
nodes/root_name=""
|
||||
nodes/apply_root_scale=true
|
||||
nodes/root_scale=1.0
|
||||
nodes/import_as_skeleton_bones=false
|
||||
nodes/use_node_type_suffixes=true
|
||||
meshes/ensure_tangents=true
|
||||
meshes/generate_lods=true
|
||||
meshes/create_shadow_meshes=true
|
||||
meshes/light_baking=1
|
||||
meshes/lightmap_texel_size=0.2
|
||||
meshes/force_disable_compression=false
|
||||
skins/use_named_skins=true
|
||||
animation/import=true
|
||||
animation/fps=30
|
||||
animation/trimming=false
|
||||
animation/remove_immutable_tracks=true
|
||||
animation/import_rest_as_RESET=false
|
||||
import_script/path=""
|
||||
_subresources={}
|
||||
gltf/naming_version=1
|
||||
gltf/embedded_image_handling=1
|
||||
Binary file not shown.
|
|
@ -1,37 +0,0 @@
|
|||
[remap]
|
||||
|
||||
importer="scene"
|
||||
importer_version=1
|
||||
type="PackedScene"
|
||||
uid="uid://7pg0hhklawxb"
|
||||
path="res://.godot/imported/mushrooms.glb-fbdb79cee23454ae0534ba9b11cd89be.scn"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Entities/Tree/assets/mushrooms.glb"
|
||||
dest_files=["res://.godot/imported/mushrooms.glb-fbdb79cee23454ae0534ba9b11cd89be.scn"]
|
||||
|
||||
[params]
|
||||
|
||||
nodes/root_type=""
|
||||
nodes/root_name=""
|
||||
nodes/apply_root_scale=true
|
||||
nodes/root_scale=1.0
|
||||
nodes/import_as_skeleton_bones=false
|
||||
nodes/use_node_type_suffixes=true
|
||||
meshes/ensure_tangents=true
|
||||
meshes/generate_lods=true
|
||||
meshes/create_shadow_meshes=true
|
||||
meshes/light_baking=1
|
||||
meshes/lightmap_texel_size=0.2
|
||||
meshes/force_disable_compression=false
|
||||
skins/use_named_skins=true
|
||||
animation/import=true
|
||||
animation/fps=30
|
||||
animation/trimming=false
|
||||
animation/remove_immutable_tracks=true
|
||||
animation/import_rest_as_RESET=false
|
||||
import_script/path=""
|
||||
_subresources={}
|
||||
gltf/naming_version=1
|
||||
gltf/embedded_image_handling=1
|
||||
Binary file not shown.
|
|
@ -1,37 +0,0 @@
|
|||
[remap]
|
||||
|
||||
importer="scene"
|
||||
importer_version=1
|
||||
type="PackedScene"
|
||||
uid="uid://dpsdijnn33q12"
|
||||
path="res://.godot/imported/plant.glb-7178531d987506ebea1d66a300992d57.scn"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Entities/Tree/assets/plant.glb"
|
||||
dest_files=["res://.godot/imported/plant.glb-7178531d987506ebea1d66a300992d57.scn"]
|
||||
|
||||
[params]
|
||||
|
||||
nodes/root_type=""
|
||||
nodes/root_name=""
|
||||
nodes/apply_root_scale=true
|
||||
nodes/root_scale=1.0
|
||||
nodes/import_as_skeleton_bones=false
|
||||
nodes/use_node_type_suffixes=true
|
||||
meshes/ensure_tangents=true
|
||||
meshes/generate_lods=true
|
||||
meshes/create_shadow_meshes=true
|
||||
meshes/light_baking=1
|
||||
meshes/lightmap_texel_size=0.2
|
||||
meshes/force_disable_compression=false
|
||||
skins/use_named_skins=true
|
||||
animation/import=true
|
||||
animation/fps=30
|
||||
animation/trimming=false
|
||||
animation/remove_immutable_tracks=true
|
||||
animation/import_rest_as_RESET=false
|
||||
import_script/path=""
|
||||
_subresources={}
|
||||
gltf/naming_version=1
|
||||
gltf/embedded_image_handling=1
|
||||
|
|
@ -4,12 +4,12 @@ importer="scene"
|
|||
importer_version=1
|
||||
type="PackedScene"
|
||||
uid="uid://cbpdkprq4oygx"
|
||||
path="res://.godot/imported/stump_squareDetailedWide.glb-d878f01571d1b63564fad6b6c5034e4e.scn"
|
||||
path="res://.godot/imported/stump_squareDetailedWide.glb-cf6ab5acdf21d0d1c819e12a33760a23.scn"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Entities/Tree/assets/temp/stump_squareDetailedWide.glb"
|
||||
dest_files=["res://.godot/imported/stump_squareDetailedWide.glb-d878f01571d1b63564fad6b6c5034e4e.scn"]
|
||||
source_file="res://Entities/Tree/assets/stump_squareDetailedWide.glb"
|
||||
dest_files=["res://.godot/imported/stump_squareDetailedWide.glb-cf6ab5acdf21d0d1c819e12a33760a23.scn"]
|
||||
|
||||
[params]
|
||||
|
||||
|
|
@ -4,12 +4,12 @@ importer="scene"
|
|||
importer_version=1
|
||||
type="PackedScene"
|
||||
uid="uid://besaean4w1n83"
|
||||
path="res://.godot/imported/tree_simple.glb-b9d4e3d58a0247bb4b0a272930d98816.scn"
|
||||
path="res://.godot/imported/tree_birch.glb-5b5f3dd54832f8b215e47c1a3d185b41.scn"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Entities/Tree/assets/temp/tree_simple.glb"
|
||||
dest_files=["res://.godot/imported/tree_simple.glb-b9d4e3d58a0247bb4b0a272930d98816.scn"]
|
||||
source_file="res://Entities/Tree/assets/tree_birch.glb"
|
||||
dest_files=["res://.godot/imported/tree_birch.glb-5b5f3dd54832f8b215e47c1a3d185b41.scn"]
|
||||
|
||||
[params]
|
||||
|
||||
|
|
@ -4,12 +4,12 @@ importer="scene"
|
|||
importer_version=1
|
||||
type="PackedScene"
|
||||
uid="uid://b3lc1nbuv5ol8"
|
||||
path="res://.godot/imported/tree_detailed.glb-b5202c3bc7a30f70608fb9f2e022f85a.scn"
|
||||
path="res://.godot/imported/tree_detailed.glb-9c5d658b3d25a47972c567f3d1f098f9.scn"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Entities/Tree/assets/temp/tree_detailed.glb"
|
||||
dest_files=["res://.godot/imported/tree_detailed.glb-b5202c3bc7a30f70608fb9f2e022f85a.scn"]
|
||||
source_file="res://Entities/Tree/assets/tree_detailed.glb"
|
||||
dest_files=["res://.godot/imported/tree_detailed.glb-9c5d658b3d25a47972c567f3d1f098f9.scn"]
|
||||
|
||||
[params]
|
||||
|
||||
|
|
@ -4,12 +4,12 @@ importer="scene"
|
|||
importer_version=1
|
||||
type="PackedScene"
|
||||
uid="uid://g74ar24o4s1"
|
||||
path="res://.godot/imported/tree_oak.glb-3aa4e2d0d7eaeebf59babfa38b1c94d8.scn"
|
||||
path="res://.godot/imported/tree_oak.glb-44054ae42038fcc129cfdc3e72791764.scn"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Entities/Tree/assets/temp/tree_oak.glb"
|
||||
dest_files=["res://.godot/imported/tree_oak.glb-3aa4e2d0d7eaeebf59babfa38b1c94d8.scn"]
|
||||
source_file="res://Entities/Tree/assets/tree_oak.glb"
|
||||
dest_files=["res://.godot/imported/tree_oak.glb-44054ae42038fcc129cfdc3e72791764.scn"]
|
||||
|
||||
[params]
|
||||
|
||||
|
|
@ -4,12 +4,12 @@ importer="scene"
|
|||
importer_version=1
|
||||
type="PackedScene"
|
||||
uid="uid://vnpet4sa23cm"
|
||||
path="res://.godot/imported/tree_oak_fall.glb-5e5d4e93272aaf8df4999be726ef1d25.scn"
|
||||
path="res://.godot/imported/tree_oak_fall.glb-5423c3799178cc793415b030f003201c.scn"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Entities/Tree/assets/temp/tree_oak_fall.glb"
|
||||
dest_files=["res://.godot/imported/tree_oak_fall.glb-5e5d4e93272aaf8df4999be726ef1d25.scn"]
|
||||
source_file="res://Entities/Tree/assets/tree_oak_fall.glb"
|
||||
dest_files=["res://.godot/imported/tree_oak_fall.glb-5423c3799178cc793415b030f003201c.scn"]
|
||||
|
||||
[params]
|
||||
|
||||
81
Entities/Tree/resources/TreeData.tres
Normal file
81
Entities/Tree/resources/TreeData.tres
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
[gd_resource type="Resource" script_class="TreeDataCollection" load_steps=11 format=3 uid="uid://buf5mtxc5f7o"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dj4dhsd0m0bvd" path="res://Entities/Tree/resources/TreeDataCollection.gd" id="1_7y4l8"]
|
||||
[ext_resource type="Script" uid="uid://cdudelqysppwl" path="res://Entities/Tree/resources/TreeDataResource.gd" id="2_4yk3p"]
|
||||
[ext_resource type="PackedScene" uid="uid://g74ar24o4s1" path="res://Entities/Tree/assets/tree_oak.glb" id="3_4yk3p"]
|
||||
[ext_resource type="PackedScene" uid="uid://bwhpbjdyl577e" path="res://Entities/Tree/assets/tree.glb" id="4_4wxxs"]
|
||||
[ext_resource type="PackedScene" uid="uid://besaean4w1n83" path="res://Entities/Tree/assets/tree_birch.glb" id="5_35hba"]
|
||||
[ext_resource type="PackedScene" uid="uid://b3lc1nbuv5ol8" path="res://Entities/Tree/assets/tree_detailed.glb" id="6_ibfiw"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_7y4l8"]
|
||||
script = ExtResource("2_4yk3p")
|
||||
tree_name = "Oak"
|
||||
model = ExtResource("3_4yk3p")
|
||||
growth_stages = Array[PackedScene]([])
|
||||
temperature_range = Vector2(0.4, 0.9)
|
||||
moisture_range = Vector2(0.3, 0.8)
|
||||
elevation_range = Vector2(0.1, 0.5)
|
||||
max_height = 15.0
|
||||
growth_time = 120.0
|
||||
spawn_probability = 0.1
|
||||
spread_radius = 5.0
|
||||
seasonal_models = Array[PackedScene]([])
|
||||
drops_leaves = true
|
||||
leaf_color_variations = Array[Color]([])
|
||||
metadata/_custom_type_script = "uid://cdudelqysppwl"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_35hba"]
|
||||
script = ExtResource("2_4yk3p")
|
||||
tree_name = "Pine"
|
||||
model = ExtResource("4_4wxxs")
|
||||
growth_stages = Array[PackedScene]([])
|
||||
temperature_range = Vector2(0.1, 0.6)
|
||||
moisture_range = Vector2(0.2, 0.6)
|
||||
elevation_range = Vector2(0.7, 1)
|
||||
max_height = 15.0
|
||||
growth_time = 120.0
|
||||
spawn_probability = 0.1
|
||||
spread_radius = 5.0
|
||||
seasonal_models = Array[PackedScene]([])
|
||||
drops_leaves = true
|
||||
leaf_color_variations = Array[Color]([])
|
||||
metadata/_custom_type_script = "uid://cdudelqysppwl"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_4wxxs"]
|
||||
script = ExtResource("2_4yk3p")
|
||||
tree_name = "Birch"
|
||||
model = ExtResource("5_35hba")
|
||||
growth_stages = Array[PackedScene]([])
|
||||
temperature_range = Vector2(0.2, 0.7)
|
||||
moisture_range = Vector2(0.5, 0.6)
|
||||
elevation_range = Vector2(0.1, 0.5)
|
||||
max_height = 15.0
|
||||
growth_time = 120.0
|
||||
spawn_probability = 0.1
|
||||
spread_radius = 5.0
|
||||
seasonal_models = Array[PackedScene]([])
|
||||
drops_leaves = true
|
||||
leaf_color_variations = Array[Color]([])
|
||||
metadata/_custom_type_script = "uid://cdudelqysppwl"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_54eyh"]
|
||||
script = ExtResource("2_4yk3p")
|
||||
tree_name = "Elder"
|
||||
model = ExtResource("6_ibfiw")
|
||||
growth_stages = Array[PackedScene]([])
|
||||
temperature_range = Vector2(0.3, 0.8)
|
||||
moisture_range = Vector2(0.7, 1)
|
||||
elevation_range = Vector2(0, 0.2)
|
||||
max_height = 15.0
|
||||
growth_time = 120.0
|
||||
spawn_probability = 0.1
|
||||
spread_radius = 5.0
|
||||
seasonal_models = Array[PackedScene]([])
|
||||
drops_leaves = true
|
||||
leaf_color_variations = Array[Color]([])
|
||||
metadata/_custom_type_script = "uid://cdudelqysppwl"
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_7y4l8")
|
||||
trees = Array[ExtResource("2_4yk3p")]([SubResource("Resource_7y4l8"), SubResource("Resource_35hba"), SubResource("Resource_4wxxs"), SubResource("Resource_54eyh")])
|
||||
metadata/_custom_type_script = "uid://dj4dhsd0m0bvd"
|
||||
20
Entities/Tree/resources/TreeDataCollection.gd
Normal file
20
Entities/Tree/resources/TreeDataCollection.gd
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
class_name TreeDataCollection
|
||||
extends Resource
|
||||
|
||||
@export var trees: Array[TreeDataResource] = []
|
||||
|
||||
# Helper functions
|
||||
func get_tree_by_name(name: String) -> TreeDataResource:
|
||||
for tree in trees:
|
||||
if tree.tree_name == name:
|
||||
return tree
|
||||
return null
|
||||
|
||||
func get_suitable_trees(temperature: float, moisture: float, elevation: float) -> Array[TreeDataResource]:
|
||||
var suitable_trees: Array[TreeDataResource] = []
|
||||
for tree in trees:
|
||||
if (temperature >= tree.temperature_range.x and temperature <= tree.temperature_range.y and
|
||||
moisture >= tree.moisture_range.x and moisture <= tree.moisture_range.y and
|
||||
elevation >= tree.elevation_range.x and elevation <= tree.elevation_range.y):
|
||||
suitable_trees.append(tree)
|
||||
return suitable_trees
|
||||
1
Entities/Tree/resources/TreeDataCollection.gd.uid
Normal file
1
Entities/Tree/resources/TreeDataCollection.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://dj4dhsd0m0bvd
|
||||
23
Entities/Tree/resources/TreeDataResource.gd
Normal file
23
Entities/Tree/resources/TreeDataResource.gd
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
class_name TreeDataResource
|
||||
extends Resource
|
||||
|
||||
@export var tree_name: String = "Oak Tree"
|
||||
@export var model: PackedScene
|
||||
@export var icon: Texture2D
|
||||
@export var growth_stages: Array[PackedScene] = []
|
||||
|
||||
@export_group("Biome Preferences")
|
||||
@export var temperature_range: Vector2 = Vector2(0.3, 0.7) # Min/Max temperature
|
||||
@export var moisture_range: Vector2 = Vector2(0.4, 0.8) # Min/Max moisture
|
||||
@export var elevation_range: Vector2 = Vector2(0.0, 0.6) # Min/Max elevation
|
||||
|
||||
@export_group("Growth Properties")
|
||||
@export var max_height: float = 15.0
|
||||
@export var growth_time: float = 120.0 # Seconds to full growth
|
||||
@export var spawn_probability: float = 0.1
|
||||
@export var spread_radius: float = 5.0
|
||||
|
||||
@export_group("Seasonal Behavior")
|
||||
@export var seasonal_models: Array[PackedScene] = [] # Spring, Summer, Fall, Winter
|
||||
@export var drops_leaves: bool = true
|
||||
@export var leaf_color_variations: Array[Color] = []
|
||||
|
|
@ -2,6 +2,9 @@ class_name TreeNode
|
|||
extends Node3D
|
||||
|
||||
@onready var area: Area3D = $InteractRange
|
||||
|
||||
var tree_data: TreeDataResource
|
||||
var model_instance: Node3D
|
||||
var mesh_instances: Array[MeshInstance3D] = []
|
||||
var original_materials: Array[Material] = []
|
||||
var outline_material: Material
|
||||
|
|
@ -9,69 +12,112 @@ var base_circle: MeshInstance3D
|
|||
var circle_material: Material
|
||||
|
||||
func _ready():
|
||||
create_base_circle()
|
||||
# Find all MeshInstance3D nodes in the GLB
|
||||
find_all_mesh_instances(self)
|
||||
|
||||
setup_outline_material()
|
||||
area.body_entered.connect(_on_player_entered)
|
||||
area.body_exited.connect(_on_player_exited)
|
||||
|
||||
func setup_outline_material():
|
||||
if mesh_instances.is_empty():
|
||||
print("Warning: No MeshInstance3D found in GLB!")
|
||||
return
|
||||
func set_tree_data(data: TreeDataResource):
|
||||
tree_data = data
|
||||
spawn_model()
|
||||
|
||||
# Store original materials
|
||||
for mesh in mesh_instances:
|
||||
if mesh.get_surface_override_material(0):
|
||||
original_materials.append(mesh.get_surface_override_material(0))
|
||||
else:
|
||||
original_materials.append(mesh.get_surface_override_material(0))
|
||||
func setup_tree(data: TreeDataResource):
|
||||
# Alternative method name if you prefer
|
||||
set_tree_data(data)
|
||||
|
||||
func spawn_model():
|
||||
if not tree_data or not tree_data.model:
|
||||
Log.pr("No tree data or model provided")
|
||||
return
|
||||
|
||||
# Clear any existing model
|
||||
if model_instance:
|
||||
model_instance.queue_free()
|
||||
mesh_instances.clear()
|
||||
original_materials.clear()
|
||||
|
||||
# Instantiate the model from the TreeDataResource
|
||||
model_instance = tree_data.model.instantiate()
|
||||
add_child(model_instance)
|
||||
|
||||
# Create base circle after model is loaded
|
||||
if not base_circle:
|
||||
create_base_circle()
|
||||
|
||||
# Re-scan for mesh instances in the new model
|
||||
find_all_mesh_instances(model_instance)
|
||||
update_outline_materials()
|
||||
|
||||
# Apply any additional properties from tree_data
|
||||
apply_tree_properties()
|
||||
|
||||
func apply_tree_properties():
|
||||
if not model_instance or not tree_data:
|
||||
return
|
||||
|
||||
# Apply scale variations if defined in tree_data
|
||||
if tree_data.has_method("get_random_scale"):
|
||||
model_instance.scale *= tree_data.get_random_scale()
|
||||
|
||||
# Apply random scale based on tree properties
|
||||
if tree_data.max_height > 0:
|
||||
var scale_variation = randf_range(0.8, 1.2)
|
||||
model_instance.scale *= scale_variation
|
||||
|
||||
func setup_outline_material():
|
||||
# Create outline material with your shader
|
||||
outline_material = ShaderMaterial.new()
|
||||
outline_material.shader = preload("res://outline.gdshader")
|
||||
outline_material.set_shader_parameter("color", Vector3(0.702, 0.557, 0.259))
|
||||
|
||||
func update_outline_materials():
|
||||
if mesh_instances.is_empty():
|
||||
print("Warning: No MeshInstance3D found in model!")
|
||||
return
|
||||
|
||||
# Store original materials for the new model
|
||||
original_materials.clear()
|
||||
for mesh in mesh_instances:
|
||||
if mesh.get_surface_override_material(0):
|
||||
original_materials.append(mesh.get_surface_override_material(0))
|
||||
else:
|
||||
original_materials.append(mesh.get_surface_override_material(0))
|
||||
|
||||
func find_all_mesh_instances(node: Node):
|
||||
if node is MeshInstance3D:
|
||||
mesh_instances.append(node)
|
||||
|
||||
mesh_instances.append(node)
|
||||
for child in node.get_children():
|
||||
find_all_mesh_instances(child)
|
||||
find_all_mesh_instances(child)
|
||||
|
||||
func create_base_circle():
|
||||
base_circle = MeshInstance3D.new()
|
||||
add_child(base_circle)
|
||||
|
||||
|
||||
# Create a flat cylinder for the circle
|
||||
var cylinder = CylinderMesh.new()
|
||||
cylinder.top_radius = 0.4 # Adjust size as needed
|
||||
cylinder.bottom_radius = 0.4
|
||||
cylinder.height = 0.02 # Very thin to make it look like a flat circle
|
||||
cylinder.height = 1 # Very thin to make it look like a flat circle
|
||||
cylinder.rings = 1
|
||||
cylinder.radial_segments = 9 # More segments = smoother circle
|
||||
|
||||
base_circle.mesh = cylinder
|
||||
|
||||
|
||||
# Create transparent material with outline
|
||||
circle_material = StandardMaterial3D.new()
|
||||
circle_material.flags_transparent = true
|
||||
circle_material.albedo_color = Color(1.0, 0.843, 0.0, 0.0) # Fully transparent gold
|
||||
|
||||
|
||||
# Add rim lighting effect for outline appearance
|
||||
circle_material.rim_enabled = true
|
||||
circle_material.rim = 1.0
|
||||
circle_material.rim_tint = 1.0
|
||||
circle_material.rim_color = Color(1.0, 0.843, 0.0) # Gold rim
|
||||
|
||||
base_circle.material_override = circle_material
|
||||
|
||||
# Position at ground level
|
||||
base_circle.position.y = 0.01 # Slightly above ground to avoid z-fighting
|
||||
|
||||
base_circle.position.y = 1 # Slightly above ground to avoid z-fighting
|
||||
|
||||
# Start hidden
|
||||
base_circle.visible = false
|
||||
base_circle.visible = true
|
||||
|
||||
|
||||
func _on_player_entered(body: Node3D):
|
||||
if body.is_in_group("player"):
|
||||
|
|
@ -84,6 +130,6 @@ func _on_player_exited(body: Node3D):
|
|||
if body.is_in_group("player"):
|
||||
Log.pr('Out of range...')
|
||||
base_circle.visible = false
|
||||
# Remove outline from all mesh instances
|
||||
# Remove outline from all mesh instances
|
||||
for mesh in mesh_instances:
|
||||
mesh.material_overlay = null
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue