armory/blender/arm/logicnode/logic_switch.py
niacdoial 17daabeb29 Improved quaternion and angle handling in logic nodes (+2bugfixes)
- 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)
2020-08-30 15:50:06 +02:00

35 lines
1.1 KiB
Python

import bpy
from bpy.props import *
from bpy.types import Node, NodeSocket
from arm.logicnode.arm_nodes import *
class SwitchNode(Node, ArmLogicTreeNode):
'''Switch node'''
bl_idname = 'LNSwitchNode'
bl_label = 'Switch'
bl_icon = 'NONE'
min_inputs = 2
min_outputs = 1
def __init__(self):
array_nodes[str(id(self))] = self
def init(self, context):
self.inputs.new('ArmNodeSocketAction', 'In')
self.inputs.new('NodeSocketShader', 'Value')
self.outputs.new('ArmNodeSocketAction', 'Default')
def draw_buttons(self, context, layout):
row = layout.row(align=True)
op = row.operator('arm.node_add_input_output', text='New', icon='PLUS', emboss=True)
op.node_index = str(id(self))
op.in_socket_type = 'NodeSocketShader'
op.out_socket_type = 'ArmNodeSocketAction'
op.in_name_format = 'Case {0}'
op.out_name_format = 'Case {0}'
op.in_index_name_offset = -1
op2 = row.operator('arm.node_remove_input_output', text='', icon='X', emboss=True)
op2.node_index = str(id(self))
add_node(SwitchNode, category='Logic')