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

Commit

Permalink
Merge pull request #33 from MoritzBrueckner/master
Browse files Browse the repository at this point in the history
Fix logic pack registering + general update
  • Loading branch information
luboslenco authored Oct 11, 2020
2 parents 6c59c0d + dbb573b commit 54d5a47
Show file tree
Hide file tree
Showing 21 changed files with 216 additions and 242 deletions.
15 changes: 4 additions & 11 deletions blender.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
import bpy
from bpy.props import *
from bpy.types import Node, NodeSocket
from arm.logicnode.arm_nodes import *
import arm.nodes_logic
# Register all nodes
from logicnode_definitions import *


def register():
# Add custom nodes
# TODO: separate into single .py file per logic node, similar to the main Armory repository
# DONE!

# Register newly added nodes
arm.nodes_logic.register_nodes()
# Optionally do some other stuff for registering
pass
8 changes: 4 additions & 4 deletions logicnode_definitions/Template.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
from bpy.types import Node, NodeSocket
from arm.logicnode.arm_nodes import *

# class <NodeName>(Node, ArmLogicTreeNode):
# '''<Short Desciption (optional)>'''
# class <NodeName>(ArmLogicTreeNode):
# """<Short Desciption (optional)>"""
# bl_idname = 'LN<NodeName>'
# bl_label = '<Name of the Node inside Blender>'
# 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>')
60 changes: 27 additions & 33 deletions logicnode_definitions/action_camera_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,38 @@
from arm.logicnode.arm_nodes import *


class CameraController(Node, ArmLogicTreeNode):
'''CameraController'''
class CameraController(ArmLogicTreeNode):
"""CameraController"""
bl_idname = 'LNCameraController'
bl_label = 'Camera Controller'
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')
22 changes: 11 additions & 11 deletions logicnode_definitions/action_look.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
from bpy.types import Node, NodeSocket
from arm.logicnode.arm_nodes import *

class LookNode(Node, ArmLogicTreeNode):
'''Look Node'''
class LookNode(ArmLogicTreeNode):
"""Look Node"""
bl_idname = 'LNLookNode'
bl_label = 'Look'
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')
36 changes: 18 additions & 18 deletions logicnode_definitions/action_looking_at.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,29 @@
from bpy.types import Node, NodeSocket
from arm.logicnode.arm_nodes import *

class LookingAtNode(Node, ArmLogicTreeNode):
'''Looking at Node'''
class LookingAtNode(ArmLogicTreeNode):
"""Looking at Node"""
bl_idname = 'LNLookingAtNode'
bl_label = 'Looking At'
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')
52 changes: 21 additions & 31 deletions logicnode_definitions/action_player_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,51 +3,41 @@
from bpy.types import Node, NodeSocket
from arm.logicnode.arm_nodes import *

class PlayerController(Node, ArmLogicTreeNode):
'''PlayerController'''
class PlayerController(ArmLogicTreeNode):
"""PlayerController"""
bl_idname = 'LNPlayerController'
bl_label = 'Player Controller'
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')
27 changes: 12 additions & 15 deletions logicnode_definitions/animation_animation_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from bpy.types import Node, NodeSocket
from arm.logicnode.arm_nodes import *

class AnimationControllerNode(Node, ArmLogicTreeNode):
'''AnimationController node'''
class AnimationControllerNode(ArmLogicTreeNode):
"""AnimationController node"""
bl_idname = 'LNAnimationControllerNode'
bl_label = 'AnimationController'
bl_icon = 'QUESTION'
Expand All @@ -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 All @@ -32,15 +29,15 @@ def draw_buttons(self, context, layout):
op = row1.operator('arm.node_add_input', text='New Animation Controller', icon='PLUS', emboss=True)
op.node_index = str(id(self))
op.socket_type = 'NodeSocketBool'

op2 = row1.operator('arm.node_add_input', text='New Animation', icon='PLUS', emboss=True)
op2.node_index = str(id(self))
op2.socket_type = 'ArmNodeSocketAnimAction'

op3 = row2.operator('arm.node_add_input', text='New blend time', icon='PLUS', emboss=True)
op3.node_index = str(id(self))
op3.socket_type = 'NodeSocketFloat'

op4 = row2.operator('arm.node_remove_input', text='', icon='X', emboss=True)
op4.node_index = str(id(self))

Expand Down
14 changes: 7 additions & 7 deletions logicnode_definitions/event_call_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from bpy.types import Node, NodeSocket
from arm.logicnode.arm_nodes import *

class CallFunctionNode(Node, ArmLogicTreeNode):
'''Call Function Node'''
class CallFunctionNode(ArmLogicTreeNode):
"""Call Function Node"""
bl_idname = 'LNCallFunctionNode'
bl_label = 'Call Function'
bl_icon = 'QUESTION'
Expand All @@ -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 All @@ -27,5 +27,5 @@ def draw_buttons(self, context, layout):
op.socket_type = 'NodeSocketShader'
op2 = row.operator('arm.node_remove_input', text='', icon='X', emboss=True)
op2.node_index = str(id(self))

add_node(CallFunctionNode, category='Event')
12 changes: 6 additions & 6 deletions logicnode_definitions/event_end_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from bpy.types import Node, NodeSocket
from arm.logicnode.arm_nodes import *

class EndFunctionNode(Node, ArmLogicTreeNode):
'''End Function Node'''
class EndFunctionNode(ArmLogicTreeNode):
"""End Function Node"""
bl_idname = 'LNEndFunctionNode'
bl_label = 'End Function'
bl_icon = 'QUESTION'
Expand All @@ -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 All @@ -26,5 +26,5 @@ def draw_buttons(self, context, layout):
op.socket_type = 'NodeSocketShader'
op2 = row.operator('arm.node_remove_input', text='', icon='X', emboss=True)
op2.node_index = str(id(self))

add_node(EndFunctionNode, category='Event')
Loading

0 comments on commit 54d5a47

Please sign in to comment.