Jump to content
  • Advertisement
Sign in to follow this  
sesime

how to pick a point in the screen?

This topic is 4174 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

how to pick a point in the screen? I know basic skill on picking a object, but I want to pick points which form the object.For example, I uses 4 points to draw a square, I want to pick a point from the 4 points , not the square, how can I do that? How to name?

Share this post


Link to post
Share on other sites
Advertisement
Assuming you know how matrix's are applied, you can call glGetDoublefv( matrix, *data), where matrix (GL_MODELVIEW etc), data (float [16]).

Since you have the 4 points somewhere in RAM, you have to transform them on the CPU. ie. apply modelview, perspective, perspective divide, ndc to screen. Then just test the 2d mouse with the x,y points.

Share this post


Link to post
Share on other sites
Thanks for your reply. Maybe your method is good enough, but it is too complicated for me. I hope there is a way that easy to use, and similar with picking a object, using some OpenGL function.

How does 3DMax do this?

Share this post


Link to post
Share on other sites
Well do you understand the modelview and projection matrices? The only other way to pick stuff in 3d is to draw a ray for the camera, but I really doubt that would ever be used for picking vertices. Especially since you need pixel perfect.

Basically you send opengl some matrices and vertices. It does the work for you (mathematically). Well you yourself have to apply those matrices to each vertex and store them in RAM. Then you can check mouse(x,y) with vertex(x,y).

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!