PDA

View Full Version : how to get the vertices of transformed shapes ?



candela
04-23-2011, 11:35 PM
hi,

To move in scene I use gluLookAt function so I have different vantage points, and when I try to apply the stenciling, no matter from which different point I'm viewing the scene via gluLookAt, stenciling is always at the same location.

That urged me to think that, to achieve proper effect of stenciling, I need to apply something to get the transformed shape and later send it to stencile processing functions because gluLookAt doesn't transform each objects "automagically" but the viewing point, whereas I'm always sending the untransformed shape to stenciling pipeline
FOR EXAMPLE:

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
glColorMask(0,0,0,0);
glClearStencil(0);
glEnable(GL_DEPTH_TEST);
glCullFace(GL_FRONT);
glutSolidSphere(0.6,16,16);

glEnable(GL_STENCIL_TEST);
glDepthMask(0);
glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);
glCullFace(GL_BACK);
glutSolidOctahedron();

Even though I'm viewing from different angles the processed shapes is always same, so there is no way for stencil buffer to know that this shape is viewed from point A or from point B.

Comments will be appreciated,

Regards,

BionicBytes
04-25-2011, 08:47 AM
I'm viewing the scene via gluLookAt, stenciling is always at the same location.

gluLookat is setting the openGl ModelViewMatrix. All verticies are transformed by this matrix and this matrix always has a value.


glutSolidSphere(0.6,16,16);
...will be transformed by the current ModelViewMatrix.

Changing the viewing direction of the current camera (gluLookAt) will simply redefine the ModelViewMatrix. All this does is transform all of the verticies in the scene so they are viewable by the camera.

What you are asking for does not make any sense. If you have a laptop on the table and look at it, no matter from which direction it still looks like the same laptop - nothing has changed.

candela
04-25-2011, 01:06 PM
Thanks for commenting !!!


Changing the viewing direction of the current camera (gluLookAt) will simply redefine the ModelViewMatrix. All this does is transform all of the verticies in the scene so they are viewable by the camera.
Exactly MUST BE as you defined. But why on earth am I getting the screen fixed stencil masking, could you just check demo?

here is the display code:

void display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

glColorMask(0,0,0,0);
glClearStencil(0);
glEnable(GL_DEPTH_TEST);
glCullFace(GL_FRONT);
glutSolidSphere(0.6,16,16);

glEnable(GL_STENCIL_TEST);
glDepthMask(0);
glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);
glCullFace(GL_BACK);
glutSolidOctahedron();

glStencilOp(GL_KEEP, GL_KEEP, GL_DECR);
glCullFace(GL_FRONT);
glutSolidOctahedron();

glStencilFunc(GL_NOTEQUAL,0,1);
glStencilMask(0);
glColorMask(1,1,1,1);
glDisable(GL_DEPTH_TEST);
glCullFace(GL_FRONT);
glColor3f(0,0,1);
glutSolidSphere(0.6,16,16);

glEnable(GL_DEPTH_TEST);
glDisable(GL_STENCIL_TEST);
glutSwapBuffers();
}

BionicBytes
04-28-2011, 04:43 AM
I tried the test_project.exe however there must be some dll dependancies or it's compiled for a platform I don't have.
I'm using vista 32-bit.

The error I get is "The application has failed to start because the side-by-side configuration is incorrect"

candela
04-30-2011, 11:29 PM
Thanks in advance,
when I run the above posted code I get the following which is as expected, holes represent the masqueraded part by stencil buffer.
http://i52.tinypic.com/bfhohs.jpg

Weirdness is that:
When I involve mouse interaction with that code and move away from center the size of holes is still same (where they should be smaller with each gradual far away) and red rectangles shows that axes are masqueraded by stencil buffer where it shouldn't be .

void motion_func(int x, int y) {
glLoadIdentity();
gluLookAt(0.3*(x-mousex),0, 4, 0, 0, 0, 0, 1, 0);
glutPostRedisplay();
}

http://i53.tinypic.com/33xy7hg.jpg