Move view or camera in 6 degrees of freedom

Hello,

First I’m sorry for my English, French student

I fight like crazy to be able to move the view (or camera) in a scene. I know it’s the scene that moves and not the view but still, it makes me sad for not succeeding this stuff (or that there is no glu function from the manage all this)

Question 0: Is there a way of defining Identity as actual position (and angles), a kind of glSaveIdentity, so that the followed glLoadIdentity will now load position that we just saved?

So I use 2 ways: one is based gluLookAt, the other based on a series of glRotated and glTranslated. I did not succeed with neither way, I had few wrong hopes …

Note: For keyboard interaction, I use a QWERTY keyboard and ideally, I would like to have (compared to the current view):
turn left a - d turn right to
look up w - s look down
swivels left q - e swivels right

Go left j - l go right
go up i - k go down
go ahead o - u go back

Question 1: What is the magic formula for cosine and sine that gluLookAt works properly for my demand?


const GLdouble PI = 3.1415926535898;

GLvoid Keyboard(unsigned char , int , int);

//View locate parameters
GLdouble eyex=0.;
GLdouble eyey=0.;
GLdouble eyez=0.;
GLdouble centrex=0.;
GLdouble centrey=0.;
GLdouble centrez=0.;
GLdouble upx=0.;
GLdouble upy=1.;
GLdouble upz=0.;
GLdouble anglexz=0;
GLdouble angley=0;
GLvoid DrawScene(GLvoid)
{
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  glPushMatrix();


/*In whole for centrex-centerz, I add a sine-cosine so that we look at the fictitious object on the trigonometric circle whose the center is the current view, and it works well to turn left-right
note: our keyboard interactions always attribute eyei = centrei*/
gluLookAt(eyex,eyey,eyez,centrex+sin(anglexz),centrey,centrez+cos(anglexz),]sin(angley)*cos(anglexz),cos(angley)*cos(anglexz),sin(angley)*cos(anglexz));

  DessineSalle();

   glutPostRedisplay();
   glutSwapBuffers();
  glFlush();

  glPopMatrix();
}

GLvoid
Keyboard(unsigned char key , int x, int y)
{
  switch(key)
    {
////////////////// ROTATE
    case 'e':
      angley-=PI/144;
      break;
    case 'q':
      angley+=PI/144;
      break;
    case 'd' :
      anglexz-=PI/144;
      break;
    case 'a' :
      anglez+=PI/144;
      break;
    case 's' :
      anglex-=PI/144;
      break;
    case 'w' :
      anglex+=PI/144;
      break;

//////////////TRANSLATE
    case 'j' :
      centrex-=0.25;
      eyex-=0.25;
      break;
    case 'l':
      centrex+=0.25;
      eyex+=0.25;
      break;
    case 'k' :
      centrey-=0.25;
      eyey-=0.25;
      break;
    case 'i' :
      centrey+=0.25;
      eyey+=0.25;
      break;
    case 'o' :
      centrez-=0.25;
      eyez-=0.25;
      break;
    case 'u' :
      centrez+=0.25;
      eyez+=0.25;
      break;

    case 'V':
      glLoadIdentity();
      break;

    case 27:
      exit(1);
      break;
    }

     glutPostRedisplay();
}

Question 2: Why this trick of the function in glRotated glTranslated does not work at all?


GLvoid Keyboard(unsigned char , int , int);


GLvoid Camera(GLfloat , GLfloat , GLfloat , GLfloat , GLfloat , GLfloat );//move the camera
GLfloat angleX = 0;
GLfloat angleY = 0;
GLfloat angleZ = 0;
GLfloat posX = 0;
GLfloat posY = 0;
GLfloat posZ = 0;

GLvoid DrawScene(GLvoid)
{

  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  glPushMatrix();

  DessineSalle();

   glutPostRedisplay();
   glutSwapBuffers();
  glFlush();

  glPopMatrix();



}

GLvoid
Keyboard(unsigned char key , int x, int y)
{
  switch(key)
    {
////////////////// ROTATE
    case 'e':
      Camera(0.,0.,1.,0.,0.,0.);
      break;
    case 'q':
      Camera(0.,0.,-1.,0.,0.,0.);
      break;
    case 's' :
      Camera(1.,0.,0.,0.,0.,0.);
      break;
    case 'w' :
      Camera(-1.,0.,0.,0.,0.,0.);
      break;
    case 'd' :
      Camera(0.,1.,0.,0.,0.,0.);
      break;
    case 'a' :
      Camera(0.,-1.,0.,0.,0.,0.);
      break;

//////////////TRANSLATE
    case 'j' :
    Camera(0.,0.,0.,1.,0.,0.);
      break;
    case 'l':
     Camera(0.,0.,0.,-1.,0.,0.);
      break;
    case 'k' :
    Camera(0.,0.,0.,0.,1.,0.);
      break;
    case 'i' :
    Camera(0.,0.,0.,0.,-1.,0.);
      break;
    case 'o' :
    Camera(0.,0.,0.,0.,0.,1.);
      break;
    case 'u' :
    Camera(0.,0.,0.,0.,0.,-1.);
      break;

    case 'V':
      glLoadIdentity();
      break;

    case 27:
      exit(1);
      break;
    }

      glutPostRedisplay();
}


GLvoid Camera(GLfloat rotX, GLfloat rotY, GLfloat rotZ, GLfloat transX , GLfloat transY, GLfloat transZ)
{
//je ne pourrais pas expliquer ce que j'observe, en tout cas c'est pas ce que j'attend...
    glTranslated(posX,posY,posZ);
    glRotated(angleX,1.,0.,0.);
    glRotated(angleY,0.,1.,0.);
    glRotated(angleZ,0.,0.,1.);

    angleX-=rotX;
    angleY-=rotY;
    angleZ-=rotZ;
    posX-=transX;
    posY-=transY;
    posZ-=transZ;

    glRotated(-angleZ,0.,0.,1.);
    glRotated(-angleY,0.,1.,0.);
    glRotated(-angleX,1.,0.,0.);
    glTranslated(-posX,-posY,-posZ);


}

First, the identity matrix is the identity matrix. Your projection and modelview are carried over every frame. To save a matrix out into an array, call glGet on the matrix you want and glLoadMatrix to put it back. You should also get familiar with the matrix stack, which may be what you want. Basically you can push and pop the matrix, so if you push the matrix up the stack, you can do anything you want with it, then pop it off and you’re back where you started.

http://www.opengl.org/resources/faq/technical/transformations.htm

Second, it’s hard for me to know the difference between swiveling and turning, but the difference between the two is one is rotating the eye around the lookat position, while the second is rotating the lookat position around the eye. Left and right is easy because you’re always rotating around the y-axis. If you’re rotating up and down, you need to calculate a new axis to rotate around.

swiveling was the wrong word, I mean the rotation by the axe of your look , as you said.

I read 2 or 3 long articles from your link, it’s not responding to my problem.

The pilotView() function (look like my camera() function) does not allow me to do what I want to do:

recall: I want to move at 6 degrees or liberty (tranlate by the 3 axes and rotate by the 3 axes) being ALWAYS and at any changes at the origin of rotation and translation, and after all rot and trans, I want that the direction I look is refresh as the Z axe:

So if I push the keyboard to look up, and than I push to go forward, I want to go forward in the direction of what I’m seeing, and not parralele of the ground. A 1st person view or like a pilot…

ok, I’ve done some analysis with of the view,
remember that I want all future rotations and translations being relative to the actual view, and not the Zero-view

Based on this code, I tried different order of transformation at the *********

Here is my code simplified:



    GLfloat angleX = 33;
    GLfloat angleY = 159;
    GLfloat angleZ = 57;
    GLfloat posX = -2.3;
    GLfloat posY = -1.5;
    GLfloat posZ = 5;

int main(int argc , char **argv)
{
    glutInit(&argc,argv);
    Initialise(argv[0]);  
    glutKeyboardFunc(Keyboard);
    glutDisplayFunc(DrawScene);  
    glutReshapeFunc(Resize);
    glutMainLoop();
    return 0;
}

GLvoid Initialise(char * Titre)
{
    GLvoid DefineWindow(char *);
    glutInitDisplayMode( GLUT_RGBA | GLUT_DEPTH | GLUT_DOUBLE );
    glutInitWindowPosition(0,0);
    glutInitWindowSize(800,600);
    glutCreateWindow(Titre);
    glClearColor(0.7,0.7,1., 1.);
}

GLvoid Resize(GLsizei WindowWidth , GLsizei WindowHeight  )
{
    glViewport( 0, 0,WindowWidth , WindowHeight) ;
    GLfloat ratio = (GLfloat)  WindowWidth /  WindowHeight;
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(45.,ratio,0.1,130);
    glMatrixMode(GL_MODELVIEW);
}

GLvoid Keyboard(unsigned char key , int x, int y)
{
  switch(key)
    {
////////////////// ROTATE
    case 'e':
      Camera(0.,0.,1.,0.,0.,0.);
      break;
    case 'q':
      Camera(0.,0.,-1.,0.,0.,0.);
      break;
    case 's' :
      Camera(1.,0.,0.,0.,0.,0.);
      break;
    case 'w' :
      Camera(-1.,0.,0.,0.,0.,0.);
      break;
    case 'd' :
      Camera(0.,1.,0.,0.,0.,0.);
      break;
    case 'a' :
      Camera(0.,-1.,0.,0.,0.,0.);
      break;
//////////////TRANSLATE
    case 'j' :
    Camera(0.,0.,0.,1.,0.,0.);
      break;
    case 'l':
    Camera(0.,0.,0.,-1.,0.,0.);
      break;
    case 'k' :
    Camera(0.,0.,0.,0.,1.,0.);
      break;
    case 'i' :
    Camera(0.,0.,0.,0.,-1.,0.);
      break;
    case 'o' :
    Camera(0.,0.,0.,0.,0.,1.);
      break;
    case 'u' :
    Camera(0.,0.,0.,0.,0.,-1.);
      break;

    case 'v':
      glLoadIdentity();
      break;
    case 27:
      exit(1);
      break;
    }
   glutPostRedisplay();
}

GLvoid Camera(GLfloat rotX, GLfloat rotY, GLfloat rotZ, GLfloat transX , GLfloat transY, GLfloat transZ)
{
    angleX+=rotX;
    angleY+=rotY;
    angleZ+=rotZ;
    posX+=transX;
    posY+=transY;
    posZ+=transZ;
}

GLvoid DrawScene(GLvoid)
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glPushMatrix();
       
   ***************

    glutSolidTeapot(0.5);
    DrawRoom();

    glutPostRedisplay();
    glutSwapBuffers();
    glPopMatrix();
}

Here is all I want to check:

  • rotation by the actual X axes
  • rotation by the actual Y axes
  • rotation by the actual Z axes
  • translation following the actual X axes
  • translation following the actual Y axes
  • translation following the actual Z axes

And here are the orders that I tested, these are placed at the ********** in the code

Order 1

    glRotated(angleX,1.,0.,0.);
    glRotated(angleY,0.,1.,0.);
    glRotated(angleZ,0.,0.,1.);
    glTranslated(posX,posY,posZ);
  • rotation by the actual X axes : CHECKED
  • rotation by the actual Y axes : CHECKED
  • rotation by the actual Z axes : NOT, it’s a rotation by the Zero-view Z axes translated to our view, why?? only translated to our view, not rotated, why!!! If not a success, I attended that this rotation would turn around the zero-view axes, but not, it’s the Zero-view axes translated to actual view(good!) but not in rotated to the look direction (not good)
  • translation following the actual X axes : NOT, it follows the Zero-view X axes
  • translation following the actual Y axes : NOT, it follows the Zero-view Y axes
  • translation following the actual Z axes : NOT, it follows the Zero-view Z axes

Order 2


   glTranslated(posX,posY,posZ);
    glRotated(angleX,1.,0.,0.);
    glRotated(angleY,0.,1.,0.);
    glRotated(angleZ,0.,0.,1.);

  • rotation by the actual X axes : NOT, we turn around the Zero-view X axes, rotated as our view (but not translates) again, why???
  • rotation by the actual Y axes : NOT, we turn around the Zero-view Y axes, rotated as our view (but not translates) again, why???
  • rotation by the actual Z axes : NOT, we turn around the original Zero-view Z axes
  • translation following the actual X axes : CHECKED
  • translation following the actual Y axes : CHECKED
  • translation following the actual Z axes : CHECKED

Order 3

   glTranslated(posX,posY,posZ);

    glRotated(angleZ,0.,0.,1.);
    glRotated(angleX,1.,0.,0.);
    glRotated(angleY,0.,1.,0.);
  • rotation by the actual X axes : NOT, we turn around the Zero-view X axes
  • rotation by the actual Y axes : NOT, we turn around the Zero-view Y axes
  • rotation by the actual Z axes : NOT, we turn around the Zero-view Z axes rotated as our view (but not translates) again, why???
  • translation following the actual X axes : CHECKED
  • translation following the actual Y axes : CHECKED
  • translation following the actual Z axes : CHECKED

… ok, I won’t try the 4!=24 possibility, but I want to find a way (perhaps a magic order , a matrix thing or something else) to have all those transformation checked.

Again, I know that we do openGL for the scene and not for the camera, but still, I have to have a perfect control of my camera to continue my work

so, I tried to replace ******** by this code:


    GLfloat TrMatrix[]={(GLfloat)(cos(angleY)*cos(angleZ)),(GLfloat)(-cos(angleY)*sin(angleZ)),(GLfloat)sin(angleY),posX,
                        (GLfloat)(sin(angleX)*sin(angleY)*cos(angleZ)+cos(angleX)*sin(angleZ)),(GLfloat)(-sin(angleX)*sin(angleY)*sin(angleZ)+cos(angleX)*cos(angleZ)),(GLfloat)-sin(angleX)*cos(angleY),posY,
                        (GLfloat)(-cos(angleX)*sin(angleY)*cos(angleZ)+sin(angleX)*sin(angleZ)),(GLfloat)(cos(angleX)*sin(angleY)*sin(angleZ)+sin(angleX)*cos(angleZ)),(GLfloat)cos(angleX)*cos(angleY),posZ,    0.f,0.f,0.f,1.f};

glLoadMatrixf(TrMatrix);

It breaks all the drawing of my room (few walls are hidden, light is not as expected) and it does not give a relative translation.

We have less and less tools to do that. I’m surprise by the long way I take to find a stuff that should be obvious in computer graphics.

ok, I’ve got it!!
Curiously, I did not found anything on the net. It’s surprising because I wonder that a lot of people want to manipulate the camera in their convenience.

I know now how to move the view about current frame of the camera with 6 degrees of freedom.

If you compile the following code, you will see how to have a camera in first person view in 6DOF

enjoy!
<div class=“ubbcode-block”><div class=“ubbcode-header”>Click to reveal… <input type=“button” class=“form-button” value=“Show me!” onclick=“toggle_spoiler(this, ‘Yikes, my eyes!’, ‘Show me!’)” />]<div style=“display: none;”>



/*
HAMMOUTENE Amir
[email]amir.hammoutene@gmail.com[/email]
04/12/2010

This code shows how to move the "camera" in OpenGL like a First Person Viewer (camera piloting)
It moves the camera relatively to its position in 6 degrees of fredom.

The most important code is in : GLvoid transfomCamera()  and in    GLvoid DrawScene
See also   GLvoid Keyboard   for the key used


build links to:
oprngl32
glu32
glut32
gdi32
winmm
*/

#include <stdlib.h>//standard C library, used for exit()
//OpenGL libraries, with glut
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
#include <math.h>//Mathematics

GLvoid Initialise( char * Titre);//Initialization of the scene
GLvoid DrawScene(GLvoid);// Drawing method, called in loop
GLvoid Resize(const GLsizei ,const  GLsizei);// Used when resizing the application window
GLvoid Keyboard(unsigned char , int , int);// Keyboard and mouse interaction
GLvoid DefineLight(const GLint);//Initialise the light source
GLvoid TeaTeam();//Draw Teapots
GLvoid Intro();//show a litlle demo

    GLfloat keyCamRot = 0.5f;
    GLfloat keyCamTrans = 0.05f;
    GLfloat TrMatrix[]={1.f,0.f,0.f,0.f,0.f,1.f,0.f,0.f,0.f,0.f,1.f,0.f,0.f,0.f,0.f,1.f};
    GLfloat   LightRelativePos[]={0.f,1.3f,-1.f,1.f};
    const GLfloat EPSILON = 0.00000000000001f;

    const GLfloat Red1Amb[] = { 0.9,0.,0. ,1};
    const GLfloat Red1Spe[] = { 1.0f, 1.0f, 1.0f, 1.0f };
    const GLfloat Red1Dif[] = {0.6,0.,0. ,1};
    const GLfloat Red1Emi[] = {0.,0.,0. ,1};

    GLfloat t=0;

int main(int argc , char **argv)
{
    glutInit(&argc,argv);
    Initialise(argv[0]);  /* Fonction à écrire pour initialiser la machine OpenGL */
    glutKeyboardFunc(Keyboard);
    glutDisplayFunc(DrawScene);  /* fonction à appeler avec la fonction principale de rendu à écrire */
    glutReshapeFunc(Resize);
    glutMainLoop(); /* Fonction de boucle infinie */
    return 0;
}

GLvoid Initialise(char * Titre)
{
    GLvoid DefineWindow(char *);
    glutInitDisplayMode( GLUT_RGBA | GLUT_DEPTH | GLUT_DOUBLE );
    DefineWindow("Elbow Manipulator");
    glPointSize(1.f);
    glLineWidth(1.f);
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_BLEND);
    glEnable(GL_POINT_SMOOTH);
    glEnable(GL_LINE_SMOOTH);
    glDisable(GL_CULL_FACE );
    glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
    glPolygonMode(GL_FRONT_AND_BACK,GL_FILL );
    glMaterialf(GL_FRONT_AND_BACK,GL_SHININESS,1.f);
    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
    DefineLight(4);
    glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT,Red1Amb);
    glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,Red1Dif);
    glMaterialfv(GL_FRONT_AND_BACK,GL_SPECULAR,Red1Spe);
    glMaterialfv(GL_FRONT_AND_BACK,GL_EMISSION,Red1Emi);
    glColor3f(0.9f,0.f,0.f);
    glPointSize(10.f);
}
GLvoid Resize(GLsizei WindowWidth , GLsizei WindowHeight  )
{
    glViewport( 0, 0,WindowWidth , WindowHeight) ;
    GLfloat ratio = (GLfloat)  WindowWidth /  WindowHeight;
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(45.f,ratio,0.1f,130.f);
    glMatrixMode(GL_MODELVIEW);
}

GLvoid DefineWindow(char * Titre)
{
    GLsizei ScreenWidth,ScreenHeight;
    GLsizei WindowWidth, WindowHeight;
    ScreenWidth=glutGet(GLUT_SCREEN_WIDTH);
    ScreenHeight=glutGet(GLUT_SCREEN_HEIGHT);
    glutInitWindowPosition(0,0);
    glutInitWindowSize(ScreenWidth,ScreenHeight);
    glutCreateWindow(Titre);
    glClearColor(0.7f,0.7f,1.f, 1.f);
    WindowWidth  = glutGet(GLUT_WINDOW_WIDTH) ;
    WindowHeight = glutGet(GLUT_WINDOW_HEIGHT);
    Resize(WindowWidth,WindowHeight);
}

GLvoid DefineLight(GLint numberofLights)
{
    int i;
    const GLfloat LumiereAmbient[]={ 0.f, 0.0f, 0.0f, 0.0f};
    const GLfloat LumiereDiffuse[]={1.f, 1.f, 1.f, 1.f };
    const GLfloat LumiereSpecular[]={1.0f, 1.0f, 1.0f, 1.0f};
    const GLfloat cst_attenuation =0.025f*numberofLights;
    const GLfloat ln_attenuation= 0.1525f*numberofLights;
    const GLfloat qua_attenuation= 0.0025f*numberofLights;
    const GLint Lights[]= {GL_LIGHT0,GL_LIGHT1,GL_LIGHT2,GL_LIGHT3,GL_LIGHT4,GL_LIGHT5,GL_LIGHT6,GL_LIGHT7};
    glEnable(GL_LIGHTING);
    glEnable(GL_NORMALIZE);
    glDepthFunc(GL_LESS);
    glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1 );
    glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE );

    for (i = 0 ; i<numberofLights ; i++) {
        glEnable(Lights[i]);
        glLightfv(Lights[i],GL_AMBIENT,LumiereAmbient);
        glLightfv(Lights[i],GL_DIFFUSE,LumiereDiffuse);
        glLightfv(Lights[i],GL_SPECULAR,LumiereSpecular);
        glLightf(Lights[i],GL_CONSTANT_ATTENUATION,  cst_attenuation);
        glLightf(Lights[i],GL_LINEAR_ATTENUATION,  ln_attenuation);
        glLightf(Lights[i],GL_QUADRATIC_ATTENUATION,  qua_attenuation);
    }
}

GLvoid DrawScene(GLvoid)
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    if (t<1000) t++;

    glPushMatrix();
        glLoadIdentity();
        glBegin(GL_POINTS);
        glVertex3f(0.f,0.f,-100.f);
        glEnd();
    glPopMatrix();
    glPushMatrix();
        TeaTeam();
        if (t<1000) Intro();
        glutSwapBuffers();
        glutPostRedisplay();
    glPopMatrix();

}

GLvoid Keyboard(unsigned char key , int x, int y)
{
  switch(key)
    {
////////////////// ROTATE
    case 'e':
      glLoadIdentity();
      glRotatef(keyCamRot,0.f,0.f,1.f);
      glMultMatrixf(TrMatrix);
      glGetFloatv(GL_MODELVIEW_MATRIX, TrMatrix);
      break;
    case 'q':
      glLoadIdentity();
      glRotatef(-keyCamRot,0.f,0.f,1.f);
      glMultMatrixf(TrMatrix);
      glGetFloatv(GL_MODELVIEW_MATRIX, TrMatrix);
      break;
    case 's' :
      glLoadIdentity();
      glRotatef(keyCamRot,1.f,0.f,0.f);
      glMultMatrixf(TrMatrix);
      glGetFloatv(GL_MODELVIEW_MATRIX, TrMatrix);
      break;
    case 'w' :
      glLoadIdentity();
      glRotatef(-keyCamRot,1.f,0.f,0.f);
      glMultMatrixf(TrMatrix);
      glGetFloatv(GL_MODELVIEW_MATRIX, TrMatrix);
      break;
    case 'd' :
      glLoadIdentity();
      glRotatef(keyCamRot,0.f,1.f,0.f);
      glMultMatrixf(TrMatrix);
      glGetFloatv(GL_MODELVIEW_MATRIX, TrMatrix);
      break;
    case 'a' :
      glLoadIdentity();
      glRotatef(-keyCamRot,0.f,1.f,0.f);
      glMultMatrixf(TrMatrix);
      glGetFloatv(GL_MODELVIEW_MATRIX, TrMatrix);
      break;
//////////////TRANSLATE
    case 'j' :
      glLoadIdentity();
      glTranslatef(keyCamTrans,0.f,0.f);
      glMultMatrixf(TrMatrix);
      glGetFloatv(GL_MODELVIEW_MATRIX, TrMatrix);
      break;
    case 'l':
      glLoadIdentity();
      glTranslatef(-keyCamTrans,0.f,0.f);
      glMultMatrixf(TrMatrix);
      glGetFloatv(GL_MODELVIEW_MATRIX, TrMatrix);
      break;
    case 'u' :
      glLoadIdentity();
      glTranslatef(0.f,keyCamTrans,0.f);
      glMultMatrixf(TrMatrix);
      glGetFloatv(GL_MODELVIEW_MATRIX, TrMatrix);
      break;
    case 'o' :
      glLoadIdentity();
      glTranslatef(0.f,-keyCamTrans,0.f);
      glMultMatrixf(TrMatrix);
      glGetFloatv(GL_MODELVIEW_MATRIX, TrMatrix);
      break;
    case 'i' :
      glLoadIdentity();
      glTranslatef(0.f,0.f,keyCamTrans);
      glMultMatrixf(TrMatrix);
      glGetFloatv(GL_MODELVIEW_MATRIX, TrMatrix);
      break;
    case 'k' :
      glLoadIdentity();
      glTranslatef(0.f,0.f,-keyCamTrans);
      glMultMatrixf(TrMatrix);
      glGetFloatv(GL_MODELVIEW_MATRIX, TrMatrix);
      break;

    case 'v':
        glLoadIdentity();
        glGetFloatv(GL_MODELVIEW_MATRIX, TrMatrix);
      break;

    case 27:
      exit(1);
      break;
    }

      glutPostRedisplay();
}


GLvoid TeaTeam()
{
        glLoadMatrixf(TrMatrix);
        glLightfv(GL_LIGHT0,GL_POSITION,LightRelativePos);
        glTranslatef(0.f,0.f,-6.f);
        glLightfv(GL_LIGHT1,GL_POSITION,LightRelativePos);
        glutSolidTeapot(1);
        glTranslatef(3.f,0.f,-3.f);
        glLightfv(GL_LIGHT2,GL_POSITION,LightRelativePos);
        glutSolidTeapot(1);
        glTranslatef(-9.f,0.f,-5.f);
        glLightfv(GL_LIGHT3,GL_POSITION,LightRelativePos);
        glutSolidTeapot(1);
        //DessineSalle();
}

GLvoid Intro()
{
    if(t>10 && t< 100) {
      glLoadIdentity();
      glTranslatef(0.f,0.f,-keyCamTrans);
      glMultMatrixf(TrMatrix);
      glGetFloatv(GL_MODELVIEW_MATRIX, TrMatrix);
      glutPostRedisplay();
    }
    else if(t>=120 && t< 220) {
      glLoadIdentity();
      glTranslatef(-keyCamTrans,0.f,0.f);
      glMultMatrixf(TrMatrix);
      glGetFloatv(GL_MODELVIEW_MATRIX, TrMatrix);
      glutPostRedisplay();
    }
    else if(t>=240 && t< 290) {
      glLoadIdentity();
      glRotatef(-keyCamRot,0.f,1.f,0.f);
      glMultMatrixf(TrMatrix);
      glGetFloatv(GL_MODELVIEW_MATRIX, TrMatrix);
      glutPostRedisplay();
    }
    else if(t>=310 && t< 410) {
      glLoadIdentity();
      glTranslatef(0.f,-keyCamTrans,0.f);
      glMultMatrixf(TrMatrix);
      glGetFloatv(GL_MODELVIEW_MATRIX, TrMatrix);
      glutPostRedisplay();
    }
    else if(t>=430 && t< 465) {
      glLoadIdentity();
      glRotatef(keyCamRot,1.f,0.f,0.f);
      glMultMatrixf(TrMatrix);
      glGetFloatv(GL_MODELVIEW_MATRIX, TrMatrix);
      glutPostRedisplay();
    }
    else if(t>=490 && t< 630) {
      glLoadIdentity();
      glTranslatef(0.f,0.f,keyCamTrans);
      glMultMatrixf(TrMatrix);
      glGetFloatv(GL_MODELVIEW_MATRIX, TrMatrix);
      glutPostRedisplay();
    }
    else if (t>630) {
        glLoadIdentity();
        glGetFloatv(GL_MODELVIEW_MATRIX, TrMatrix);
        t=1001;
        glutPostRedisplay();
    }
}


[/QUOTE]</div>