forked from armory3d/logic_pack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
blender.py
86 lines (74 loc) · 3.02 KB
/
blender.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import bpy
from bpy.props import *
from bpy.types import Node, NodeSocket
from arm.logicnode.arm_nodes import *
import arm.nodes_logic
class QuatToEulerNode(Node, ArmLogicTreeNode):
'''QuatToEulerNode'''
bl_idname = 'LNQuatToEulerNode'
bl_label = 'Quat To Euler'
bl_icon = 'GAME'
def init(self, context):
self.inputs.new('NodeSocketFloat', 'X')
self.inputs.new('NodeSocketFloat', 'Y')
self.inputs.new('NodeSocketFloat', 'Z')
self.inputs.new('NodeSocketFloat', 'W')
self.outputs.new('NodeSocketVector', 'Euler')
class SeparateQuatNode(Node, ArmLogicTreeNode):
'''SeparateQuatNode'''
bl_idname = 'LNSeparateQuatNode'
bl_label = 'Separate Quat'
bl_icon = 'GAME'
def init(self, context):
self.inputs.new('NodeSocketShader', 'Transform')
self.outputs.new('NodeSocketFloat', 'X')
self.outputs.new('NodeSocketFloat', 'Y')
self.outputs.new('NodeSocketFloat', 'Z')
self.outputs.new('NodeSocketFloat', 'W')
self.outputs.new('NodeSocketVector', 'Euler')
class LookNode(Node, ArmLogicTreeNode):
'''Look Node'''
bl_idname = 'LNLookNode'
bl_label = 'Look'
bl_icon = 'GAME'
def init(self, context):
self.inputs.new('ArmNodeSocketAction', 'In')
self.inputs.new('ArmNodeSocketObject', 'Object')
self.inputs.new('NodeSocketVector', 'Vector')
self.inputs.new('NodeSocketBool', 'Look Y')
self.inputs.new('NodeSocketBool', 'Look Z')
self.inputs.new('NodeSocketFloat', 'Minimum')
self.inputs.new('NodeSocketFloat', 'Maximum')
self.outputs.new('ArmNodeSocketAction', 'Out')
class ArrayLoopIndiceNode(Node, ArmLogicTreeNode):
'''ArrayLoop node avec indice'''
bl_idname = 'LNArrayLoopIndiceNode'
bl_label = 'Array Loop Indice'
bl_icon = 'CURVE_PATH'
def init(self, context):
self.inputs.new('ArmNodeSocketAction', 'In')
self.inputs.new('NodeSocketShader', 'Array')
self.outputs.new('ArmNodeSocketAction', 'Loop')
self.outputs.new('NodeSocketInt', 'Value')
self.outputs.new('ArmNodeSocketAction', 'Done')
self.outputs.new('NodeSocketInt', 'Indice')
class MinMaxNode(Node, ArmLogicTreeNode):
'''Min/Max Node'''
bl_idname = 'LNMinMaxNode'
bl_label = 'MinMax'
bl_icon = 'GAME'
def init(self, context):
self.inputs.new('ArmNodeSocketAction', 'In')
self.inputs.new('NodeSocketShader', 'Value')
self.inputs.new('NodeSocketShader', 'Value')
self.inputs.new('NodeSocketShader', 'Value')
self.outputs.new('ArmNodeSocketAction', 'Out')
def register():
# Add custom nodes
add_node(QuatToEulerNode, category= 'Value')
add_node(SeparateQuatNode, category='Value')
add_node(ArrayLoopIndiceNode, category='Logic')
add_node(MinMaxNode, category='Variable')
add_node(LookNode, category='Action')
# Register newly added nodes
arm.nodes_logic.register_nodes()