Tuesday, March 22, 2011

Picking and Change of Looks

  • Now I'm able to click on the fan and make it spin faster or slower, this feature is called selection and picking in openGL.

  • Using GLframe.h and picking. You should be aware that if you use the GLframe.h class provided with the superbible book to move around the scene, to get a correct mapping you need to do something like this:


//Change render mode
//Establish new clipping volume to be unit cube around mouse cursor
//point (xPos, yPos) and extending two pixels in the vertical and horizontal direction
gluPickMatrix(xPos, viewport[3] - yPos + viewport[1], 10,10, viewport);
GLfloat aspectRatio;
aspectRatio = (float) viewport[2] / (float) viewport[3];
gluPerspective (60.0f,aspectRatio, 50.0f,800.0f);
glMatrixMode(GL_MODELVIEW);  //<-This is the important part
glLoadMatrixf(cameraM); // <- and this one


This because you change the modelview matrix each time you render the scene to move around.

And here's the new style:

[caption id="attachment_125" align="aligncenter" width="300" caption="proyectoGraficacion_v.0.2.5"][/caption]

  • You can see the z-fighting under the table, I'll get it fixed soon.

  • Just a couple of requirements are left to consider this finished. Out of my own contribution I intent to place a window for those curtains, a dealer, the walls and a big sign outdoors when all the requirements are properly taken care of.  This project was really fun. Comments are welcome.

No comments:

Post a Comment