2017-04-08 00:34:45 +02:00
|
|
|
from arm.logicnode.arm_nodes import *
|
|
|
|
|
2020-09-08 21:16:20 +02:00
|
|
|
class VectorMathNode(ArmLogicTreeNode):
|
2020-10-05 19:55:56 +02:00
|
|
|
"""Operates vectors. Some operations uses only the first input."""
|
2017-04-08 00:34:45 +02:00
|
|
|
bl_idname = 'LNVectorMathNode'
|
|
|
|
bl_label = 'Vector Math'
|
2020-10-27 19:44:37 +01:00
|
|
|
arm_section = 'vector'
|
2020-09-13 11:27:58 +02:00
|
|
|
arm_version = 1
|
2020-10-27 19:44:37 +01:00
|
|
|
|
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'),
|
2019-03-13 19:29:33 +01:00
|
|
|
('Distance', 'Distance', 'Distance'),
|
2020-06-04 22:19:02 +02:00
|
|
|
('Reflect', 'Reflect', 'Reflect'),
|
2017-10-18 11:28:04 +02:00
|
|
|
],
|
2017-04-08 00:34:45 +02:00
|
|
|
name='', default='Add')
|
2020-06-04 22:19:02 +02:00
|
|
|
|
2017-04-08 00:34:45 +02:00
|
|
|
def init(self, context):
|
2020-09-13 11:27:58 +02:00
|
|
|
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')
|