Results 1 to 5 of 5

Thread: how to get the vertices of transformed shapes ?

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2011
    Posts
    13

    how to get the vertices of transformed shapes ?

    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:
    Code :
    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,

  2. #2
    Senior Member OpenGL Pro BionicBytes's Avatar
    Join Date
    Mar 2009
    Location
    UK, London
    Posts
    1,161

    Re: how to get the vertices of transformed shapes ?

    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.
    Code :
    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.

  3. #3
    Junior Member Newbie
    Join Date
    Mar 2011
    Posts
    13

    Re: how to get the vertices of transformed shapes ?

    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:
    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();  
    }

  4. #4
    Senior Member OpenGL Pro BionicBytes's Avatar
    Join Date
    Mar 2009
    Location
    UK, London
    Posts
    1,161

    Re: how to get the vertices of transformed shapes ?

    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"

  5. #5
    Junior Member Newbie
    Join Date
    Mar 2011
    Posts
    13

    Re: how to get the vertices of transformed shapes ?

    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.


    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 .
    Code :
    void motion_func(int x, int y) {
    glLoadIdentity();
     gluLookAt(0.3*(x-mousex),0, 4, 0, 0, 0, 0, 1, 0);
     glutPostRedisplay();
    }


Similar Threads

  1. Rendering simple shapes without passing vertices?
    By 7d7d7d in forum OpenGL: GLSL
    Replies: 10
    Last Post: 04-27-2012, 09:14 AM
  2. Incomplete shapes and "blobs" (extra solid shapes)
    By bballdave025 in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 07-12-2011, 11:54 PM
  3. Read back transformed vertices...
    By ttdsuen in forum OpenGL: General
    Replies: 2
    Last Post: 03-03-2004, 11:18 AM
  4. Replies: 1
    Last Post: 12-08-2003, 05:04 PM
  5. Transformed and Lit Vertices
    By imported_Ilya in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 04-14-2001, 06:00 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean