-
Notifications
You must be signed in to change notification settings - Fork 324
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3110 from t3du/RotationMatrixNode
Rotation matrix node
- Loading branch information
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
armory/Sources/armory/logicnode/RotationFromTransformNode.hx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
14
armory/blender/arm/logicnode/transform/LN_transform_to_rotation.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |