Skip to content
This repository has been archived by the owner on Jan 29, 2024. It is now read-only.

Commit

Permalink
Make use of new node API
Browse files Browse the repository at this point in the history
  • Loading branch information
MoritzBrueckner committed Oct 11, 2020
1 parent 0181cb6 commit dbb573b
Show file tree
Hide file tree
Showing 19 changed files with 136 additions and 155 deletions.
4 changes: 2 additions & 2 deletions logicnode_definitions/Template.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# bl_icon = 'QUESTION'

# def init(self, context):
# self.inputs.new('<SocketType>', '<SocketName>')
# self.outputs.new('<SocketType>', '<SocketName>')
# self.add_input('<SocketType>', '<SocketName>')
# self.add_output('<SocketType>', '<SocketName>')

# add_node(<NodeName>, category='<Category of the node>')
56 changes: 25 additions & 31 deletions logicnode_definitions/action_camera_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,37 +11,31 @@ class CameraController(ArmLogicTreeNode):
bl_icon = 'QUESTION'

def init(self, context):
self.outputs.new('ArmNodeSocketAction', 'Out')

self.inputs.new('ArmNodeSocketAction', 'Activate')

self.inputs.new('ArmNodeSocketObject', 'Player Object')
self.inputs[-1].default_value = 'Player'

self.inputs.new('ArmNodeSocketObject', 'Camera Object')
self.inputs[-1].default_value = 'Camera'

self.inputs.new('NodeSocketFloat', 'Speed Modifier')
self.inputs[-1].default_value = 1.0
self.inputs.new('NodeSocketBool', 'Additional Modifier (e.g. sniper)')
self.inputs.new('NodeSocketFloat', 'Modifier')
self.inputs[-1].default_value = 0.25
self.inputs.new('NodeSocketBool', 'Invert Horizontal')
self.inputs.new('NodeSocketBool', 'Invert Vertical')

self.inputs.new('NodeSocketFloat', 'Horizontal Axis Movement')
self.inputs.new('NodeSocketFloat', 'Horizontal Speed')
self.inputs[-1].default_value = 1.0
self.inputs.new('NodeSocketBool', 'Restrict Horizontal')
self.inputs.new('NodeSocketFloat', 'hMin (Radians)')
self.inputs.new('NodeSocketFloat', 'hMax (Radians)')

self.inputs.new('NodeSocketFloat', 'Vertical Axis Movement')
self.inputs.new('NodeSocketFloat', 'Vertical Speed')
self.inputs[-1].default_value = 1.0
self.inputs.new('NodeSocketBool', 'Restrict Vertical')
self.inputs.new('NodeSocketFloat', 'vMin (Radians)')
self.inputs.new('NodeSocketFloat', 'vMax (Radians)')
self.add_output('ArmNodeSocketAction', 'Out')

self.add_input('ArmNodeSocketAction', 'Activate')

self.add_input('ArmNodeSocketObject', 'Player Object', default_value='Player')

self.add_input('ArmNodeSocketObject', 'Camera Object', default_value='Camera')

self.add_input('NodeSocketFloat', 'Speed Modifier', default_value=1.0)
self.add_input('NodeSocketBool', 'Additional Modifier (e.g. sniper)')
self.add_input('NodeSocketFloat', 'Modifier', default_value=0.25)
self.add_input('NodeSocketBool', 'Invert Horizontal')
self.add_input('NodeSocketBool', 'Invert Vertical')

self.add_input('NodeSocketFloat', 'Horizontal Axis Movement')
self.add_input('NodeSocketFloat', 'Horizontal Speed', default_value=1.0)
self.add_input('NodeSocketBool', 'Restrict Horizontal')
self.add_input('NodeSocketFloat', 'hMin (Radians)')
self.add_input('NodeSocketFloat', 'hMax (Radians)')

self.add_input('NodeSocketFloat', 'Vertical Axis Movement')
self.add_input('NodeSocketFloat', 'Vertical Speed', default_value=1.0)
self.add_input('NodeSocketBool', 'Restrict Vertical')
self.add_input('NodeSocketFloat', 'vMin (Radians)')
self.add_input('NodeSocketFloat', 'vMax (Radians)')


add_node(CameraController, category='Action')
16 changes: 8 additions & 8 deletions logicnode_definitions/action_look.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ class LookNode(ArmLogicTreeNode):
bl_icon = 'QUESTION'

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')
self.add_input('ArmNodeSocketAction', 'In')
self.add_input('ArmNodeSocketObject', 'Object')
self.add_input('NodeSocketVector', 'Vector')
self.add_input('NodeSocketBool', 'Look Y')
self.add_input('NodeSocketBool', 'Look Z')
self.add_input('NodeSocketFloat', 'Minimum')
self.add_input('NodeSocketFloat', 'Maximum')
self.add_output('ArmNodeSocketAction', 'Out')

add_node(LookNode, category='Action')
30 changes: 15 additions & 15 deletions logicnode_definitions/action_looking_at.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ class LookingAtNode(ArmLogicTreeNode):
bl_icon = 'QUESTION'

def init(self, context):
self.inputs.new('NodeSocketVector', 'From Position')
self.inputs.new('NodeSocketVector', 'To Position')
self.inputs.new('NodeSocketVector', 'Front Facing')
self.add_input('NodeSocketVector', 'From Position')
self.add_input('NodeSocketVector', 'To Position')
self.add_input('NodeSocketVector', 'Front Facing')
self.inputs[-1].default_value = [1, 0, 0]
self.inputs.new('NodeSocketVector', 'Main Rotation Axis')
self.add_input('NodeSocketVector', 'Main Rotation Axis')
self.inputs[-1].default_value = [0, 0, 1]
self.inputs.new('NodeSocketBool', 'Disable Primary Roatation')
self.inputs.new('NodeSocketBool', 'Disable Secodary Roatation')
self.inputs.new('NodeSocketBool', 'Restrict Primary Rotation')
self.inputs.new('NodeSocketFloat', 'min Primary Rotation')
self.inputs.new('NodeSocketFloat', 'max Primary Rotation')
self.inputs.new('NodeSocketBool', 'Restrict Secondary Rotation')
self.inputs.new('NodeSocketFloat', 'min Secondary Rotation')
self.inputs.new('NodeSocketFloat', 'max Secondary Rotation')
self.outputs.new('NodeSocketVector', 'Rotation (Euler)')
self.outputs.new('NodeSocketVector', 'Rotation (Quat)')
self.outputs.new('NodeSocketBool', 'Is in field of view')
self.add_input('NodeSocketBool', 'Disable Primary Roatation')
self.add_input('NodeSocketBool', 'Disable Secodary Roatation')
self.add_input('NodeSocketBool', 'Restrict Primary Rotation')
self.add_input('NodeSocketFloat', 'min Primary Rotation')
self.add_input('NodeSocketFloat', 'max Primary Rotation')
self.add_input('NodeSocketBool', 'Restrict Secondary Rotation')
self.add_input('NodeSocketFloat', 'min Secondary Rotation')
self.add_input('NodeSocketFloat', 'max Secondary Rotation')
self.add_output('NodeSocketVector', 'Rotation (Euler)')
self.add_output('NodeSocketVector', 'Rotation (Quat)')
self.add_output('NodeSocketBool', 'Is in field of view')

add_node(LookingAtNode, category='Action')
48 changes: 19 additions & 29 deletions logicnode_definitions/action_player_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,44 +10,34 @@ class PlayerController(ArmLogicTreeNode):
bl_icon = 'QUESTION'

def init(self, context):
self.outputs.new('ArmNodeSocketAction', 'Out')
self.add_output('ArmNodeSocketAction', 'Out')

self.inputs.new('ArmNodeSocketAction', 'Activate')
self.add_input('ArmNodeSocketAction', 'Activate')

self.inputs.new('ArmNodeSocketObject', 'Player Object')
self.inputs[-1].default_value = 'Player'
self.add_input('ArmNodeSocketObject', 'Player Object', default_value='Player')

self.inputs.new('NodeSocketFloat', 'Overall Speed Modifier')
self.inputs[-1].default_value = 1.0
self.add_input('NodeSocketFloat', 'Overall Speed Modifier', default_value=1.0)

self.inputs.new('NodeSocketBool', 'Forward')
self.inputs.new('NodeSocketFloat', 'Forward Speed')
self.inputs[-1].default_value = 1.0
self.add_input('NodeSocketBool', 'Forward')
self.add_input('NodeSocketFloat', 'Forward Speed', default_value=1.0)

self.inputs.new('NodeSocketBool', 'Left')
self.inputs.new('NodeSocketFloat', 'Left Speed')
self.inputs[-1].default_value = 1.0
self.add_input('NodeSocketBool', 'Left')
self.add_input('NodeSocketFloat', 'Left Speed', default_value=1.0)

self.inputs.new('NodeSocketBool', 'Right')
self.inputs.new('NodeSocketFloat', 'Right Speed')
self.inputs[-1].default_value = 1.0
self.add_input('NodeSocketBool', 'Right')
self.add_input('NodeSocketFloat', 'Right Speed', default_value=1.0)

self.inputs.new('NodeSocketBool', 'Reverse')
self.inputs.new('NodeSocketFloat', 'Reverse Speed')
self.inputs[-1].default_value = 1.0
self.add_input('NodeSocketBool', 'Reverse')
self.add_input('NodeSocketFloat', 'Reverse Speed', default_value=1.0)

self.inputs.new('NodeSocketBool', 'Jump')
self.inputs.new('NodeSocketFloat', 'Jump Height')
self.inputs[-1].default_value = 1.0
self.add_input('NodeSocketBool', 'Jump')
self.add_input('NodeSocketFloat', 'Jump Height', default_value=1.0)

self.inputs.new('NodeSocketBool', 'Run')
self.inputs.new('NodeSocketFloat', 'Run Multiplier')
self.inputs[-1].default_value = 1.5
self.add_input('NodeSocketBool', 'Run')
self.add_input('NodeSocketFloat', 'Run Multiplier', default_value=1.5)

self.inputs.new('NodeSocketBool', 'Crouch')
self.inputs.new('NodeSocketBool', 'Hold for crouch')
self.inputs[-1].default_value = 1
self.inputs.new('NodeSocketFloat', 'Crouch Multiplier')
self.inputs[-1].default_value = 0.5
self.add_input('NodeSocketBool', 'Crouch')
self.add_input('NodeSocketBool', 'Hold for crouch', default_value=1)
self.add_input('NodeSocketFloat', 'Crouch Multiplier', default_value=0.5)

add_node(PlayerController, category='Action')
17 changes: 7 additions & 10 deletions logicnode_definitions/animation_animation_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,13 @@ def __init__(self):
array_nodes[str(id(self))] = self

def init(self, context):
self.outputs.new('ArmNodeSocketAction', 'Out')
self.outputs.new('ArmNodeSocketAction', 'Done')

self.inputs.new('ArmNodeSocketAction', 'In')
self.inputs.new('ArmNodeSocketObject', 'Animated Object')
self.inputs[-1].default_value = 'Animated Object'
self.inputs.new('ArmNodeSocketAnimAction', 'Idle')
self.inputs[-1].default_value = 'Idle'
self.inputs.new('NodeSocketFloat', 'Blend Time')
self.inputs[-1].default_value = 0.2
self.add_output('ArmNodeSocketAction', 'Out')
self.add_output('ArmNodeSocketAction', 'Done')

self.add_input('ArmNodeSocketAction', 'In')
self.add_input('ArmNodeSocketObject', 'Animated Object', default_value='Animated Object')
self.add_input('ArmNodeSocketAnimAction', 'Idle', default_value='Idle')
self.add_input('NodeSocketFloat', 'Blend Time', default_value=0.2)


def draw_buttons(self, context, layout):
Expand Down
8 changes: 4 additions & 4 deletions logicnode_definitions/event_call_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ def __init__(self):
array_nodes[str(id(self))] = self

def init(self, context):
self.outputs.new('ArmNodeSocketAction', 'Out')
self.inputs.new('ArmNodeSocketAction', 'In')
self.inputs.new('NodeSocketString', 'Function')
self.inputs.new('NodeSocketInt', 'ID')
self.add_output('ArmNodeSocketAction', 'Out')
self.add_input('ArmNodeSocketAction', 'In')
self.add_input('NodeSocketString', 'Function')
self.add_input('NodeSocketInt', 'ID')

def draw_buttons(self, context, layout):
row = layout.row(align=True)
Expand Down
6 changes: 3 additions & 3 deletions logicnode_definitions/event_end_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ def __init__(self):
array_nodes[str(id(self))] = self

def init(self, context):
self.outputs.new('ArmNodeSocketAction', 'Out')
self.inputs.new('ArmNodeSocketAction', 'In')
self.inputs.new('NodeSocketString', 'Function')
self.add_output('ArmNodeSocketAction', 'Out')
self.add_input('ArmNodeSocketAction', 'In')
self.add_input('NodeSocketString', 'Function')

def draw_buttons(self, context, layout):
row = layout.row(align=True)
Expand Down
4 changes: 2 additions & 2 deletions logicnode_definitions/event_return_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ def __init__(self):
array_nodes[str(id(self))] = self

def init(self, context):
self.outputs.new('ArmNodeSocketAction', 'Out')
self.inputs.new('NodeSocketInt', 'ID')
self.add_output('ArmNodeSocketAction', 'Out')
self.add_input('NodeSocketInt', 'ID')

def draw_buttons(self, context, layout):
layout.prop(self, 'property0')
Expand Down
2 changes: 1 addition & 1 deletion logicnode_definitions/event_start_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def __init__(self):
array_nodes[str(id(self))] = self

def init(self, context):
self.outputs.new('ArmNodeSocketAction', 'Out')
self.add_output('ArmNodeSocketAction', 'Out')

def draw_buttons(self, context, layout):
layout.prop(self, 'property0')
Expand Down
12 changes: 6 additions & 6 deletions logicnode_definitions/logic_array_loop_indice.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ class ArrayLoopIndiceNode(ArmLogicTreeNode):
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')
self.add_input('ArmNodeSocketAction', 'In')
self.add_input('NodeSocketShader', 'Array')
self.add_output('ArmNodeSocketAction', 'Loop')
self.add_output('NodeSocketInt', 'Value')
self.add_output('ArmNodeSocketAction', 'Done')
self.add_output('NodeSocketInt', 'Indice')

add_node(ArrayLoopIndiceNode, category='Logic')
8 changes: 4 additions & 4 deletions logicnode_definitions/logic_bool_operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ def __init__(self):
array_nodes[str(id(self))] = self

def init(self, context):
self.inputs.new('NodeSocketBool', 'Invert Output')
self.inputs.new('NodeSocketBool', 'Input 1')
self.inputs.new('NodeSocketBool', 'Input 2')
self.outputs.new('NodeSocketBool', 'Output')
self.add_input('NodeSocketBool', 'Invert Output')
self.add_input('NodeSocketBool', 'Input 1')
self.add_input('NodeSocketBool', 'Input 2')
self.add_output('NodeSocketBool', 'Output')

def draw_buttons(self, context, layout):
layout.prop(self, 'property0')
Expand Down
6 changes: 3 additions & 3 deletions logicnode_definitions/logic_number_compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ class CompareNumberNode(ArmLogicTreeNode):
property1: FloatProperty(name='Tolerance', description='Almost Equal threshold', default=0.0001)

def init(self, context):
self.inputs.new('NodeSocketInt', 'A')
self.inputs.new('NodeSocketInt', 'B')
self.outputs.new('NodeSocketBool', 'Result')
self.add_input('NodeSocketInt', 'A')
self.add_input('NodeSocketInt', 'B')
self.add_output('NodeSocketBool', 'Result')

def draw_buttons(self, context, layout):
layout.prop(self, 'property0')
Expand Down
24 changes: 12 additions & 12 deletions logicnode_definitions/logic_timer.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ class TimerNode(ArmLogicTreeNode):
bl_icon = 'QUESTION'

def init(self, context):
self.outputs.new('ArmNodeSocketAction', 'Out')
self.outputs.new('ArmNodeSocketAction', 'Done')
self.outputs.new('NodeSocketBool', 'Running')
self.outputs.new('NodeSocketBool', 'Paused')
self.outputs.new('NodeSocketFloat', 'Seconds left')
self.outputs.new('NodeSocketFloat', 'Progress (in %)')
self.outputs.new('NodeSocketInt', 'Repetitions done')
self.add_output('ArmNodeSocketAction', 'Out')
self.add_output('ArmNodeSocketAction', 'Done')
self.add_output('NodeSocketBool', 'Running')
self.add_output('NodeSocketBool', 'Paused')
self.add_output('NodeSocketFloat', 'Seconds left')
self.add_output('NodeSocketFloat', 'Progress (in %)')
self.add_output('NodeSocketInt', 'Repetitions done')

self.inputs.new('ArmNodeSocketAction', 'Start')
self.inputs.new('NodeSocketBool', 'Pause')
self.inputs.new('NodeSocketBool', 'Stop')
self.add_input('ArmNodeSocketAction', 'Start')
self.add_input('NodeSocketBool', 'Pause')
self.add_input('NodeSocketBool', 'Stop')

self.inputs.new('NodeSocketFloat', 'Seconds')
self.inputs.new('NodeSocketInt', 'Repetitions (0 for oneshot, negative for unlimited)')
self.add_input('NodeSocketFloat', 'Seconds')
self.add_input('NodeSocketInt', 'Repetitions (0 for oneshot, negative for unlimited)')

add_node(TimerNode, category='Logic')
6 changes: 3 additions & 3 deletions logicnode_definitions/physics_get_contact_coords.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ class GetContactCoordsNode(ArmLogicTreeNode):
bl_icon = 'QUESTION'

def init(self, context):
self.inputs.new('ArmNodeSocketObject', 'Object')
self.outputs.new('ArmNodeSocketArray', 'Array')
self.outputs.new('ArmNodeSocketArray', 'Coords')
self.add_input('ArmNodeSocketObject', 'Object')
self.add_output('ArmNodeSocketArray', 'Array')
self.add_output('ArmNodeSocketArray', 'Coords')

add_node(GetContactCoordsNode, category='Physics')
12 changes: 6 additions & 6 deletions logicnode_definitions/value_lerp_vectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ class LerpVectorsNode(ArmLogicTreeNode):
bl_icon = 'QUESTION'

def init(self, context):
self.inputs.new('ArmNodeSocketAction', 'In')
self.inputs.new('NodeSocketVector', 'Starting Vector')
self.inputs.new('NodeSocketVector', 'End Vector')
self.inputs.new('NodeSocketFloat', 'Time For Change')
self.inputs.new('NodeSocketBool', 'Stop Interpolation')
self.outputs.new('NodeSocketVector', 'Vector')
self.add_input('ArmNodeSocketAction', 'In')
self.add_input('NodeSocketVector', 'Starting Vector')
self.add_input('NodeSocketVector', 'End Vector')
self.add_input('NodeSocketFloat', 'Time For Change')
self.add_input('NodeSocketBool', 'Stop Interpolation')
self.add_output('NodeSocketVector', 'Vector')

add_node(LerpVectorsNode, category='Value')
10 changes: 5 additions & 5 deletions logicnode_definitions/value_quat_to_euler.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ class QuatToEulerNode(ArmLogicTreeNode):
bl_icon = 'QUESTION'

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')
self.add_input('NodeSocketFloat', 'X')
self.add_input('NodeSocketFloat', 'Y')
self.add_input('NodeSocketFloat', 'Z')
self.add_input('NodeSocketFloat', 'W')
self.add_output('NodeSocketVector', 'Euler')


add_node(QuatToEulerNode, category='Value')
Loading

0 comments on commit dbb573b

Please sign in to comment.