TP2 Camera ENG
TP2 Camera ENG
Reminders
To be able to move the camera and place the point of view anywhere in the scene, we use a kind of virtual
camera with the function call:
gluLookAt(eyeX,eyeY,eyeZ,centerX,centerY,centerZ,upX,upY,upZ)
Placing the camera means moving everyone so that they are centered on the camera and oriented along
the line of sight. This therefore logically influences the GL MODELVIEW matrix and you will
not be surprised that the camera is called just after resetting GL MODELVIEW.
Machine Translated by Google
Examples:
In our initial scene, the cube is placed at (0.,0.,0):
The call to the gluLookAt(0., 0., -10., 0., 0., 0., 0., 1., 0.) function; allows you to see the back of the cube:
Change the vertical (the parameters vertX, vertY and vertZ) and therefore call the function gluLookAt(0.,
0., 0., 0., 0., -5., 1., 1., 0.); allows you to tilt the stage
• Position a Camera in init using the following parameters: eye = {0.,0.,1.,}, aim = {0.,0.,-1.,} and up =
{0.,1., 0.5,0.}. • Add the gluLookAt(...) function
in your code (display). You should know that this function applies to the stack of MODELVIEW matrices
and that you want to position the camera before placing and tracing the different objects in the
scene.
• Each press of a key causes a movement (in translation or rotation) and the movement is carried out by
calculating the new values of the parameters of the gluLookAt() function. It is therefore no longer
a question of stacking and unstacking OpenGL transformation matrices, but of calculating "by hand" the
new O,X,Y,Z parameters of the camera to move it. For example, for a forward translation, we move the
position O of the camera a certain number of times on the vector Z.
For a rotation, O is fixed, but we will change the orientation of the vectors X,
Y and Z. • Your
gluLookAt(...) is defined as follows:
We are going to create a walk type navigation , that is to say that we will be able to
move around the scene like a user who can walk in space. The following
functionalities will need to be developed:
To do this, we will use the keyboard arrows for forward/backward and left/right, as well as the h and b keys
for up/down.
Go forward go backward
Start by moving the camera forward/backward. Please note, the movement is made in the direction of the
camera's Z vector.
2. Calculate the new unit vector Z corresponding to the new position of the point
targeted and finally calculate the new vector
3. Calculate the new vector X.