gluProject and picking
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.
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
http://www.rush3d.com/reference/opengl-redbook-1.1/chapter12.html
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.
Thanks.
Quote:Original post by daniel_i_lThis is also in answer to your other post on picking.
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement