From c6f37c8ef14121682bef9dc973a5a43f5c60ab48 Mon Sep 17 00:00:00 2001 From: Martin Felis Date: Sun, 11 Jan 2026 22:20:39 +0100 Subject: [PATCH] Updated demo project. --- demo/main.gd | 19 ++++ demo/main.gd.uid | 1 + demo/main.tscn | 139 +++++++++++++++++++---- demo/project.godot | 1 + demo/synced_blend_tree_node.tres | 18 +++ demo/synced_blend_tree_node_limping.tres | 19 ++++ demo/walk_limp_blend_tree.tres | 21 ---- 7 files changed, 177 insertions(+), 41 deletions(-) create mode 100644 demo/main.gd create mode 100644 demo/main.gd.uid create mode 100644 demo/synced_blend_tree_node.tres create mode 100644 demo/synced_blend_tree_node_limping.tres delete mode 100644 demo/walk_limp_blend_tree.tres diff --git a/demo/main.gd b/demo/main.gd new file mode 100644 index 0000000..0cf88e5 --- /dev/null +++ b/demo/main.gd @@ -0,0 +1,19 @@ +extends Node3D + +@onready var synced_animation_graph: SyncedAnimationGraph = %SyncedAnimationGraph +@onready var animation_tree: AnimationTree = %AnimationTree +@onready var blend_weight_slider: HSlider = %BlendWeightSlider +@onready var blend_weight_label: Label = %BlendWeightLabel + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + blend_weight_slider.value = 0.0 + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta: float) -> void: + pass + +func _on_blend_weight_slider_value_changed(value: float) -> void: + animation_tree.set("parameters/Blend2/blend_amount", value) + synced_animation_graph.set("parameters/AnimationBlend2Node/blend_amount", value) + blend_weight_label.text = str(value) diff --git a/demo/main.gd.uid b/demo/main.gd.uid new file mode 100644 index 0000000..09b3333 --- /dev/null +++ b/demo/main.gd.uid @@ -0,0 +1 @@ +uid://bjvgqujpqumj7 diff --git a/demo/main.tscn b/demo/main.tscn index ef86770..c843e02 100644 --- a/demo/main.tscn +++ b/demo/main.tscn @@ -1,33 +1,132 @@ -[gd_scene load_steps=5 format=3 uid="uid://svj53e2xoio"] +[gd_scene load_steps=14 format=3 uid="uid://svj53e2xoio"] [ext_resource type="PackedScene" uid="uid://d1xcqdqr1qeu6" path="res://assets/MixamoAmy.glb" id="1_0xm2m"] -[ext_resource type="AnimationNodeBlendTree" uid="uid://dbkgln7hoxxc8" path="res://embedded_statemachine.tres" id="2_h2yge"] -[ext_resource type="AnimationLibrary" uid="uid://bjyfy6m2sr2kp" path="res://animation_library.tres" id="3_1bvp3"] +[ext_resource type="Script" uid="uid://bjvgqujpqumj7" path="res://main.gd" id="1_1bvp3"] +[ext_resource type="AnimationLibrary" uid="uid://dwubn740aqx51" path="res://animation_library.res" id="3_1bvp3"] [ext_resource type="SyncedBlendTree" uid="uid://bijslmj4wd7ap" path="res://synced_blend_tree_node_limping.tres" id="4_1bvp3"] -[node name="Node3D" type="Node3D"] +[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_h2yge"] +albedo_color = Color(0.427493, 0.42749307, 0.42749307, 1) -[node name="MixamoAmy" parent="." instance=ExtResource("1_0xm2m")] +[sub_resource type="PlaneMesh" id="PlaneMesh_h2yge"] +material = SubResource("StandardMaterial3D_h2yge") +size = Vector2(20, 20) -[node name="AnimationTree" type="AnimationTree" parent="."] -active = false -root_node = NodePath("../MixamoAmy") -tree_root = ExtResource("2_h2yge") -anim_player = NodePath("../MixamoAmy/AnimationPlayer") -parameters/Blend2/blend_amount = 0.44 -"parameters/Embedded StateMachine/conditions/is_healthy" = false -"parameters/Embedded StateMachine/conditions/is_limping" = false +[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_h2yge"] +sky_horizon_color = Color(0.66224277, 0.6717428, 0.6867428, 1) +ground_horizon_color = Color(0.66224277, 0.6717428, 0.6867428, 1) -[node name="AnimationPlayer" type="AnimationPlayer" parent="."] -root_node = NodePath("../MixamoAmy") +[sub_resource type="Sky" id="Sky_1bvp3"] +sky_material = SubResource("ProceduralSkyMaterial_h2yge") + +[sub_resource type="Environment" id="Environment_lquwl"] +background_mode = 2 +sky = SubResource("Sky_1bvp3") +tonemap_mode = 2 +glow_enabled = true + +[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_h2yge"] +animation = &"Limping-InPlace" + +[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_1bvp3"] +animation = &"Walk-InPlace" + +[sub_resource type="AnimationNodeBlend2" id="AnimationNodeBlend2_lquwl"] + +[sub_resource type="AnimationNodeBlendTree" id="AnimationNodeBlendTree_7mycd"] +nodes/output/position = Vector2(540, 140) +nodes/Animation/node = SubResource("AnimationNodeAnimation_1bvp3") +nodes/Animation/position = Vector2(120, 80) +"nodes/Animation 2/node" = SubResource("AnimationNodeAnimation_h2yge") +"nodes/Animation 2/position" = Vector2(80, 320) +nodes/Blend2/node = SubResource("AnimationNodeBlend2_lquwl") +nodes/Blend2/position = Vector2(360, 180) +node_connections = [&"output", 0, &"Blend2", &"Blend2", 0, &"Animation", &"Blend2", 1, &"Animation 2"] + +[node name="Main" type="Node3D"] +script = ExtResource("1_1bvp3") + +[node name="UI" type="CanvasLayer" parent="."] + +[node name="MarginContainer" type="MarginContainer" parent="UI"] +anchors_preset = 7 +anchor_left = 0.5 +anchor_top = 1.0 +anchor_right = 0.5 +anchor_bottom = 1.0 +offset_left = -153.5 +offset_top = -40.0 +offset_right = 153.5 +grow_horizontal = 2 +grow_vertical = 0 +size_flags_horizontal = 4 +size_flags_vertical = 8 + +[node name="HBoxContainer" type="HBoxContainer" parent="UI/MarginContainer"] +layout_mode = 2 +theme_override_constants/separation = 14 + +[node name="Label" type="Label" parent="UI/MarginContainer/HBoxContainer"] +layout_mode = 2 +text = "Blend Weight" + +[node name="BlendWeightSlider" type="HSlider" parent="UI/MarginContainer/HBoxContainer"] +unique_name_in_owner = true +custom_minimum_size = Vector2(200, 0) +layout_mode = 2 +size_flags_vertical = 4 +max_value = 1.0 +step = 0.001 + +[node name="BlendWeightLabel" type="Label" parent="UI/MarginContainer/HBoxContainer"] +unique_name_in_owner = true +layout_mode = 2 +text = "0.0" + +[node name="Level" type="Node3D" parent="."] + +[node name="MeshInstance3D" type="MeshInstance3D" parent="Level"] +mesh = SubResource("PlaneMesh_h2yge") +skeleton = NodePath("../..") + +[node name="DirectionalLight3D" type="DirectionalLight3D" parent="Level"] +transform = Transform3D(1, 0, 0, 0, 0.14081486, 0.99003595, 0, -0.99003595, 0.14081486, 0, 2.0531263, 4.9494514) +shadow_enabled = true + +[node name="WorldEnvironment" type="WorldEnvironment" parent="Level"] +environment = SubResource("Environment_lquwl") + +[node name="Camera3D" type="Camera3D" parent="Level"] +transform = Transform3D(1, 0, 0, 0, 0.9897887, 0.14254257, 0, -0.14254257, 0.9897887, 0, 0.89188766, 1.4517534) + +[node name="Characters" type="Node3D" parent="."] + +[node name="MixamoAmy" parent="Characters" instance=ExtResource("1_0xm2m")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.5, 0, 0) + +[node name="AnimationTree" type="AnimationTree" parent="Characters/MixamoAmy"] +unique_name_in_owner = true +root_node = NodePath("%AnimationTree/..") +tree_root = SubResource("AnimationNodeBlendTree_7mycd") +anim_player = NodePath("../AnimationPlayer") +parameters/Blend2/blend_amount = 0.5 + +[node name="MixamoAmySynced" parent="Characters" instance=ExtResource("1_0xm2m")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.5, 0, 0) + +[node name="AnimationPlayer2" type="AnimationPlayer" parent="Characters/MixamoAmySynced"] libraries = { &"animation_library": ExtResource("3_1bvp3") } -[node name="SyncedAnimationGraph" type="SyncedAnimationGraph" parent="."] -animation_player = NodePath("../AnimationPlayer") +[node name="SyncedAnimationGraph" type="SyncedAnimationGraph" parent="Characters/MixamoAmySynced"] +unique_name_in_owner = true +animation_player = NodePath("../AnimationPlayer2") tree_root = ExtResource("4_1bvp3") -skeleton = NodePath("../MixamoAmy/Armature/Skeleton3D") -parameters/AnimationBlend2Node/blend_amount = 0.0 +skeleton = NodePath("../Armature/Skeleton3D") +parameters/AnimationBlend2Node/blend_amount = 0.5 -[editable path="MixamoAmy"] +[connection signal="value_changed" from="UI/MarginContainer/HBoxContainer/BlendWeightSlider" to="." method="_on_blend_weight_slider_value_changed"] + +[editable path="Characters/MixamoAmy"] +[editable path="Characters/MixamoAmySynced"] diff --git a/demo/project.godot b/demo/project.godot index 6571085..158db7e 100644 --- a/demo/project.godot +++ b/demo/project.godot @@ -11,6 +11,7 @@ config_version=5 [application] config/name="Synced Blend Tree Test" +run/main_scene="uid://svj53e2xoio" config/features=PackedStringArray("4.5", "Forward Plus") config/icon="res://icon.svg" diff --git a/demo/synced_blend_tree_node.tres b/demo/synced_blend_tree_node.tres new file mode 100644 index 0000000..b8ef9dd --- /dev/null +++ b/demo/synced_blend_tree_node.tres @@ -0,0 +1,18 @@ +[gd_resource type="SyncedBlendTree" load_steps=4 format=3 uid="uid://de41u8rkjnjyk"] + +[sub_resource type="AnimationSamplerNode" id="AnimationSamplerNode_bvt3d"] +animation = &"animation_library/Run-InPlace" + +[sub_resource type="AnimationSamplerNode" id="AnimationSamplerNode_sntl5"] +animation = &"animation_library/Walk-InPlace" + +[sub_resource type="AnimationBlend2Node" id="AnimationBlend2Node_n4m28"] + +[resource] +nodes/Blend2/node = SubResource("AnimationBlend2Node_n4m28") +nodes/Blend2/position = Vector2(0, 0) +"nodes/AnimationSamplerNode 1/node" = SubResource("AnimationSamplerNode_bvt3d") +"nodes/AnimationSamplerNode 1/position" = Vector2(0, 0) +nodes/AnimationSamplerNode/node = SubResource("AnimationSamplerNode_sntl5") +nodes/AnimationSamplerNode/position = Vector2(0, 0) +node_connections = [&"Blend2", 0, &"AnimationSamplerNode", &"Blend2", 1, &"AnimationSamplerNode 1", &"Output", 0, &"Blend2"] diff --git a/demo/synced_blend_tree_node_limping.tres b/demo/synced_blend_tree_node_limping.tres new file mode 100644 index 0000000..e258d86 --- /dev/null +++ b/demo/synced_blend_tree_node_limping.tres @@ -0,0 +1,19 @@ +[gd_resource type="SyncedBlendTree" load_steps=4 format=3 uid="uid://bijslmj4wd7ap"] + +[sub_resource type="AnimationBlend2Node" id="AnimationBlend2Node_bvt3d"] +blend_amount = 0.5 + +[sub_resource type="AnimationSamplerNode" id="AnimationSamplerNode_sntl5"] +animation = &"animation_library/Limping-InPlace" + +[sub_resource type="AnimationSamplerNode" id="AnimationSamplerNode_n4m28"] +animation = &"animation_library/Walk-InPlace" + +[resource] +nodes/AnimationBlend2Node/node = SubResource("AnimationBlend2Node_bvt3d") +nodes/AnimationBlend2Node/position = Vector2(0, 0) +"nodes/AnimationSamplerNode 1/node" = SubResource("AnimationSamplerNode_sntl5") +"nodes/AnimationSamplerNode 1/position" = Vector2(0, 0) +nodes/AnimationSamplerNode/node = SubResource("AnimationSamplerNode_n4m28") +nodes/AnimationSamplerNode/position = Vector2(0, 0) +node_connections = [&"AnimationBlend2Node", 0, &"AnimationSamplerNode", &"AnimationBlend2Node", 1, &"AnimationSamplerNode 1", &"Output", 0, &"AnimationBlend2Node"] diff --git a/demo/walk_limp_blend_tree.tres b/demo/walk_limp_blend_tree.tres deleted file mode 100644 index afb8810..0000000 --- a/demo/walk_limp_blend_tree.tres +++ /dev/null @@ -1,21 +0,0 @@ -[gd_resource type="AnimationNodeBlendTree" load_steps=4 format=3 uid="uid://c7o0gt3li5p4b"] - -[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_fpiwu"] -animation = &"animation_library/Limping-InPlace" - -[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_4sffn"] -animation = &"animation_library/Walk-InPlace" - -[sub_resource type="AnimationNodeBlend2" id="AnimationNodeBlend2_w6plo"] -sync = true -blend_amount = 0.5 - -[resource] -nodes/output/position = Vector2(860, 160) -nodes/Animation/node = SubResource("AnimationNodeAnimation_4sffn") -nodes/Animation/position = Vector2(280, 100) -"nodes/Animation 2/node" = SubResource("AnimationNodeAnimation_fpiwu") -"nodes/Animation 2/position" = Vector2(280, 300) -nodes/Blend2/node = SubResource("AnimationNodeBlend2_w6plo") -nodes/Blend2/position = Vector2(640, 160) -node_connections = [&"output", 0, &"Blend2", &"Blend2", 0, &"Animation", &"Blend2", 1, &"Animation 2"]