Skip to content

Commit

Permalink
Merge pull request #3110 from t3du/RotationMatrixNode
Browse files Browse the repository at this point in the history
Rotation matrix node
  • Loading branch information
luboslenco authored Dec 24, 2024
2 parents 8765fb8 + 1d78e1a commit 07da452
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
27 changes: 27 additions & 0 deletions armory/Sources/armory/logicnode/RotationFromTransformNode.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package armory.logicnode;

import iron.math.Mat4;
import iron.math.Vec4;

class RotationFromTransformNode extends LogicNode {

public function new(tree: LogicTree) {
super(tree);
}

override function get(from: Int): Dynamic {
var m: Mat4 = inputs[0].get();

if (m == null) return null;

var mr: Mat4 = m.clone().toRotation();

return switch(from){
case 0: new Vec4(mr._00, mr._10, mr._20, mr._30);
case 1: new Vec4(mr._01, mr._11, mr._21, mr._31);
case 2: new Vec4(mr._02, mr._12, mr._22, mr._32);
default: null;
}

}
}
14 changes: 14 additions & 0 deletions armory/blender/arm/logicnode/transform/LN_transform_to_rotation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from arm.logicnode.arm_nodes import *

class RotationFromTransformNode(ArmLogicTreeNode):
"""Returns rotation matrix from the given transform."""
bl_idname = 'LNRotationFromTransformNode'
bl_label = 'Transform to Rotation Matrix'
arm_version = 1

def arm_init(self, context):
self.add_input('ArmDynamicSocket', 'Transform')

self.add_output('ArmVectorSocket', 'Vector x')
self.add_output('ArmVectorSocket', 'Vector y')
self.add_output('ArmVectorSocket', 'Vector z')

0 comments on commit 07da452

Please sign in to comment.