Picking with an Absolute mouse

More on the whole Orthographic mode situation. I think I am going to add a ProjectionState. You’ll be able to set ortho mode and normal mode from here and set it to tree nodes. That might give you finer control.

That would be extremely cool.



I’m currently using the gui’s Text object to show labels or text. This object basically uses the orthographic mode ( like all gui elements do ).



Can’t wait to test it!

"Marius" wrote:
To calculate the direction of the ray you need the start point (x,y) and the direction of the ray ( which you get if you substract the far plane position with the near plane position)

Marius, can you explain how you get the far plane position? I'm assuming the near-plane position is simply the translated-to-view mouse coordinates.

Also, are you still planning on posting your source code?

-Mike

Well, to create a ray I called my hacked-in getWorldCoordinates. This method took a parameter, Z for the plane.



To cast a mouse-ray I simply called this :



startPoint = mouse.getWorldCoordinates(0);

endPoint = mouse.getWorldCoordinates(1);



then I have that start point ( startPoint ) and direction ( endPoint - startPoint) of the ray.





Hope this helps a bit.



// side-note, I’m still planning to release the source soon but want to implement at least some new features before doing so. Also, i’m currently not using any mouse-actions in my game. I intend to implement mouse picking later on.

Marius was kind enough to explain to me offline that the code I needed was



            DisplaySystem display = DisplaySystem.getDisplaySystem();

            Vector2f screenPosition = new Vector2f(mouse.getLocalTranslation().x, mouse.getLocalTranslation().y);
                 
            Vector3f nearWorldCoordinates = display.getWorldCoordinates(screenPosition, 0);

            Vector3f farWorldCoordinates = display.getWorldCoordinates(screenPosition, 1);



Once I have this figured out, I'll try to post an example Test application demonstrating how this is done.

So far, I have the ray computed (although I'm using near - far, which may just be a problem in my orientation.)

-Mike

FYI, getScreenCoordinates has been updated to return a Vector3f instead of a Vector2f. This change brings us into line with OpenGL’s gluProject specs. It also fixes a problem some were having with lens flare where you could sometimes find another flare at the negative coords of where the real flare lay.