2017-04-08 20:05:35 +02:00
|
|
|
package armory.logicnode;
|
|
|
|
|
2017-11-20 15:16:52 +01:00
|
|
|
import iron.math.Vec4;
|
2020-10-13 19:50:30 +02:00
|
|
|
import iron.math.RayCaster;
|
2017-04-08 20:05:35 +02:00
|
|
|
|
|
|
|
class ScreenToWorldSpaceNode extends LogicNode {
|
|
|
|
|
2020-10-13 19:50:30 +02:00
|
|
|
public var property0: Bool; // Separator Out
|
2017-04-08 20:05:35 +02:00
|
|
|
|
2019-12-19 23:54:08 +01:00
|
|
|
public function new(tree: LogicTree) {
|
2017-04-08 20:05:35 +02:00
|
|
|
super(tree);
|
|
|
|
}
|
|
|
|
|
2019-12-19 23:54:08 +01:00
|
|
|
override function get(from: Int): Dynamic {
|
2020-10-13 19:50:30 +02:00
|
|
|
var vInput: Vec4 = new Vec4();
|
|
|
|
vInput.x = inputs[0].get();
|
|
|
|
vInput.y = inputs[1].get();
|
2018-06-14 14:52:05 +02:00
|
|
|
|
2017-11-20 15:16:52 +01:00
|
|
|
var cam = iron.Scene.active.camera;
|
2020-10-13 19:50:30 +02:00
|
|
|
if (cam == null) return null;
|
2017-04-08 20:05:35 +02:00
|
|
|
|
2020-10-13 19:50:30 +02:00
|
|
|
// Separator Out
|
|
|
|
if (property0) {
|
|
|
|
switch (from) {
|
|
|
|
// World
|
|
|
|
case 0: {
|
|
|
|
return RayCaster.getRay(vInput.x, vInput.y, cam).origin;
|
|
|
|
}
|
|
|
|
// World X
|
|
|
|
case 1: {
|
|
|
|
return RayCaster.getRay(vInput.x, vInput.y, cam).origin.x;
|
|
|
|
}
|
|
|
|
// World Y
|
|
|
|
case 2: {
|
|
|
|
return RayCaster.getRay(vInput.x, vInput.y, cam).origin.y;
|
|
|
|
}
|
|
|
|
// World Z
|
|
|
|
case 3: {
|
|
|
|
return RayCaster.getRay(vInput.x, vInput.y, cam).origin.z;
|
|
|
|
}
|
|
|
|
// Direction
|
|
|
|
case 4: {
|
|
|
|
return RayCaster.getRay(vInput.x, vInput.y, cam).direction.normalize();
|
|
|
|
}
|
|
|
|
// Direction X
|
|
|
|
case 5: {
|
|
|
|
return RayCaster.getRay(vInput.x, vInput.y, cam).direction.normalize().x;
|
|
|
|
}
|
|
|
|
// Direction Y
|
|
|
|
case 6: {
|
|
|
|
return RayCaster.getRay(vInput.x, vInput.y, cam).direction.normalize().y;
|
|
|
|
}
|
|
|
|
// Direction Z
|
|
|
|
case 7: {
|
|
|
|
return RayCaster.getRay(vInput.x, vInput.y, cam).direction.normalize().z;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch (from) {
|
|
|
|
// World
|
|
|
|
case 0: {
|
|
|
|
return RayCaster.getRay(vInput.x, vInput.y, cam).origin;
|
|
|
|
}
|
|
|
|
// Direction
|
|
|
|
case 1: {
|
|
|
|
return RayCaster.getRay(vInput.x, vInput.y, cam).direction.normalize();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
2017-04-08 20:05:35 +02:00
|
|
|
}
|
|
|
|
}
|