2017-04-14 20:38:50 +02:00
|
|
|
from arm.logicnode.arm_nodes import *
|
|
|
|
|
2020-09-08 21:16:20 +02:00
|
|
|
class SetRotationNode(ArmLogicTreeNode):
|
2020-10-05 19:55:56 +02:00
|
|
|
"""Sets the rotation of the given object."""
|
2017-04-14 20:38:50 +02:00
|
|
|
bl_idname = 'LNSetRotationNode'
|
2020-09-25 00:49:21 +02:00
|
|
|
bl_label = 'Set Object Rotation'
|
2020-09-13 11:27:58 +02:00
|
|
|
arm_version = 1
|
2017-04-14 20:38:50 +02:00
|
|
|
|
|
|
|
def init(self, context):
|
2020-09-13 11:27:58 +02:00
|
|
|
super(SetRotationNode, self).init(context)
|
2020-09-08 21:49:02 +02:00
|
|
|
self.add_input('ArmNodeSocketAction', 'In')
|
|
|
|
self.add_input('ArmNodeSocketObject', 'Object')
|
|
|
|
self.add_input('NodeSocketVector', 'Euler Angles / Vector XYZ')
|
|
|
|
self.add_input('NodeSocketFloat', 'Angle / W')
|
|
|
|
self.add_output('ArmNodeSocketAction', 'Out')
|
2020-09-08 17:03:24 +02:00
|
|
|
|
2020-08-30 11:45:07 +02:00
|
|
|
def on_property_update(self, context):
|
|
|
|
"""called by the EnumProperty, used to update the node socket labels"""
|
|
|
|
if self.property0 == "Quaternion":
|
|
|
|
self.inputs[2].name = "Quaternion XYZ"
|
|
|
|
self.inputs[3].name = "Quaternion W"
|
|
|
|
elif self.property0 == "Euler Angles":
|
|
|
|
self.inputs[2].name = "Euler Angles"
|
|
|
|
self.inputs[3].name = "[unused for Euler input]"
|
|
|
|
elif self.property0.startswith("Angle Axies"):
|
|
|
|
self.inputs[2].name = "Axis"
|
|
|
|
self.inputs[3].name = "Angle"
|
|
|
|
else:
|
|
|
|
raise ValueError('No nodesocket labels for current input mode: check self-consistancy of action_set_rotation.py')
|
2017-04-14 20:38:50 +02:00
|
|
|
|
2019-09-27 21:35:26 +02:00
|
|
|
def draw_buttons(self, context, layout):
|
|
|
|
layout.prop(self, 'property0')
|
2020-09-08 17:03:24 +02:00
|
|
|
|
2020-08-30 11:45:07 +02:00
|
|
|
property0: EnumProperty(
|
|
|
|
items = [('Euler Angles', 'Euler Angles', 'Euler Angles'),
|
|
|
|
('Angle Axies (Radians)', 'Angle Axies (Radians)', 'Angle Axies (Radians)'),
|
|
|
|
('Angle Axies (Degrees)', 'Angle Axies (Degrees)', 'Angle Axies (Degrees)'),
|
|
|
|
('Quaternion', 'Quaternion', 'Quaternion')],
|
|
|
|
name='', default='Euler Angles',
|
|
|
|
update=on_property_update)
|
2019-09-27 21:35:26 +02:00
|
|
|
|
2020-09-09 20:48:35 +02:00
|
|
|
add_node(SetRotationNode, category=PKG_AS_CATEGORY, section='rotation')
|