Thursday, March 10, 2011

Picking in OpenGL

1. The process of picking an object in openGL is rather complex at first but once you grasp the idea becomes quite clear. The thing goes more or less like this:


Inside the rendering function:



  • initialize the primitive naming functionality with glInitNames()

  • load a name (an unsigned integer) or push it into the name stack

  • draw



Inside the selection processing function:





  • setup the selection buffer

  • save the current projection matrix

  • change the render mode to GL_SELECT

  • set a new clipping volume around the mouse cursor with gluPickMatrix()

  • transform this new clipping volume to the one you're using for rendering (to get a true mapping)

  • draw the scene

  • collect the generated hits

  • parse the selection buffer

  • do "the magic" you want to happen when the user selects a particular object.

  • restore the former projection matrix

  • and go back to the modelview for normal rendering





Well, second guessing, it isn't that clear, but practice makes master.


2. I talked about kindness from unexpected sources in my last post, and it happened again, someone did a nice thing to help me and I wasn't expecting it. It feels right to have a concrete prove that people like you; usually you don't help someone you don't like.
3. And even more compelling is to receive compliments from someone you admire. The neurotic issue here, is the fear of letting him down. I have confidence in such thing not happening though.
4. Today I submitted my terminal project proposal, I have confidence also that it will be accepted.
5. I started reading about web services, it looks quite interesting. It's oriented towards business to business collaboration.

No comments:

Post a Comment