OpenGL - Order of transformations

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Hoax
    New Member
    • Nov 2007
    • 7

    OpenGL - Order of transformations

    I didn't see a forum for OpenGL so i assume it would go here. I've having an issues with my camera interfering with the transformations of my geometry. Here is my Display() code, I think it's pretty straight forward.

    Code:
    void Display(void)
    {
          glClear(GL_COLOR_BUFFER_BIT |   GL_DEPTH_BUFFER_BIT);
          glEnable(GL_DEPTH_TEST);
    
          eyePos.Set(0,0,10);
          //this is my wrist position
           targetPos.Set(GraspEngine.wsPositions.palmContainerMat[12],GraspEngine.wsPositions.palmContainerMat[13],GraspEngine.wsPositions.palmContainerMat[14]);
    
          //I draw all environment objects here as primitives
          drawEnvObj();
          //Render the hand here
          render();
    
          //get distance to closest primitive, set color to red, and select motion from primitive struct
          GraspEngine.GetDistToEnvObj(&GraspEngine.env);
    
          //reset all transformations and place camera. The PanXYZ variable is a keyboard callback which is set to 0 initially.
          glMatrixMode(GL_MODELVIEW);
          glLoadIdentity();
          gluLookAt(eyePos.GetX()-panX,eyePos.GetY()-panY,eyePos.GetZ()-panZ,
          targetPos.GetX(),targetPos.GetY(),targetPos.GetZ(),
                0.0, 1.0, 0.0);
    
          //output wrist position, it is correct but camera won’t move now.  If I place this at the top then the camera moves but the wrist position is thrown off by this transformation
    
    cout << GraspEngine.wsPositions.wristContainerMat[12] << "  " << GraspEngine.wsPositions.wristContainerMat[13] << "  " << GraspEngine.wsPositions.wristContainerMat[14] << endl;
    
          glutSwapBuffers();
          glutPostRedisplay();
    }

    Thanks in advance,

    Matt Brisbin
Working...