Merge pull request #1953 from knowledgenude/master
Vector To Object Orientation node
This commit is contained in:
commit
dbb061bafc
29
Sources/armory/logicnode/VectorToObjectOrientation.hx
Normal file
29
Sources/armory/logicnode/VectorToObjectOrientation.hx
Normal file
|
@ -0,0 +1,29 @@
|
|||
package armory.logicnode;
|
||||
|
||||
import iron.object.Object;
|
||||
import iron.math.Vec4;
|
||||
|
||||
class VectorToObjectOrientationNode extends LogicNode {
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
|
||||
var object: Object = inputs[0].get();
|
||||
var vecIn: Vec4 = inputs[1].get();
|
||||
|
||||
if (object == null || vecIn == null) return null;
|
||||
|
||||
var vecOut = new Vec4();
|
||||
|
||||
var right = object.transform.world.right().mult(vecIn.x);
|
||||
var look = object.transform.world.look().mult(vecIn.y);
|
||||
var up = object.transform.world.up().mult(vecIn.z);
|
||||
|
||||
vecOut.add(right).add(look).add(up);
|
||||
|
||||
return vecOut;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
from arm.logicnode.arm_nodes import *
|
||||
|
||||
class VectorToObjectOrientationNode(ArmLogicTreeNode):
|
||||
"""Converts a world oriented vector to a given object oriented vector. Works similarly to 'On Local Axis' checkboxes.
|
||||
|
||||
@seeNode Get World Orientation
|
||||
@seeNode Vector From Transform
|
||||
"""
|
||||
bl_idname = 'LNVectorToObjectOrientationNode'
|
||||
bl_label = 'Vector To Object Orientation'
|
||||
arm_version = 1
|
||||
|
||||
def init(self, context):
|
||||
super(VectorToObjectOrientationNode, self).init(context)
|
||||
self.add_input('ArmNodeSocketObject', 'Object')
|
||||
self.add_input('NodeSocketVector', 'World')
|
||||
self.add_output('NodeSocketVector', 'Local')
|
||||
|
||||
add_node(VectorToObjectOrientationNode, category=PKG_AS_CATEGORY, section='location')
|
Loading…
Reference in a new issue