diff --git a/core/ai/agents/human/Farmer1.fbx b/core/ai/agents/human/Farmer1.fbx new file mode 100644 index 0000000..7bfa65b Binary files /dev/null and b/core/ai/agents/human/Farmer1.fbx differ diff --git a/core/ai/agents/human/Farmer1.fbx.import b/core/ai/agents/human/Farmer1.fbx.import new file mode 100644 index 0000000..d0bcaad --- /dev/null +++ b/core/ai/agents/human/Farmer1.fbx.import @@ -0,0 +1,44 @@ +[remap] + +importer="scene" +importer_version=1 +type="PackedScene" +uid="uid://b3j2dbcqwodx1" +path="res://.godot/imported/Farmer1.fbx-c6b3fa9e901f9ab5b38c67c1343eab85.scn" + +[deps] + +source_file="res://core/ai/agents/human/Farmer1.fbx" +dest_files=["res://.godot/imported/Farmer1.fbx-c6b3fa9e901f9ab5b38c67c1343eab85.scn"] + +[params] + +nodes/root_type="" +nodes/root_name="" +nodes/root_script=null +nodes/apply_root_scale=true +nodes/root_scale=1.0 +nodes/import_as_skeleton_bones=false +nodes/use_name_suffixes=true +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=true +animation/remove_immutable_tracks=true +animation/import_rest_as_RESET=false +import_script/path="" +materials/extract=0 +materials/extract_format=0 +materials/extract_path="" +_subresources={} +fbx/importer=0 +fbx/allow_geometry_helper_nodes=false +fbx/embedded_image_handling=1 +fbx/naming_version=2 diff --git a/core/ai/agents/human/Farmer2.fbx b/core/ai/agents/human/Farmer2.fbx new file mode 100644 index 0000000..c742b39 Binary files /dev/null and b/core/ai/agents/human/Farmer2.fbx differ diff --git a/core/ai/agents/human/Farmer2.fbx.import b/core/ai/agents/human/Farmer2.fbx.import new file mode 100644 index 0000000..9e91aad --- /dev/null +++ b/core/ai/agents/human/Farmer2.fbx.import @@ -0,0 +1,44 @@ +[remap] + +importer="scene" +importer_version=1 +type="PackedScene" +uid="uid://c5x3ycaxixpxy" +path="res://.godot/imported/Farmer2.fbx-da830fcedaed7d46b77458a4c0e1f611.scn" + +[deps] + +source_file="res://core/ai/agents/human/Farmer2.fbx" +dest_files=["res://.godot/imported/Farmer2.fbx-da830fcedaed7d46b77458a4c0e1f611.scn"] + +[params] + +nodes/root_type="" +nodes/root_name="" +nodes/root_script=null +nodes/apply_root_scale=true +nodes/root_scale=1.0 +nodes/import_as_skeleton_bones=false +nodes/use_name_suffixes=true +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=true +animation/remove_immutable_tracks=true +animation/import_rest_as_RESET=false +import_script/path="" +materials/extract=0 +materials/extract_format=0 +materials/extract_path="" +_subresources={} +fbx/importer=0 +fbx/allow_geometry_helper_nodes=false +fbx/embedded_image_handling=1 +fbx/naming_version=2 diff --git a/core/ai/agents/human/ai_human.tscn b/core/ai/agents/human/ai_human.tscn index f9ff589..c5b9d7a 100644 --- a/core/ai/agents/human/ai_human.tscn +++ b/core/ai/agents/human/ai_human.tscn @@ -6,6 +6,9 @@ [ext_resource type="Animation" uid="uid://ptj85lvvtjpg" path="res://core/ai/agents/human/sitting.res" id="4_8kg0q"] [ext_resource type="Animation" uid="uid://oq22ilhxjejj" path="res://core/ai/agents/human/idle.res" id="4_cuxdk"] [ext_resource type="Animation" uid="uid://6xnsf8x7nmsl" path="res://core/ai/agents/human/walking.res" id="6_cuxdk"] +[ext_resource type="PackedScene" uid="uid://b3j2dbcqwodx1" path="res://core/ai/agents/human/Farmer1.fbx" id="7_hguxe"] +[ext_resource type="PackedScene" uid="uid://c5x3ycaxixpxy" path="res://core/ai/agents/human/Farmer2.fbx" id="8_ke7sb"] +[ext_resource type="Script" uid="uid://dauqq8cqmwrqh" path="res://core/ai/agents/human/dress_human.gd" id="9_2tpdi"] [sub_resource type="AnimationLibrary" id="AnimationLibrary_8kg0q"] _data = { @@ -15,13 +18,79 @@ _data = { &"walking": ExtResource("6_cuxdk") } +[sub_resource type="AnimationLibrary" id="AnimationLibrary_ke7sb"] +_data = { +&"gathering": ExtResource("3_8kg0q"), +&"idle": ExtResource("4_cuxdk"), +&"sitting": ExtResource("4_8kg0q"), +&"walking": ExtResource("6_cuxdk") +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_2tpdi"] +_data = { +&"gathering": ExtResource("3_8kg0q"), +&"idle": ExtResource("4_cuxdk"), +&"sitting": ExtResource("4_8kg0q"), +&"walking": ExtResource("6_cuxdk") +} + [node name="AiHuman" unique_id=1228675528 node_paths=PackedStringArray("anim_player") instance=ExtResource("1_hko2w")] anim_player = NodePath("BaseMesh/AnimationPlayer") [node name="BaseMesh" parent="." index="3" unique_id=1846171523 instance=ExtResource("3_ef4cu")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.9, 0) -[node name="Skeleton3D" parent="BaseMesh/BaseMesh" parent_id_path=PackedInt32Array(1846171523, 1142246531) index="0" unique_id=928995817] +[node name="Skeleton3D" parent="BaseMesh/BaseMesh" parent_id_path=PackedInt32Array(1846171523, 2032005240) index="0" unique_id=1876883359] +bones/0/position = Vector3(-0.0024333135, 0.9952637, 6.9276895e-05) +bones/0/rotation = Quaternion(-0.0049152793, -0.050206795, -0.026513178, 0.99837476) +bones/1/rotation = Quaternion(-0.025209453, 0.006135946, 0.009180705, 0.9996213) +bones/2/rotation = Quaternion(0.020680578, 0.011754706, 0.015464293, 0.99959743) +bones/3/rotation = Quaternion(0.020680578, 0.011754692, 0.015464287, 0.99959743) +bones/4/rotation = Quaternion(-0.053108443, 0.009324013, 0.011697456, 0.9984768) +bones/5/rotation = Quaternion(0.03947722, 0.0123098595, -0.024802445, 0.99883676) +bones/8/rotation = Quaternion(-0.5728458, -0.38286844, 0.60871977, -0.39334446) +bones/9/rotation = Quaternion(0.44939622, 0.29187396, 0.053696252, 0.84259677) +bones/10/rotation = Quaternion(-0.013349593, 0.006303966, 0.231745, 0.97266454) +bones/11/rotation = Quaternion(-0.13493852, -0.23365982, 0.088579476, 0.95882654) +bones/12/rotation = Quaternion(0.1921569, 0.10821218, -0.024087887, 0.9750824) +bones/13/rotation = Quaternion(0.025333803, 0.00917047, 0.048555605, 0.9984571) +bones/14/rotation = Quaternion(-0.0120385215, 0.035021365, -0.027293455, 0.99894124) +bones/17/rotation = Quaternion(0.09417869, -0.072669275, -0.17156787, 0.9779642) +bones/18/rotation = Quaternion(0.14308922, 0.0019350327, -0.0097575225, 0.98965985) +bones/19/rotation = Quaternion(0.114431076, 0.0009974723, -0.016153814, 0.99329937) +bones/22/rotation = Quaternion(0.11025663, -0.026056329, -0.115814656, 0.9867886) +bones/23/rotation = Quaternion(0.08941777, 0.0010620031, -0.023814844, 0.9957089) +bones/24/rotation = Quaternion(0.18236126, 0.0039793584, -0.014504941, 0.9831166) +bones/27/rotation = Quaternion(0.5637914, -0.40525162, 0.5912719, 0.41025364) +bones/28/rotation = Quaternion(0.5117543, -0.062450167, 0.07040776, 0.8539615) +bones/29/rotation = Quaternion(0.06749446, 0.22771753, -0.20722775, 0.9490237) +bones/30/rotation = Quaternion(-0.0005478785, -0.33554533, -0.112540804, 0.93527734) +bones/31/rotation = Quaternion(0.13877106, 0.12508087, 0.031252213, 0.9818965) +bones/32/rotation = Quaternion(-0.01564488, 0.0028465544, -0.073795564, 0.9971466) +bones/33/rotation = Quaternion(0.09055836, 0.16444178, -0.016598457, 0.9820808) +bones/36/rotation = Quaternion(0.048626706, 0.08521321, 0.1502388, 0.98376954) +bones/37/rotation = Quaternion(0.20746112, 0.00031290663, 0.0112788575, 0.97817826) +bones/38/rotation = Quaternion(0.15843387, -0.0010695796, -0.0025179624, 0.9873659) +bones/41/rotation = Quaternion(0.16202472, 0.04171574, 0.09497025, 0.98131984) +bones/42/rotation = Quaternion(0.14799795, 0.00100551, 0.030993575, 0.9885015) +bones/43/rotation = Quaternion(0.04765674, -0.005312021, -0.037802245, 0.9981341) +bones/46/rotation = Quaternion(0.024758164, 0.13509843, 0.9874187, -0.07835583) +bones/47/rotation = Quaternion(-0.1871983, 0.0008643933, -0.010582049, 0.98226476) +bones/48/rotation = Quaternion(0.46037424, -0.13497493, 0.042778272, 0.87636036) +bones/49/rotation = Quaternion(0.3209879, 0.038273156, 0.0024189365, 0.9463065) +bones/52/rotation = Quaternion(-0.060150255, 0.009860813, 0.99663967, -0.05471906) +bones/53/rotation = Quaternion(-0.10502596, -0.00032293255, 0.008123855, 0.9944363) +bones/54/rotation = Quaternion(0.51151097, 0.066536464, -0.07767137, 0.8531686) +bones/55/rotation = Quaternion(0.3453064, -0.067497015, 0.02391528, 0.93575406) + +[node name="AnimationPlayer" parent="BaseMesh" index="1" unique_id=226905852] +libraries/custom = SubResource("AnimationLibrary_8kg0q") + +[node name="Farmer1" parent="." index="4" unique_id=925374995 instance=ExtResource("7_hguxe")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.9, 0) +visible = false + +[node name="Skeleton3D" parent="Farmer1/BaseMesh" parent_id_path=PackedInt32Array(925374995, 35893719) index="0" unique_id=264693097] bones/0/position = Vector3(0.00060560287, 0.9719096, 0.007789615) bones/0/rotation = Quaternion(-0.03158553, -0.024531638, -0.086598895, 0.9954402) bones/1/rotation = Quaternion(-0.068302006, -0.011589706, 0.088431515, 0.99367017) @@ -29,7 +98,7 @@ bones/2/rotation = Quaternion(0.013750468, -0.0028497525, 0.022636604, 0.9996452 bones/3/rotation = Quaternion(0.014052153, -0.0046672956, 0.021981178, 0.99964875) bones/4/rotation = Quaternion(0.08060878, 0.0009885994, -0.05385771, 0.99528927) bones/5/rotation = Quaternion(-0.08819712, -0.010719821, 0.004734955, 0.9960341) -bones/8/rotation = Quaternion(-0.5780019, -0.40066734, 0.5948007, -0.38934776) +bones/8/rotation = Quaternion(-0.6173422, -0.37346625, 0.5666242, -0.3979305) bones/9/rotation = Quaternion(0.5403529, 0.038538188, -0.087646246, 0.8359735) bones/10/rotation = Quaternion(-0.009744837, 0.0007412914, 0.18789424, 0.98214066) bones/11/rotation = Quaternion(0.019992959, 0.15807849, 0.15262179, 0.9753554) @@ -55,7 +124,7 @@ bones/38/rotation = Quaternion(0.13336712, -0.0009009653, 0.002359003, 0.9910635 bones/41/rotation = Quaternion(0.12012116, 0.015946638, 0.088212825, 0.9887037) bones/42/rotation = Quaternion(0.11693482, 0.00096280884, 0.06057904, 0.99128985) bones/43/rotation = Quaternion(0.22191456, 0.026510797, -0.016629422, 0.9745638) -bones/46/rotation = Quaternion(0.00039673893, 0.021240532, 0.99960107, -0.018613452) +bones/46/rotation = Quaternion(0.059241787, 0.12928401, 0.9836761, -0.110261135) bones/47/rotation = Quaternion(-0.34151906, -0.06546942, 0.0071559767, 0.93756455) bones/48/rotation = Quaternion(0.60213244, 0.010313871, -0.012120304, 0.7982376) bones/49/rotation = Quaternion(0.31586254, 0.059334766, -0.020474449, 0.9467265) @@ -64,7 +133,65 @@ bones/53/rotation = Quaternion(-0.20515193, 0.049833227, 0.0071537, 0.9774345) bones/54/rotation = Quaternion(0.55275166, -0.049315806, -0.007871797, 0.8318483) bones/55/rotation = Quaternion(0.326561, -0.058840513, 0.019667907, 0.9431378) -[node name="AnimationPlayer" parent="BaseMesh" index="1" unique_id=2096005878] -libraries/custom = SubResource("AnimationLibrary_8kg0q") +[node name="AnimationPlayer" parent="Farmer1" index="1" unique_id=1795570086] +libraries/custom = SubResource("AnimationLibrary_ke7sb") + +[node name="Farmer2" parent="." index="5" unique_id=1239853450 instance=ExtResource("8_ke7sb")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.9, 0) +visible = false + +[node name="Skeleton3D" parent="Farmer2/BaseMesh" parent_id_path=PackedInt32Array(1239853450, 2123768022) index="0" unique_id=1560566445] +bones/0/position = Vector3(0.00060560287, 0.9719096, 0.007789615) +bones/0/rotation = Quaternion(-0.03158553, -0.024531638, -0.086598895, 0.9954402) +bones/1/rotation = Quaternion(-0.068302006, -0.011589706, 0.088431515, 0.99367017) +bones/2/rotation = Quaternion(0.013750468, -0.0028497525, 0.022636604, 0.99964523) +bones/3/rotation = Quaternion(0.014052153, -0.0046672956, 0.021981178, 0.99964875) +bones/4/rotation = Quaternion(0.08060878, 0.0009885994, -0.05385771, 0.99528927) +bones/5/rotation = Quaternion(-0.08819712, -0.010719821, 0.004734955, 0.9960341) +bones/8/rotation = Quaternion(-0.6173422, -0.37346625, 0.5666242, -0.3979305) +bones/9/rotation = Quaternion(0.5403529, 0.038538188, -0.087646246, 0.8359735) +bones/10/rotation = Quaternion(-0.009744837, 0.0007412914, 0.18789424, 0.98214066) +bones/11/rotation = Quaternion(0.019992959, 0.15807849, 0.15262179, 0.9753554) +bones/12/rotation = Quaternion(0.11525436, -0.03521942, -0.0147265345, 0.9926023) +bones/13/rotation = Quaternion(0.004553697, -0.0011956134, 0.0748576, 0.9971832) +bones/14/rotation = Quaternion(-0.021573644, -0.09607655, -0.02610063, 0.9947978) +bones/17/rotation = Quaternion(0.10615231, -0.012490018, -0.06538699, 0.9921191) +bones/18/rotation = Quaternion(0.112639524, -0.0005986789, -0.020016164, 0.99343413) +bones/19/rotation = Quaternion(0.13624819, 0.001439244, -0.018421004, 0.9905025) +bones/22/rotation = Quaternion(0.051831737, -0.007218998, -0.063239366, 0.9966254) +bones/23/rotation = Quaternion(0.12439526, 0.00031310506, -0.03746358, 0.99152523) +bones/24/rotation = Quaternion(0.14832872, 0.0028264069, -0.017447466, 0.9887802) +bones/27/rotation = Quaternion(0.6085938, -0.37735197, 0.5827399, 0.3842309) +bones/28/rotation = Quaternion(0.42811802, -0.12440211, 0.04666202, 0.8939026) +bones/29/rotation = Quaternion(-0.010464899, -0.0008133942, -0.24076757, 0.97052604) +bones/30/rotation = Quaternion(0.01554073, -0.15455346, -0.11519627, 0.9811226) +bones/31/rotation = Quaternion(0.109474085, 0.02398801, 0.02464503, 0.99339455) +bones/32/rotation = Quaternion(-0.03558804, 0.04901748, 0.08471445, 0.9945624) +bones/33/rotation = Quaternion(0.014632019, 0.019343862, -0.1317728, 0.9909832) +bones/36/rotation = Quaternion(0.19392295, 0.020005528, 0.11780725, 0.973712) +bones/37/rotation = Quaternion(0.090232305, 2.462184e-07, 0.01726049, 0.9957712) +bones/38/rotation = Quaternion(0.13336712, -0.0009009653, 0.002359003, 0.9910635) +bones/41/rotation = Quaternion(0.12012116, 0.015946638, 0.088212825, 0.9887037) +bones/42/rotation = Quaternion(0.11693482, 0.00096280884, 0.06057904, 0.99128985) +bones/43/rotation = Quaternion(0.22191456, 0.026510797, -0.016629422, 0.9745638) +bones/46/rotation = Quaternion(0.059241787, 0.12928401, 0.9836761, -0.110261135) +bones/47/rotation = Quaternion(-0.34151906, -0.06546942, 0.0071559767, 0.93756455) +bones/48/rotation = Quaternion(0.60213244, 0.010313871, -0.012120304, 0.7982376) +bones/49/rotation = Quaternion(0.31586254, 0.059334766, -0.020474449, 0.9467265) +bones/52/rotation = Quaternion(-0.07240856, 0.034467246, 0.9931159, -0.085380435) +bones/53/rotation = Quaternion(-0.20515193, 0.049833227, 0.0071537, 0.9774345) +bones/54/rotation = Quaternion(0.55275166, -0.049315806, -0.007871797, 0.8318483) +bones/55/rotation = Quaternion(0.326561, -0.058840513, 0.019667907, 0.9431378) + +[node name="AnimationPlayer" parent="Farmer2" index="1" unique_id=916643412] +libraries/custom = SubResource("AnimationLibrary_2tpdi") + +[node name="DressHuman" type="Node3D" parent="." index="6" unique_id=107727715 node_paths=PackedStringArray("farmers", "main_anim_player")] +script = ExtResource("9_2tpdi") +farmers = [NodePath("../Farmer1"), NodePath("../Farmer2")] +colors = Array[Color]([Color(0, 0, 0, 1), Color(1, 1, 1, 1), Color(1, 0, 0, 1), Color(0, 1, 0, 1), Color(0, 0, 1, 1)]) +main_anim_player = NodePath("../BaseMesh/AnimationPlayer") [editable path="BaseMesh"] +[editable path="Farmer1"] +[editable path="Farmer2"] diff --git a/core/ai/agents/human/dress_human.gd b/core/ai/agents/human/dress_human.gd new file mode 100644 index 0000000..fbe4625 --- /dev/null +++ b/core/ai/agents/human/dress_human.gd @@ -0,0 +1,59 @@ +extends Node + +@export var farmers: Array[Node3D] +@export var colors: Array[Color] + +@export var main_anim_player: AnimationPlayer +var dress_anim_player: AnimationPlayer + +func _ready() -> void: + if farmers.is_empty(): + return + + for farmer in farmers: + if farmer: + farmer.hide() + + var selected_farmer = farmers.pick_random() + if selected_farmer: + selected_farmer.show() + + dress_anim_player = selected_farmer.get_node_or_null("AnimationPlayer") + + if main_anim_player and dress_anim_player: + main_anim_player.current_animation_changed.connect(_on_animation_sync) + main_anim_player.animation_started.connect(_on_animation_sync) + + if main_anim_player.current_animation != "": + _on_animation_sync(main_anim_player.current_animation) + dress_anim_player.seek(main_anim_player.current_animation_position) + + if colors.size() > 0: + var parts_to_color = ["pants", "shirt"] + var shared_color = colors.pick_random() + + for part_name in parts_to_color: + var piece_node = _find_mesh_case_insensitive(selected_farmer, part_name) + + if piece_node: + var mat = StandardMaterial3D.new() + mat.albedo_color = shared_color + + piece_node.set_surface_override_material(0, mat) + +func _on_animation_sync(anim_name: StringName) -> void: + if dress_anim_player and dress_anim_player.has_animation(anim_name): + dress_anim_player.play(anim_name) + dress_anim_player.speed_scale = main_anim_player.speed_scale + +func _find_mesh_case_insensitive(parent: Node, part_name: String) -> MeshInstance3D: + var target = part_name.to_lower() + for child in parent.get_children(): + if child.name.to_lower().contains(target) and child is MeshInstance3D: + return child + + var found = _find_mesh_case_insensitive(child, target) + if found: + return found + + return null diff --git a/core/ai/agents/human/dress_human.gd.uid b/core/ai/agents/human/dress_human.gd.uid new file mode 100644 index 0000000..43c52dc --- /dev/null +++ b/core/ai/agents/human/dress_human.gd.uid @@ -0,0 +1 @@ +uid://dauqq8cqmwrqh