Jump to content
  • Advertisement
Sign in to follow this  
Cacks

OpenGL Selecting objects in my scene

This topic is 4651 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 guys, in my OpenGL scene I store my objects in a vector then iterate through the vector to render them. Is that a good way to render my objects? Also, I want to select an object on screen. I've read in the Red Book about selection and feedback. But I don't understand the difference. Could some1 explain the difference in simple terms please. Also My objects which I call Bricks are defined as: class Brick { private: float xPos, yPos, zPos; public: render(); ... } Is there anything I need to add into each object for selecting them? Thanks for any help given!

Share this post


Link to post
Share on other sites
Advertisement
Hello Cacks,

Its the easiest (and fastest) way to do it, but its also the least efficient way to do. What about culling? Are all of your objects visible everytime in runtime? render()'call should be done from an auxiliar data structure, usually a scene-graph; it will sort your objects and sent just the bare minimum to the hw (after some previous and very fast culling) So if you have time enough try to add some kind of scene sorting prior to render stage.

Sorry about picking i cant help you (perhaps some local guru can) but, unless all your objects are spheres or cubes you will need more data for sure.

totb

Share this post


Link to post
Share on other sites
For object selection you have 2 choices in opengl, selection and picking. You can find good information on both of these topics on the www.opengl.org faq (clicky).

In opengl terms, your choices are rendering your scene regularly and then rendering a simplified version in GL_SELECT mode, or you can take your x and y coordinates and call gluUnproject to cast a 3d ray into your scene and mathematically determine what object you are intersecting.

LightHouse3d has a tutorial on the first method here and nehe has a gluUnproject tutorial here. I can't say which is better, it really depends on your application. I myself prefer to use gluUnproject.

Hope this helps.

Nit

Share this post


Link to post
Share on other sites
I would definintely recommend you implement picking using this method:
http://gpwiki.org/index.php/OpenGL_Selection_Using_Unique_Color_IDs

Its by far the easiest method.

Share this post


Link to post
Share on other sites
Quote:
Original post by oconnellseanm
I would definintely recommend you implement picking using this method:
http://gpwiki.org/index.php/OpenGL_Selection_Using_Unique_Color_IDs

Its by far the easiest method.


I agree, after glancing at that page that seems like a very good idea. You can also have thousands of objects on a screen at once and look them up easily.

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!