final changes
This commit is contained in:
parent
973c560b9f
commit
0ca3911519
26 changed files with 1106 additions and 51 deletions
|
@ -2,6 +2,7 @@ extends GL_Animatable
|
|||
|
||||
var anim_tree: AnimationTree
|
||||
var blend_tree: AnimationNodeBlendTree
|
||||
@export var animParameters: Dictionary
|
||||
|
||||
# Assuming this node has a child node with an AnimationPlayer
|
||||
func _ready():
|
||||
|
@ -24,38 +25,59 @@ func _ready():
|
|||
var animations = anim_player.get_animation_list()
|
||||
if animations.size() == 0:
|
||||
return
|
||||
|
||||
if animParameters.size() == 0:
|
||||
for key in animations:
|
||||
_create_anim_dict(key)
|
||||
|
||||
# Handle the case where there is only one animation
|
||||
if animations.size() == 1:
|
||||
var node_name = "Anim_" + animations[0]
|
||||
var anim_node := AnimationNodeAnimation.new()
|
||||
anim_node.animation = animations[0]
|
||||
blend_tree.add_node(node_name, anim_node, Vector2.ZERO)
|
||||
|
||||
var output := AnimationNodeOutput.new()
|
||||
blend_tree.add_node("Output", output, Vector2(200, 0))
|
||||
blend_tree.connect_node("Output", 0, node_name)
|
||||
printerr("STILL NEED TO FIX THIS AHEM")
|
||||
return
|
||||
|
||||
# Start with the first animation node
|
||||
var prev_name = "Anim_" + animations[0]
|
||||
var old_time_name = "Time_" + animations[0]
|
||||
var old_seek_name = "Seek_" + animations[0]
|
||||
|
||||
var prev_anim_node := AnimationNodeAnimation.new()
|
||||
prev_anim_node.animation = animations[0]
|
||||
blend_tree.add_node(prev_name, prev_anim_node, Vector2.ZERO)
|
||||
blend_tree.add_node(prev_name, prev_anim_node)
|
||||
|
||||
var old_time_node := AnimationNodeTimeScale.new()
|
||||
blend_tree.add_node(old_time_name,old_time_node)
|
||||
|
||||
var _old_seek_node := AnimationNodeTimeSeek.new()
|
||||
blend_tree.add_node(old_seek_name,_old_seek_node)
|
||||
|
||||
blend_tree.connect_node(old_time_name,0,prev_name)
|
||||
blend_tree.connect_node(old_seek_name,0,old_time_name)
|
||||
prev_name = old_seek_name
|
||||
|
||||
# Iteratively add and connect animations through Add2 nodes
|
||||
for i in range(1, animations.size()):
|
||||
var anim_name = "Anim_" + animations[i]
|
||||
var add_name = "Add_" + str(i)
|
||||
var add_name = "Add_" + animations[i]
|
||||
var time_name = "Time_" + animations[i]
|
||||
var seek_name = "Seek_" + animations[i]
|
||||
|
||||
var new_anim_node := AnimationNodeAnimation.new()
|
||||
new_anim_node.animation = animations[i]
|
||||
blend_tree.add_node(anim_name, new_anim_node, Vector2(i * 200, 0))
|
||||
blend_tree.add_node(anim_name, new_anim_node)
|
||||
|
||||
var time_node := AnimationNodeTimeScale.new()
|
||||
blend_tree.add_node(time_name,time_node)
|
||||
|
||||
var seek_node := AnimationNodeTimeSeek.new()
|
||||
blend_tree.add_node(seek_name,seek_node)
|
||||
|
||||
var add_node := AnimationNodeAdd2.new()
|
||||
blend_tree.add_node(add_name, add_node, Vector2(i * 200, 100))
|
||||
blend_tree.add_node(add_name, add_node)
|
||||
|
||||
blend_tree.connect_node(time_name,0,anim_name)
|
||||
blend_tree.connect_node(seek_name,0,time_name)
|
||||
blend_tree.connect_node(add_name, 0, prev_name)
|
||||
blend_tree.connect_node(add_name, 1, anim_name)
|
||||
blend_tree.connect_node(add_name, 1, seek_name)
|
||||
prev_name = add_name
|
||||
|
||||
# Final output node connection
|
||||
|
@ -63,22 +85,38 @@ func _ready():
|
|||
|
||||
# Set the blend amount for each additive node
|
||||
for i in range(0, animations.size()):
|
||||
anim_tree.set("parameters/Add_" + str(i) + "/add_amount", 1.0)
|
||||
anim_tree.set("parameters/Add_" + str(animations[i]) + "/add_amount", 1.0)
|
||||
anim_tree.set("parameters/Seek_" + str(animations[i]) + "/seek_request", 0)
|
||||
anim_tree.set("parameters/Time_" + str(animations[i]) + "/scale", 0)
|
||||
|
||||
func _create_anim_dict(name:String):
|
||||
animParameters[name] = {"type":"standard","out_speed":5.0,"in_speed":5.0,"value":0,"signal_value":0}
|
||||
|
||||
func _process(delta):
|
||||
if not anim_tree:
|
||||
return
|
||||
for key in animParameters:
|
||||
var anim_path = "parameters/Seek_" + key + "/seek_request"
|
||||
var anim_player = get_child(0).get_node("AnimationPlayer") as AnimationPlayer
|
||||
|
||||
if not anim_player.has_animation(key):
|
||||
print("Animation not found: ", key)
|
||||
return
|
||||
match(animParameters[key]["type"]):
|
||||
"standard":
|
||||
var value = float(animParameters[key]["signal_value"])
|
||||
if value > 0.01:
|
||||
animParameters[key]["value"] = clamp(float(animParameters[key]["value"]) + (delta * animParameters[key]["out_speed"] * value),0,1)
|
||||
else:
|
||||
animParameters[key]["value"] = clamp(float(animParameters[key]["value"]) - (delta * animParameters[key]["in_speed"] * (1 - value)),0,1)
|
||||
|
||||
"move_to":
|
||||
animParameters[key]["value"] = lerp(float(animParameters[key]["value"]), float(animParameters[key]["signal_value"]),delta * animParameters[key]["out_speed"])
|
||||
var anim_length = anim_player.get_animation(key).length
|
||||
var time_value = clamp(animParameters[key].get("value",0), 0.0, 1.0) * anim_length
|
||||
|
||||
anim_tree.set(anim_path, time_value)
|
||||
|
||||
# Function to set the time of the animation based on a normalized value (0.0 to 1.0)
|
||||
func _sent_signals(anim_name: String, value: float):
|
||||
if not anim_tree:
|
||||
return
|
||||
|
||||
var anim_path = "parameters/Anim_" + anim_name + "/time"
|
||||
var anim_player = get_child(0).get_node("AnimationPlayer") as AnimationPlayer
|
||||
|
||||
if not anim_player.has_animation(anim_name):
|
||||
print("Animation not found: ", anim_name)
|
||||
return
|
||||
|
||||
var anim_length = anim_player.get_animation(anim_name).length
|
||||
var time_value = clamp(value, 0.0, 1.0) * anim_length
|
||||
|
||||
anim_tree.set(anim_path, time_value)
|
||||
animParameters[anim_name]["signal_value"] = clamp(value,0,1)
|
||||
|
|
18
Scripts/GL_Lerp.gd
Normal file
18
Scripts/GL_Lerp.gd
Normal file
|
@ -0,0 +1,18 @@
|
|||
extends GL_Node
|
||||
|
||||
|
||||
func _ready():
|
||||
_set_title("Lerp")
|
||||
_create_row("Value",0.0,0.0,true,0.0,1.0)
|
||||
_create_row("Speed",1.0,null,true,1.0,25.0)
|
||||
pass
|
||||
|
||||
func _process(delta):
|
||||
super._process(delta)
|
||||
|
||||
for key in rows:
|
||||
if rows[key]["picker"] == true && rows[key]["backConnected"] == false:
|
||||
rows[key]["input"] = rows[key]["pickValue"]
|
||||
|
||||
rows["Value"]["output"] = lerp(float(rows["Value"]["output"]),float(rows["Value"]["input"]),delta * rows["Speed"]["input"])
|
||||
_send_input("Value")
|
1
Scripts/GL_Lerp.gd.uid
Normal file
1
Scripts/GL_Lerp.gd.uid
Normal file
|
@ -0,0 +1 @@
|
|||
uid://4m1d1qoykyf6
|
23
Scripts/GL_Mouse_Wheel.gd
Normal file
23
Scripts/GL_Mouse_Wheel.gd
Normal file
|
@ -0,0 +1,23 @@
|
|||
extends GL_Node
|
||||
|
||||
func _ready():
|
||||
_set_title("Mouse Wheel")
|
||||
_create_row("Output", null, 0.0, false, 0.0, 0)
|
||||
_create_row("Step Size", 0.0, null, true, 0.1, 1.0)
|
||||
|
||||
func _process(delta):
|
||||
super._process(delta)
|
||||
|
||||
for key in rows:
|
||||
if rows[key]["picker"] == true && rows[key]["backConnected"] == false:
|
||||
rows[key]["input"] = rows[key]["pickValue"]
|
||||
|
||||
_send_input("Output")
|
||||
|
||||
func _input(event):
|
||||
# Check if the mouse wheel up or down button is pressed
|
||||
if event is InputEventMouseButton:
|
||||
if event.button_index == MOUSE_BUTTON_WHEEL_UP and event.pressed:
|
||||
rows["Output"]["output"] = clamp(rows["Output"]["output"] + rows["Step Size"]["input"], 0, 1)
|
||||
elif event.button_index == MOUSE_BUTTON_WHEEL_DOWN and event.pressed:
|
||||
rows["Output"]["output"] = clamp(rows["Output"]["output"] - rows["Step Size"]["input"], 0, 1)
|
1
Scripts/GL_Mouse_Wheel.gd.uid
Normal file
1
Scripts/GL_Mouse_Wheel.gd.uid
Normal file
|
@ -0,0 +1 @@
|
|||
uid://y8j8wap2o4oe
|
|
@ -142,11 +142,30 @@ func _create_connection(target:GL_Node,input_name:String,output_name:String):
|
|||
print("Connection already exists: " + output_name + " to " + target.name)
|
||||
return
|
||||
|
||||
for node in get_tree().get_nodes_in_group("GL Node"):
|
||||
if node is GL_Node:
|
||||
node.destroy_connection(target,input_name)
|
||||
|
||||
connections.append(thenew)
|
||||
rows[output_name]["connections"] = connections
|
||||
|
||||
target._confirm_backConnection(input_name)
|
||||
|
||||
func destroy_connection(target:GL_Node,input_name:String):
|
||||
for key in rows:
|
||||
var connections = rows[key].get("connections",[])
|
||||
for i in connections.size():
|
||||
if connections[i].target == target and connections[i].input_name == input_name:
|
||||
connections.remove_at(i)
|
||||
rows[key]["connections"] = connections
|
||||
var holder = get_node("Margins").get_node("Holder")
|
||||
for child in holder.get_children():
|
||||
if child.name == "Title":
|
||||
continue
|
||||
(child.get_node("Input") as GL_Node_Point).update_lines()
|
||||
(child.get_node("Output") as GL_Node_Point).update_lines()
|
||||
return
|
||||
|
||||
func mouse_enter():
|
||||
canDrag = true
|
||||
func mouse_exit():
|
||||
|
|
|
@ -9,6 +9,8 @@ var rows : Dictionary = {
|
|||
"Keystrokes":1,
|
||||
"Keystroke Ramp":1,
|
||||
"Mix Colors":1,
|
||||
"Lerp":1,
|
||||
"Mouse Wheel":1,
|
||||
}
|
||||
var searching : bool
|
||||
var lastMousePos : Vector2
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue