From 03baa49ecdd6b5160303dda27344e01a77fa5cfd Mon Sep 17 00:00:00 2001 From: QuantumCoderQC Date: Thu, 20 May 2021 18:08:11 +0200 Subject: [PATCH] Implement node to get bone transform in world space --- .../armory/logicnode/GetBoneTransformNode.hx | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Sources/armory/logicnode/GetBoneTransformNode.hx diff --git a/Sources/armory/logicnode/GetBoneTransformNode.hx b/Sources/armory/logicnode/GetBoneTransformNode.hx new file mode 100644 index 00000000..098fd519 --- /dev/null +++ b/Sources/armory/logicnode/GetBoneTransformNode.hx @@ -0,0 +1,30 @@ +package armory.logicnode; + +import iron.object.Object; +import iron.object.BoneAnimation; +import iron.math.Mat4; + +class GetBoneTransformNode extends LogicNode { + + public function new(tree: LogicTree) { + super(tree); + } + + override function get(from: Int): Mat4 { + #if arm_skin + + var object: Object = inputs[0].get(); + var boneName: String = inputs[1].get(); + + if (object == null) return null; + var anim = object.animation != null ? cast(object.animation, BoneAnimation) : null; + if (anim == null) anim = object.getParentArmature(object.name); + + // Get bone in armature + var bone = anim.getBone(boneName); + + return anim.getAbsWorldMat(bone); + + #end + } +}