armory/Sources/armory/logicnode/GetRotationNode.hx

35 lines
619 B
Haxe
Raw Normal View History

2017-04-14 20:38:50 +02:00
package armory.logicnode;
2017-11-20 15:16:52 +01:00
import iron.object.Object;
import iron.math.Quat;
import iron.math.Vec4;
2017-04-14 20:38:50 +02:00
2017-05-13 11:04:39 +02:00
class GetRotationNode extends LogicNode {
2019-12-19 23:54:08 +01:00
public var property0: String;
2019-12-19 23:54:08 +01:00
public function new(tree: LogicTree) {
2017-04-14 20:38:50 +02:00
super(tree);
}
2019-12-19 23:54:08 +01:00
override function get(from: Int): Dynamic {
var object: Object = inputs[0].get();
2020-10-01 21:05:47 +02:00
2019-12-19 23:54:08 +01:00
if (object == null) {
2019-09-27 21:51:30 +02:00
return null;
2019-12-19 23:54:08 +01:00
}
2020-10-01 21:05:47 +02:00
switch(property0){
case "Local":
return object.transform.rot;
case "Global":{
var useless1 = new Vec4();
var ret = new Quat();
object.transform.world.decompose(useless1, ret, useless1);
return ret;
}}
return null;
2017-04-14 20:38:50 +02:00
}
}