armory/blender/arm/logicnode/math/LN_tween_vector.py
2021-09-13 23:10:31 +02:00

73 lines
2.8 KiB
Python

from arm.logicnode.arm_nodes import *
class TweenVectorNode( ArmLogicTreeNode):
'''Tween a vector value
@input Start: Start tweening
@input Stop: Stop a tweening. tweening can be re-started via the `Start`input
@input From: Tween start value
@input To: Tween final value
@input Duration: Duartion of the tween in seconds
@output Out: Executed immidiately after `Start` or `Stop` is called
@output Tick: Executed at every time step in the tween duration
@output Done: Executed when tween is successfully completed. Not executed if tweening is stopped mid-way
@output Value: Current tween value
'''
bl_idname = 'LNTweenVectorNode'
bl_label = 'Tween Vector'
arm_version = 1
property0: HaxeEnumProperty(
'property0',
items = [('Linear', 'Linear', 'Linear'),
('SineIn', 'SineIn', 'SineIn'),
('SineOut', 'SineOut', 'SineOut'),
('SineInOut', 'SineInOut', 'SineInOut'),
('QuadIn', 'QuadIn', 'QuadIn'),
('QuadOut', 'QuadOut', 'QuadOut'),
('QuadInOut', 'QuadInOut', 'QuadInOut'),
('CubicIn', 'CubicIn', 'CubicIn'),
('CubicOut', 'CubicOut', 'CubicOut'),
('CubicInOut', 'CubicInOut', 'CubicInOut'),
('QuartIn', 'QuartIn', 'QuartIn'),
('QuartOut', 'QuartOut', 'QuartOut'),
('QuartInOut', 'QuartInOut', 'QuartInOut'),
('QuintIn', 'QuintIn', 'QuintIn'),
('QuintOut', 'QuintOut', 'QuintOut'),
('QuintInOut', 'QuintInOut', 'QuintInOut'),
('ExpoIn', 'ExpoIn', 'ExpoIn'),
('ExpoOut', 'ExpoOut', 'ExpoOut'),
('ExpoInOut', 'ExpoInOut', 'ExpoInOut'),
('CircIn', 'CircIn', 'CircIn'),
('CircOut', 'CircOut', 'CircOut'),
('CircInOut', 'CircInOut', 'CircInOut'),
('BackIn', 'BackIn', 'BackIn'),
('BackOut', 'BackOut', 'BackOut'),
('BackInOut', 'BackInOut', 'BackInOut')],
name='', default='Linear')
def init(self, context):
self.add_input('ArmNodeSocketAction', 'Start')
self.add_input('ArmNodeSocketAction', 'Stop')
self.add_input('ArmVectorSocket', 'From')
self.add_input('ArmVectorSocket', 'To')
self.add_input('ArmFloatSocket', 'Duration', default_value = 1.0)
self.add_output('ArmNodeSocketAction', 'Out')
self.add_output('ArmNodeSocketAction', 'Tick')
self.add_output('ArmNodeSocketAction', 'Done')
self.add_output('ArmVectorSocket', 'Value')
def draw_buttons(self, context, layout):
layout.prop(self, 'property0')
def draw_label(self) -> str:
return f'{self.bl_label}: {self.property0}'