-
Notifications
You must be signed in to change notification settings - Fork 324
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3109 from t3du/getDistanceWorld
Get distance world node
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
armory/Sources/armory/logicnode/DistanceScreenToWorldSpaceNode.hx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package armory.logicnode; | ||
|
||
import iron.math.Vec4; | ||
import iron.math.RayCaster; | ||
|
||
class DistanceScreenToWorldSpaceNode extends LogicNode { | ||
|
||
public function new(tree: LogicTree) { | ||
super(tree); | ||
} | ||
|
||
override function get(from: Int): Dynamic { | ||
var vInput: Vec4 = new Vec4(); | ||
vInput.x = inputs[0].get(); | ||
vInput.y = inputs[1].get(); | ||
|
||
var cam = iron.Scene.active.camera; | ||
if (cam == null) return null; | ||
|
||
return (inputs[2].get().y) - cam.transform.world.getLoc().y / RayCaster.getRay(vInput.x, vInput.y, cam).direction.y; | ||
//return RayCaster.getRay(vInput.x, vInput.y, cam).distanceToPoint(inputs[2].get()); | ||
|
||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
armory/blender/arm/logicnode/math/LN_distance_screen_to_world_space.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from arm.logicnode.arm_nodes import * | ||
|
||
|
||
class DistanceScreenToWorldSpaceNode(ArmLogicTreeNode): | ||
"""Gets the distance from given screen coordinates to World coordinates. | ||
@input Screen X: screen x position. | ||
@input Screen Y: screen y position. | ||
@input At: World coordinates is a vector position. | ||
@output Distance At: distance result. | ||
""" | ||
|
||
bl_idname = 'LNDistanceScreenToWorldSpaceNode' | ||
bl_label = 'Distance Screen to World Space' | ||
arm_section = 'matrix' | ||
arm_version = 1 | ||
|
||
def arm_init(self, context): | ||
self.add_input('ArmIntSocket', 'Screen X') | ||
self.add_input('ArmIntSocket', 'Screen Y') | ||
self.add_input('ArmVectorSocket', 'At') | ||
|
||
self.add_output('ArmFloatSocket', 'Distance at') |