2017-04-08 20:05:35 +02:00
|
|
|
from arm.logicnode.arm_nodes import *
|
|
|
|
|
2020-09-08 21:16:20 +02:00
|
|
|
class ScreenToWorldSpaceNode(ArmLogicTreeNode):
|
2020-10-05 19:55:56 +02:00
|
|
|
"""Transforms the given screen coordinates into world coordinates."""
|
2017-04-08 20:05:35 +02:00
|
|
|
bl_idname = 'LNScreenToWorldSpaceNode'
|
2020-11-17 16:01:15 +01:00
|
|
|
bl_label = 'Screen to World Space'
|
2020-10-13 19:50:30 +02:00
|
|
|
node_index: StringProperty(name='Node Index', default='')
|
2020-10-27 19:44:37 +01:00
|
|
|
arm_section = 'matrix'
|
2020-09-13 11:27:58 +02:00
|
|
|
arm_version = 1
|
2020-10-13 19:50:30 +02:00
|
|
|
min_outputs = 2
|
|
|
|
max_outputs = 8
|
|
|
|
|
|
|
|
# Separator
|
|
|
|
@property
|
|
|
|
def property0(self):
|
|
|
|
return True if self.property0_ else False
|
2020-10-27 19:44:37 +01:00
|
|
|
|
2020-10-13 19:50:30 +02:00
|
|
|
property0_: BoolProperty(name='Separator Out', default=False)
|
2017-04-08 20:05:35 +02:00
|
|
|
|
|
|
|
def init(self, context):
|
2020-09-13 11:27:58 +02:00
|
|
|
super(ScreenToWorldSpaceNode, self).init(context)
|
2020-10-13 19:50:30 +02:00
|
|
|
self.add_input('NodeSocketInt', 'Screen X')
|
|
|
|
self.add_input('NodeSocketInt', 'Screen Y')
|
2020-11-17 16:01:15 +01:00
|
|
|
|
2020-09-20 20:10:01 +02:00
|
|
|
self.add_output('NodeSocketVector', 'World')
|
2020-10-13 19:50:30 +02:00
|
|
|
self.add_output('NodeSocketVector', 'Direction')
|
|
|
|
|
|
|
|
def draw_buttons(self, context, layout):
|
|
|
|
layout.prop(self, 'property0_') # Separator Out
|
|
|
|
if self.property0_:
|
|
|
|
if len(self.outputs) < self.max_outputs:
|
|
|
|
self.outputs.remove(self.outputs.values()[-1]) # Direction vector
|
|
|
|
self.add_output('NodeSocketFloat', 'X') # World X
|
|
|
|
self.add_output('NodeSocketFloat', 'Y') # World Y
|
2020-10-27 19:44:37 +01:00
|
|
|
self.add_output('NodeSocketFloat', 'Z') # World Z
|
2020-10-13 19:50:30 +02:00
|
|
|
self.add_output('NodeSocketVector', 'Direction') # Vector
|
|
|
|
self.add_output('NodeSocketFloat', 'X') # Direction X
|
|
|
|
self.add_output('NodeSocketFloat', 'Y') # Direction Y
|
|
|
|
self.add_output('NodeSocketFloat', 'Z') # Direction Z
|
|
|
|
else:
|
|
|
|
if len(self.outputs) == self.max_outputs:
|
|
|
|
self.outputs.remove(self.outputs.values()[-1]) # Z
|
|
|
|
self.outputs.remove(self.outputs.values()[-1]) # Y
|
|
|
|
self.outputs.remove(self.outputs.values()[-1]) # X
|
|
|
|
self.outputs.remove(self.outputs.values()[-1]) # Direction
|
|
|
|
self.outputs.remove(self.outputs.values()[-1]) # Z
|
|
|
|
self.outputs.remove(self.outputs.values()[-1]) # Y
|
|
|
|
self.outputs.remove(self.outputs.values()[-1]) # X
|
|
|
|
self.add_output('NodeSocketVector', 'Direction')
|