ray.setOrigin(new Vector3f(exe.getInputManager().getCursorPosition().getX(),exe.getInputManager().getCursorPosition().getY(),0f));
ray.setDirection(
new Vector3f(exe.getInputManager().getCursorPosition().getX(),exe.getInputManager().getCursorPosition().getY(),1.f).normalize());
when i use thiis coordinates in never collides objects
when i use 3d ray cast it works fine ,but in guiNode it never works properly .
I had allready a suggestion to use lemur , but i really need to do it without external code,
soo i just need to know some rule or alse that may help me to get proper coordinates from mouse position to ray cast in guiNode
Ray collision with the GUI node works just fine. Direction will always be the same, though.
Your direction is not a direction vector since a direction vector wouldn’t also have position. new Vector3f(0, 0, -1) is the correct direction vector for the screen. Z goes out of the screen.
You can do it up from z=0 but you will encounter everything backwards.
But JME is “external code”. Do you “need” to do it or just “want” to do it? Is this for a school assignment or for learning?
Either way, the code for how Lemur constructs its Ray is right there online:
…where range[1] is a Z value calculated to be above everything.
Yeah. All of this works fine in Lemur… so you can always look there. Even if you are reinventing your own wheel it’s never wrong to check out other peoples’ wheels from time to time for ideas.
yeah, i felt like i invent own wheel, but thats just one aspect of gui i need to have different(at least i thought i had). but there’s still something i dont seen in other guis i need