Jump to content
  • Advertisement
Sign in to follow this  
jakesee

Who is responsible for scene picking?

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

Working in opengl, I am currently working on color picking with glReadPixels. And i have problems deciding who is responsible for calling the pick() function and who should decide what unique values to use for each entity in the scene.

What is the case usually?

-- MORE INFO --
I have a IGraphics interface which essentially is a wrapper for the underlying API i.e. opengl. IGraphics wraps stuff like glDrawElements, SwapBuffers, ReadPixels etc.

currently I have a Renderer::Render() which gets called in the idle loop:


Renderer::Render()
{
// bunch of IGraphic calls.
for (each entity in Scene)
{
...
_mIGraphics->DrawBuffers();
}
...
_mIGraphics->SwapBuffers();
}



Should I also let Renderer do the picking? Other candidates include the Scene object, but then I will have to share the IGraphics object which is currently contained in an inner-class inside Renderer... that is bad.

Share this post


Link to post
Share on other sites
Advertisement
I think the question should be, what is the purpose of the picking, and which class cares most about that purpose? Are you doing it for some process the renderer manages? Or one the scene manages? All things being equal, any functionality should be located closest to the other functionality it's most closely related to. Simple naive test: which class accesses the data generated by picking the most.

Share this post


Link to post
Share on other sites
It really depends on your overall architecture and how things would most naturally fit. From what you've described it sounds like Renderer makes the most sense for containing the picking logic, at least at a low level; you might consider wrapping that in a higher level interface as well for clean separation in case you want to rework your picking methodology later (e.g. if you decide to do picking via a physics library and a raycast, such as Bullet).

Share this post


Link to post
Share on other sites
I guess if you are doing color picking it would be somewhere in the renderer. You will also need access to GUI elements, since you need pick those as well. Also, if you pick a GUI element during a frame, then you should not also simultaneously pick a world object that happens to be behind that GUI element.

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!