• Advertisement
Sign in to follow this  

gluProject and picking

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

If I have a tiled map that's raised with a height feild (mountains and stuff) - basiclly a mesh if you know what I mean, how do I use gluProject/UnProject to tell which tile the mouse is on? Or are there better ways to do it? I thought of drawing the map again with the tiles colored in different colors and then do color picking, but that seemed a little slow. Any ideas? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
I believe there is an example in the red book and is quite simple to follow. The one I did was an older version but this'll probably be better...

http://www.rush3d.com/reference/opengl-redbook-1.1/chapter12.html

Share this post


Link to post
Share on other sites
Here's another example for you:

http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=32

Share this post


Link to post
Share on other sites
I know about opengl's selection, but to use it I would have to render all of the 1024X1024 tiles seperatly and then see which one was picked - but with opengl's selection you can only draw 64, and even if you could draw more, it would take a ton of time and would wreck the framerate. I think that I need another method. This should be a pretty basic thing for every 3D tiled game, how is it done?
Thanks.

Share this post


Link to post
Share on other sites
Quote:
Original post by daniel_i_l
I know about opengl's selection, but to use it I would have to render all of the 1024X1024 tiles seperatly and then see which one was picked - but with opengl's selection you can only draw 64, and even if you could draw more, it would take a ton of time and would wreck the framerate. I think that I need another method. This should be a pretty basic thing for every 3D tiled game, how is it done?
Thanks.
This is also in answer to your other post on picking.

I'd recommend approaching this problem geometrically rather than using feedback mode or other framebuffer tricks. The first step is to construct a picking ray. You can do this by using gluUnproject() to find the worldspace coordinates corresponding to the mouse position at the near and far planes. You can find more details on this step here.

How to use the pick ray to select geometry in your simulation is a bigger topic, but in almost all cases it can be accelerated and/or optimized so that it will be practical even if you have thousands of objects in your scene.

It's hard to be more specific without knowing more about your simulation. You mentioned a heightfield, but also tiles. Based on that, possible solutions might include a (3D) quadtree, or 3D-DDA.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement