armory/Sources/armory/logicnode/VectorNode.hx

33 lines
739 B
Haxe
Raw Normal View History

2016-08-22 21:56:28 +02:00
package armory.logicnode;
2015-11-26 15:36:17 +01:00
2017-11-20 15:16:52 +01:00
import iron.math.Vec4;
2017-03-06 02:29:03 +01:00
2017-04-08 20:05:35 +02:00
class VectorNode extends LogicNode {
2015-11-26 15:36:17 +01:00
2017-03-06 02:29:03 +01:00
var value = new Vec4();
2019-12-19 23:54:08 +01:00
public function new(tree: LogicTree, x: Null<Float> = null, y: Null<Float> = null, z: Null<Float> = null) {
2017-04-04 23:11:31 +02:00
super(tree);
2015-11-26 15:36:17 +01:00
2017-03-06 02:29:03 +01:00
if (x != null) {
LogicNode.addLink(new FloatNode(tree, x), this, 0, 0);
LogicNode.addLink(new FloatNode(tree, y), this, 0, 1);
LogicNode.addLink(new FloatNode(tree, z), this, 0, 2);
2017-03-06 02:29:03 +01:00
}
2015-11-26 15:36:17 +01:00
}
2019-12-19 23:54:08 +01:00
override function get(from: Int): Dynamic {
2020-04-12 17:32:52 +02:00
value = new Vec4();
2017-03-06 02:29:03 +01:00
value.x = inputs[0].get();
value.y = inputs[1].get();
value.z = inputs[2].get();
return 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) {
2017-04-14 20:38:50 +02:00
inputs[0].set(value.x);
inputs[1].set(value.y);
inputs[2].set(value.z);
2017-04-03 22:29:46 +02:00
}
2015-11-26 15:36:17 +01:00
}