- Made so all nodes outputting a quaternion object also output it as a XYZ (vector) + W (float) combination - Modernized the interface of the "Action/Rotate Object" node, to align on the newer "Action/Set Rotation" node interface ("Action/Rotate Object Along Axis" is now depreciated, but still usable) - Fixed a blender-side-only bug with the "Logic/Switch" node (...which technically could have lead to a compile-time problem if exploited the right way) - Fixed a bug on the "Action/Set Rotation" node: now, quaternion input is automatically normalized in order to avoid accidental scaling - Added a "Value/Separate Quaternion" node - Made so the names of some sockets change in the "Set Rotation" and "Rotate Object" nodes, so they adapt to those nodes' input types. (Same thing with "Value/Vector From Transform"'s output type)
45 lines
1.8 KiB
Python
45 lines
1.8 KiB
Python
import bpy
|
|
from bpy.props import *
|
|
from bpy.types import Node, NodeSocket
|
|
from arm.logicnode.arm_nodes import *
|
|
|
|
class SetRotationNode(Node, ArmLogicTreeNode):
|
|
'''Set rotation node'''
|
|
bl_idname = 'LNSetRotationNode'
|
|
bl_label = 'Set Rotation'
|
|
bl_icon = 'NONE'
|
|
|
|
def init(self, context):
|
|
self.inputs.new('ArmNodeSocketAction', 'In')
|
|
self.inputs.new('ArmNodeSocketObject', 'Object')
|
|
self.inputs.new('NodeSocketVector', 'Euler Angles / Vector XYZ')
|
|
self.inputs.new('NodeSocketFloat', 'Angle / W')
|
|
self.outputs.new('ArmNodeSocketAction', 'Out')
|
|
|
|
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')
|
|
|
|
def draw_buttons(self, context, layout):
|
|
layout.prop(self, 'property0')
|
|
|
|
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)
|
|
|
|
add_node(SetRotationNode, category='Action')
|