Jump to content
  • Advertisement
Sign in to follow this  
brandonman

Unit Picking

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

Hi, and i'm getting started on a simple 2D rts. I have the tilemap drawn, and a unit drawn, but I can't get selecting it down. I'm drawing with glVertex3f, and I'm using getCursorPos() to find my mouse coordinates when the left mouse button is pressed. getcursorPos() returns pixel values, and my unit is drawn with the units, or "f"s, such as 1.0f. How can I convert the return of the getCursorPos() to the type of measurement I am using to draw my soldier? Or am I going to need to change the code and use pixels to render everything?

Share this post


Link to post
Share on other sites
Advertisement
To do it this way, you have to transform the object to the screen by going through the modelview,perspective, then perspective division yourself. Then you can either translate the mouse into this space , or translate the objects to pixel space.

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!