Jump to content
  • Advertisement
Sign in to follow this  
gpr1me

Clicking an object with the mouse.

This topic is 4473 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!