Sign in to follow this  
gpr1me

Clicking an object with the mouse.

Recommended Posts

In my program i want to be able to make an object (like a plane made with a GL_QUAD) clickable. So if i have a plane displayed on the screen i want to be able to click on a point on the screen and get the X, Y position on the plane (not the screen). Is this some sort of collision detection or something? [Edited by - gpr1me on March 26, 2006 4:00:31 PM]

Share this post


Link to post
Share on other sites
OpenGL actually has a limited set of mouse picking capabilities (which NeHe has a tutorial on here), however it works by allowing selection of screen-space regions rather than points, so you get a list of selected objects and you chose the closest one to get the effectively selected object. But if you want the exact world-space intersection point of the selection with the object, you'll have to manually intersect a ray with the object. Intersecting rays with polygons isn't too bad though, and if you do it in NDC-space then the math can simplify immensely. Once you have the location in NDC-space, then you can inverse transform it into world-space.

I believe there are few references in this FAQ on ray-poly intersection as well as performing the inverse transformations.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this