I want to check if a lemur or other gui node is between the mouse pointer and landscape then do something.
using ray cast? and the gui node?
It’s not working:
// Convert screen click to 3d position
Vector2f click2d = app.getInputManager().getCursorPosition();
Vector3f click3d = app.getCamera().getWorldCoordinates(new Vector2f(click2d.x, click2d.y), 0f).clone();
Vector3f dir = app.getCamera().getWorldCoordinates(new Vector2f(click2d.x, click2d.y), 1f).subtractLocal(click3d).normalizeLocal();
// Aim the ray from the clicked spot forwards.
Ray ray = new Ray(click3d, dir);
// Reset results list.
CollisionResults results = new CollisionResults();
app.getGuiNode().collideWith(ray, results);
if (results.size() > 0) {
Geometry guiSelectedGeo = results.getClosestCollision().getGeometry();
if (guiSelectedGeo != null) {
System.out.println("gui node name: " + tools.get_parent_node(guiSelectedGeo).getName());
app.getRootNode().collideWith(ray, results);
try {
globalVars.click3d = results.getClosestCollision().getContactPoint();
System.out.println("" + tools.get_parent_node(results.getClosestCollision().getGeometry()).getName());
run_for_multislected(globalVars.click3d.x, globalVars.click3d.z);
} catch (Exception e) {
globalVars.click3d = null;
}
}
}