armory/blender/arm/logicnode/math/LN_vector_math.py

33 lines
1.4 KiB
Python
Raw Normal View History

2017-04-08 00:34:45 +02:00
from arm.logicnode.arm_nodes import *
class VectorMathNode(ArmLogicTreeNode):
2020-09-23 22:12:25 +02:00
"""Use to operate vectors. You must check in the Wiki what each operator does, because some of them uses only the first input."""
2017-04-08 00:34:45 +02:00
bl_idname = 'LNVectorMathNode'
bl_label = 'Vector Math'
arm_version = 1
2018-12-18 23:48:38 +01:00
property0: EnumProperty(
2017-04-08 00:34:45 +02:00
items = [('Add', 'Add', 'Add'),
('Dot Product', 'Dot Product', 'Dot Product'),
2017-04-14 20:38:50 +02:00
('Multiply', 'Multiply', 'Multiply'),
2017-10-18 11:28:04 +02:00
('Normalize', 'Normalize', 'Normalize'),
('Subtract', 'Subtract', 'Subtract'),
('Average', 'Average', 'Average'),
('Cross Product', 'Cross Product', 'Cross Product'),
2018-04-13 05:20:05 +02:00
('Length', 'Length', 'Length'),
('Distance', 'Distance', 'Distance'),
('Reflect', 'Reflect', 'Reflect'),
2017-10-18 11:28:04 +02:00
],
2017-04-08 00:34:45 +02:00
name='', default='Add')
2017-04-08 00:34:45 +02:00
def init(self, context):
super(VectorMathNode, self).init(context)
2020-09-20 20:10:01 +02:00
self.add_input('NodeSocketVector', 'Vector 1', default_value=[0.0, 0.0, 0.0])
self.add_input('NodeSocketVector', 'Vector 2', default_value=[0.0, 0.0, 0.0])
self.add_output('NodeSocketVector', 'Result')
self.add_output('NodeSocketFloat', 'Distance')
2017-04-08 00:34:45 +02:00
def draw_buttons(self, context, layout):
layout.prop(self, 'property0')
add_node(VectorMathNode, category=PKG_AS_CATEGORY, section='vector')