Advertisement

object selection

Started by September 25, 2003 01:18 AM
2 comments, last by jbeder 21 years, 5 months ago
I''m writing a 2D/3D game (think warcraft3), and I''m trying to figure out how to deal with mouse selection. I want the user to be able to click somewhere and have their character move to that place on the map, but I don''t know how to convert the mouse coordinates to the point on the ground. One option that I don''t want to do is to tile the ground in selection mode, determine if one of the tiles has been selected, and then move the character there. That seems like a BAD solution to me, especially since there is a limit on the number of objects that can be in the selection buffer. It seems as though this problem should have come up before. Is there any nice way of solving it? Any help is greatly appreciated, Jesse Beder
Can't you use glUnProject() (don't ask me how it works, but I think that what it's used for

EDIT: ups... its gluUnProject... still don't know how it works, though!

[edited by - NeViL tHe dEVil on September 25, 2003 5:01:38 PM]
------------------------------------------------------ Regret Nothing - Learn Everything
Advertisement
http://onemancrew.sinfree.net
under downloads you''ll find example.
Use glunproject to get a ray from the front of the screen to the back clipping plane.

Then use a read pixels to see where the ray colides with the 3d terrain. If you have a 2d terrain you can just find the XZ plane interect of that ray.

This topic is closed to new replies.

Advertisement