2017-03-21 03:06:38 +01:00
|
|
|
import bpy
|
|
|
|
from bpy.props import *
|
|
|
|
from bpy.types import Node, NodeSocket
|
|
|
|
from arm.logicnode.arm_nodes import *
|
|
|
|
|
|
|
|
class MathNode(Node, ArmLogicTreeNode):
|
|
|
|
'''Math node'''
|
2017-04-04 23:11:31 +02:00
|
|
|
bl_idname = 'LNMathNode'
|
2017-03-21 03:06:38 +01:00
|
|
|
bl_label = 'Math'
|
|
|
|
bl_icon = 'CURVE_PATH'
|
|
|
|
property0 = EnumProperty(
|
|
|
|
items = [('Add', 'Add', 'Add'),
|
|
|
|
('Multiply', 'Multiply', 'Multiply'),
|
|
|
|
('Sine', 'Sine', 'Sine'),
|
2017-04-14 20:38:50 +02:00
|
|
|
('Cosine', 'Cosine', 'Cosine'),
|
2017-10-18 11:28:04 +02:00
|
|
|
('Max', 'Maximum', 'Max'),
|
|
|
|
('Min', 'Minimum', 'Min'),
|
|
|
|
('Abs', 'Absolute', 'Abs'),
|
|
|
|
|
|
|
|
('Subtract', 'Subtract', 'Subtract'),
|
|
|
|
('Divide', 'Divide', 'Divide'),
|
|
|
|
('Tangent', 'Tangent', 'Tangent'),
|
|
|
|
('Arcsine', 'Arcsine', 'Arcsine'),
|
|
|
|
('Arccosine', 'Arccosine', 'Arccosine'),
|
|
|
|
('Arctangent', 'Arctangent', 'Arctangent'),
|
|
|
|
('Power', 'Power', 'Power'),
|
|
|
|
('Logarithm', 'Logarithm', 'Logarithm'),
|
|
|
|
('Round', 'Round', 'Round'),
|
|
|
|
('Less Than', 'Less Than', 'Less Than'),
|
|
|
|
('Greater Than', 'Greater Than', 'Greater Than'),
|
|
|
|
('Modulo', 'Modulo', 'Modulo'),
|
2018-08-15 19:11:47 +02:00
|
|
|
('Arctan2', 'Arctan2', 'Arctan2'),
|
|
|
|
('Floor', 'Floor', 'Floor'),
|
|
|
|
('Ceil', 'Ceil', 'Ceil'),
|
|
|
|
('Fract', 'Fract', 'Fract'),
|
|
|
|
('Square Root', 'Square Root', 'Square Root'),
|
2017-10-18 11:28:04 +02:00
|
|
|
],
|
2017-04-03 22:29:46 +02:00
|
|
|
name='', default='Add')
|
2017-03-21 03:06:38 +01:00
|
|
|
|
2017-10-18 11:28:04 +02:00
|
|
|
@property
|
|
|
|
def property1(self):
|
|
|
|
return 'true' if self.property1_ else 'false'
|
|
|
|
|
|
|
|
property1_ = BoolProperty(name='Clamp', default=False)
|
|
|
|
|
2017-03-21 03:06:38 +01:00
|
|
|
def init(self, context):
|
2017-04-08 00:34:45 +02:00
|
|
|
self.inputs.new('NodeSocketFloat', 'Value')
|
2017-10-19 18:27:01 +02:00
|
|
|
self.inputs[-1].default_value = 0.5
|
2017-04-08 00:34:45 +02:00
|
|
|
self.inputs.new('NodeSocketFloat', 'Value')
|
2017-10-19 18:27:01 +02:00
|
|
|
self.inputs[-1].default_value = 0.5
|
2017-04-08 00:34:45 +02:00
|
|
|
self.outputs.new('NodeSocketFloat', 'Value')
|
2017-03-21 03:06:38 +01:00
|
|
|
|
|
|
|
def draw_buttons(self, context, layout):
|
2017-10-18 11:28:04 +02:00
|
|
|
layout.prop(self, 'property1_')
|
2017-04-03 22:29:46 +02:00
|
|
|
layout.prop(self, 'property0')
|
2017-03-21 03:06:38 +01:00
|
|
|
|
|
|
|
add_node(MathNode, category='Value')
|