2016-08-22 21:56:28 +02:00
|
|
|
package armory.logicnode;
|
2015-11-26 15:36:17 +01:00
|
|
|
|
2016-07-10 00:51:39 +02:00
|
|
|
import iron.math.Mat4;
|
|
|
|
import iron.math.Vec4;
|
|
|
|
import iron.math.Quat;
|
2015-11-26 15:36:17 +01:00
|
|
|
|
2017-04-08 20:05:35 +02:00
|
|
|
class TransformNode extends LogicNode {
|
2015-11-26 15:36:17 +01:00
|
|
|
|
2019-12-19 23:54:08 +01:00
|
|
|
var value: Mat4 = Mat4.identity();
|
2021-06-15 23:06:43 +02:00
|
|
|
var q = new Quat();
|
|
|
|
var v1 = new Vec4();
|
|
|
|
var v2 = new Vec4();
|
2015-11-26 15:36:17 +01:00
|
|
|
|
2019-12-19 23:54:08 +01:00
|
|
|
public function new(tree: LogicTree) {
|
2017-04-04 23:11:31 +02:00
|
|
|
super(tree);
|
2015-11-26 15:36:17 +01:00
|
|
|
}
|
|
|
|
|
2019-12-19 23:54:08 +01:00
|
|
|
override function get(from: Int): Dynamic {
|
|
|
|
var loc: Vec4 = inputs[0].get();
|
2021-06-15 23:06:43 +02:00
|
|
|
var rot: Quat = new Quat().setFrom(inputs[1].get());
|
|
|
|
rot.normalize();
|
2019-12-19 23:54:08 +01:00
|
|
|
var scale: Vec4 = inputs[2].get();
|
2021-06-15 23:06:43 +02:00
|
|
|
if (loc == null && rot == null && scale == null) return this.value;
|
2018-06-14 14:52:05 +02:00
|
|
|
if (loc == null || rot == null || scale == null) return null;
|
2021-06-15 23:06:43 +02:00
|
|
|
this.value.compose(loc, rot, scale);
|
|
|
|
return this.value;
|
2015-11-26 15:36:17 +01:00
|
|
|
}
|
2017-04-03 22:29:46 +02:00
|
|
|
|
2019-12-19 23:54:08 +01:00
|
|
|
override function set(value: Dynamic) {
|
2021-06-15 23:06:43 +02:00
|
|
|
if (inputs.length>0){
|
|
|
|
cast(value, Mat4).decompose(v1, q, v2);
|
|
|
|
inputs[0].set(v1);
|
|
|
|
inputs[1].set(q);
|
|
|
|
inputs[2].set(v2);
|
|
|
|
}else this.value = value;
|
2017-04-03 22:29:46 +02:00
|
|
|
}
|
2015-11-26 15:36:17 +01:00
|
|
|
}
|