LNXSDK/leenkx/blender/lnx/logicnode/animation/LN_play_action_from.py
2025-01-22 16:18:30 +01:00

52 lines
2.3 KiB
Python

from lnx.logicnode.lnx_nodes import *
class PlayActionFromNode(LnxLogicTreeNode):
"""
Plays animation action, that starts from given frame (0 is the first), and ends at given frame (-1 for last frame).
@input In: Activates the node logic.
@input Object: States object/armature to run the animation action on.
@input Action: States animation action to be played.
@input Start Frame: Sets frame the animation should start at from 0.
@input End Frame: Sets frame the animation should end at. HINT: Set to "-1" if you want the total frames length of the animation.
@input Blend: Sets rate to blend multiple animations together.
@input Speed: Sets rate the animation plays at.
@input Loop: Sets whether the animation should rewind itself after finishing.
@output Out: Executes whenever the node is run.
@output Done: Executes whenever the played animation is finished. (Only triggers if looping is false.)
"""
bl_idname = 'LNPlayActionFromNode'
bl_label = 'Play Action From'
lnx_version = 3
def lnx_init(self, context):
self.add_input('LnxNodeSocketAction', 'In')
self.add_input('LnxNodeSocketObject', 'Object')
self.add_input('LnxNodeSocketAnimAction', 'Action')
self.add_input('LnxIntSocket', 'Start Frame')
self.add_input('LnxIntSocket', 'End Frame')
self.add_input('LnxFloatSocket', 'Blend', default_value = 0.25)
self.add_input('LnxFloatSocket', 'Speed', default_value = 1.0)
self.add_input('LnxBoolSocket', 'Loop', default_value = False)
self.add_input('LnxBoolSocket', 'Reverse', default_value = False)
self.add_output('LnxNodeSocketAction', 'Out')
self.add_output('LnxNodeSocketAction', 'Done')
def get_replacement_node(self, node_tree: bpy.types.NodeTree):
if self.lnx_version in (0, 1):
return NodeReplacement(
'LNPlayActionFromNode', self.lnx_version, 'LNPlayActionFromNode', 2,
in_socket_mapping={0:0, 1:1, 2:2, 3:3, 4:4}, out_socket_mapping={0:0, 1:1}
)
if self.lnx_version == 2:
return NodeReplacement(
'LNPlayActionFromNode', self.lnx_version, 'LNPlayActionFromNode', 3,
in_socket_mapping={0:0, 1:1, 2:2, 3:3, 4:5, 5:6, 6:7}, out_socket_mapping={0:0, 1:1}
)
raise LookupError()