Procházet zdrojové kódy

Add Node: Separate Vector

this works, need to note a TODO for this- in display, it should adapt to Vector and BoolVector
Joseph Brandenburg před 8 měsíci
rodič
revize
b83a7eb88c
2 změnil soubory, kde provedl 51 přidání a 4 odebrání
  1. 35 0
      misc_containers.py
  2. 16 4
      nodes_generic.py

+ 35 - 0
misc_containers.py

@@ -34,6 +34,7 @@ def TellClasses():
              UtilitySwitch,
              UtilityCombineThreeBool,
              UtilityCombineVector,
+             UtilitySeparateVector,
              UtilityCatStrings,
              UtilityGetBoneLength,
              UtilityPointFromBoneMatrix,
@@ -1043,6 +1044,40 @@ class UtilityCombineVector:
           self.evaluate_input("Z"), )
         self.prepared = True
         self.executed = True
+  
+
+  # TODO
+class UtilitySeparateVector:
+    '''A node for separating a vector into three floats'''
+
+    def __init__(self, signature, base_tree):
+        self.base_tree=base_tree
+        self.executed = False
+        self.signature = signature
+        self.inputs = {
+          "Vector" : NodeSocket(is_input = True, name = "Vector", node=self),
+        }
+        self.outputs = {
+          "X"   : NodeSocket(name = "X", node = self),
+          "Y"   : NodeSocket(name = "Y", node = self),
+          "Z"   : NodeSocket(name = "Z", node = self),
+        }
+        self.parameters = {
+          "X"   : None,
+          "Y"   : None,
+          "Z"   : None, }
+        self.node_type = "UTILITY"
+        self.hierarchy_connections, self.connections = [], []
+        self.hierarchy_dependencies, self.dependencies = [], []
+        self.prepared, self.executed = False, False
+
+    def bPrepare(self, bContext = None,):
+        # prepare_parameters(self)
+        self.parameters["X"] = self.evaluate_input("Vector")[0]
+        self.parameters["Y"] = self.evaluate_input("Vector")[1]
+        self.parameters["Z"] = self.evaluate_input("Vector")[2]
+        self.prepared = True
+        self.executed = True
 
 class UtilityCatStrings:
     '''A node representing an armature object'''

+ 16 - 4
nodes_generic.py

@@ -41,6 +41,7 @@ def TellClasses():
              UtilityKeyframe,
              UtilityCombineThreeBoolNode,
              UtilityCombineVectorNode,
+             UtilitySeparateVector,
              UtilityCatStringsNode,
              UtilityGetBoneLength,
              UtilityPointFromBoneMatrix,
@@ -515,9 +516,8 @@ class UtilityCombineThreeBoolNode(Node, MantisNode):
         self.inputs.new("BooleanSocket", "Y")
         self.inputs.new("BooleanSocket", "Z")
         self.outputs.new("BooleanThreeTupleSocket", "Three-Bool")
-        # this node should eventually just be a Combine Boolean Three-Tuple node
-        # and the "Driver" output will need to be figured out some other way
         self.initialized = True
+
 class UtilityCombineVectorNode(Node, MantisNode):
     """Combines three floats into a vector."""
     bl_idname = "UtilityCombineVector"
@@ -530,8 +530,20 @@ class UtilityCombineVectorNode(Node, MantisNode):
         self.inputs.new("FloatSocket", "Y")
         self.inputs.new("FloatSocket", "Z")
         self.outputs.new("VectorSocket", "Vector")
-        # this node should eventually just be a Combine Boolean Three-Tuple node
-        # and the "Driver" output will need to be figured out some other way
+        self.initialized = True
+        
+class UtilitySeparateVector(Node, MantisNode):
+    """Separates a vector into three floats"""
+    bl_idname = "UtilitySeparateVector"
+    bl_label = "Separate Vector"
+    bl_icon = "NODE"
+    initialized : bpy.props.BoolProperty(default = False)
+    
+    def init(self, context):
+        self.inputs.new("VectorSocket", "Vector")
+        self.outputs.new("FloatSocket", "X")
+        self.outputs.new("FloatSocket", "Y")
+        self.outputs.new("FloatSocket", "Z")
         self.initialized = True
         
 class UtilityCatStringsNode(Node, MantisNode):