Relative remapping of locations #7
30
nodes.py
30
nodes.py
@ -634,6 +634,34 @@ class SetControlNode(AbstractRigNodesNode):
|
|||||||
control_obj.scale = control_scale
|
control_obj.scale = control_scale
|
||||||
|
|
||||||
|
|
||||||
|
class RemapPositionNode(AbstractRigNodesEventNode):
|
||||||
|
"""Relative remapping of a location"""
|
||||||
|
|
||||||
|
bl_idname = "RemapPositionNode"
|
||||||
|
bl_label = "Remap Position"
|
||||||
|
bl_icon = "EMPTY_ARROWS"
|
||||||
|
|
||||||
|
def init(self, context):
|
||||||
|
self.inputs.new("NodeSocketVector", "From Origin")
|
||||||
|
self.inputs.new("NodeSocketVector", "From Destination")
|
||||||
|
self.inputs.new("NodeSocketVector", "To Origin")
|
||||||
|
self.inputs.new("NodeSocketVector", "To Destination")
|
||||||
|
self.outputs.new("NodeSocketVector", "Result")
|
||||||
|
|
||||||
|
def execute(self, depsgraph: bpy.types.Depsgraph) -> None:
|
||||||
|
from_origin = self._get_input_value("From Origin", Vector)
|
||||||
|
from_dest = self._get_input_value("From Destination", Vector)
|
||||||
|
to_origin = self._get_input_value("To Origin", Vector)
|
||||||
|
to_dest = self._get_input_value("To Destination", Vector)
|
||||||
|
|
||||||
|
from_dist = (from_dest - from_origin).length
|
||||||
|
to_dist = (to_dest - to_origin).length
|
||||||
|
|
||||||
|
fact = to_dist / from_dist if to_dist != 0 else 0
|
||||||
|
res = (from_dest - from_origin) * fact + to_origin
|
||||||
|
self.outputs["Result"].default_value = res
|
||||||
|
|
||||||
|
|
||||||
class ToVector(AbstractRigNodesNode):
|
class ToVector(AbstractRigNodesNode):
|
||||||
bl_idname = "ToVector"
|
bl_idname = "ToVector"
|
||||||
bl_label = "To Vector"
|
bl_label = "To Vector"
|
||||||
@ -1343,6 +1371,7 @@ node_categories = [
|
|||||||
nodeitems_utils.NodeItem("ClampNode"),
|
nodeitems_utils.NodeItem("ClampNode"),
|
||||||
nodeitems_utils.NodeItem("ToEulerNode"),
|
nodeitems_utils.NodeItem("ToEulerNode"),
|
||||||
nodeitems_utils.NodeItem("FromEulerNode"),
|
nodeitems_utils.NodeItem("FromEulerNode"),
|
||||||
|
nodeitems_utils.NodeItem("RemapPositionNode"),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
RigNodesNodeCategory(
|
RigNodesNodeCategory(
|
||||||
@ -1371,6 +1400,7 @@ classes = (
|
|||||||
TwoBoneIKNode,
|
TwoBoneIKNode,
|
||||||
SetCursorNode,
|
SetCursorNode,
|
||||||
SequenceNode,
|
SequenceNode,
|
||||||
|
RemapPositionNode,
|
||||||
# Math Nodes
|
# Math Nodes
|
||||||
RotateTowards,
|
RotateTowards,
|
||||||
AngleFromVectors,
|
AngleFromVectors,
|
||||||
|
BIN
rignodes-remap_location.blend
Normal file
BIN
rignodes-remap_location.blend
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user