Created-Armory-Nodes/Sources/armory/logicnode/EnhancedTransformNode.hx

44 lines
1.1 KiB
Haxe

package armory.logicnode;
import iron.object.Object;
import iron.math.Vec4;
import armory.trait.physics.RigidBody;
class EnhancedTransformNode extends LogicNode {
public function new(tree:LogicTree) {
super(tree);
}
override function run() {
var object:Object = inputs[1].get();
var loc:Vec4 = inputs[2].get();
var rot:Vec4 = inputs[3].get();
var scale:Vec4 = inputs[4].get();
if (loc == null || rot == null || scale == null) return;
// Location transform
object.transform.loc.x = loc.x;
object.transform.loc.y = loc.y;
object.transform.loc.z = loc.z;
// Rotation transform
object.transform.rot.fromEuler(rot.x, rot.y, rot.z);
object.transform.buildMatrix();
// Scale transform
object.transform.scale.x = scale.x;
object.transform.scale.y = scale.y;
object.transform.scale.z = scale.z;
#if arm_physics
var rigidBody = object.getTrait(RigidBody);
if (rigidBody != null) rigidBody.syncTransform();
#end
super.run();
}
}