TP-rendu/TP1-2/reponses.md
2023-06-22 20:30:57 +02:00

5.1 KiB
Raw Permalink Blame History

Replace glutWireTeapot with glutSolidTeapot.

What do you see ? What do you think it is still missing in order to see a more realistic rendering of the teapot?

On voit un teapot "plein"/solid, il manque simplement un peu de lumière/shading, pour que le rendu soit plus réaliste.

glutWireTeapot(.5)
glutSolidTeapot(.5)

Replace the teapot with a sphere using glutWireSphere.

The parameter slices is the number of meridians around the z-axis to draw, and stacks the parallels along the z-axis. Try with different values for each of them and compare the results

glutWireSphere(0.7, 20, 20)
glutWireSphere(0.7, 100, 100)

Try to manually resize the window. What happens?

How can we preserve the aspect ratio of our scene? Change the call to glViewport so that every time the windows is resized, the viewport is always a square centred both vertically and horizontally inside the window, and its size is the maximum that can fit the window (i.e. its size is the minimum between the width and the height of the window).

L'aspect ratio de notre fenêtre change, mais l'aspect ratio de notre scène n'étant pas fixe, on observe que le rendu devient difforme.

En utilisant le callback glviewport, on peut ainsi fixer/conserver l'aspect ratio en toute circonstance.

Add a new case for the letter w, so that every time it is pressed we can switch from a wireframe teapot to a solid teapot and viceversa.

(Hint: you can define and use a global bool variable...)

cf helloteapot.cpp

Try to increase and decrease the value of the parameter fovy of gluPerspective.

What happens and why?

fovy correspond à la focale de la caméra selon l'axe y de l'image.

On observe alors que les objets sont comprimés ou étalées, si l'on diminue ou augmente fovy.

Try to increase the value of the parameter zNear of gluPerspective.

What happens for values, e.g., greater than 2.1?

zNear permet de définir le début du volume de clipping.

Ainsi si l'on défini zNear supérieur à 2.1 dans la scène de l'exercice, le volume de clipping se situe derrière le teapot et donc on ne le voit plus.

What happens if we invert the up vector, i.e. we set it to (0,-1,0)?

L'image est à l'envers.

gluLookAt(0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 0.0, -1.0, 0.0)

Set the camera so that we can see the teapot as in Figure 9 (a-b)?

How do you change the “up-vector”?

On défini le up vector : (1, 1, -1)

gluLookAt(0.0, 0.0, -2.0, 0.0, 0.0, 0.0, 1.0, 1.0, -1.0)
gluLookAt(0.0, 2.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0);

What happens if the second glPopMatrix in display isnt there?

Try resizing the window or partially covering it, to force a repaint. Why does this occur? (Consider what happens to the modelview stack.)

On push deux matrices au début de la fonction. On doit alors pop deux matrices avant de finir la fonction. Si on enlève le deuxième glPopMatrix, alors les transformations suivantes seront conservées lors de la prochaine itération:

// translate -2 on y and -1 on z
glTranslatef(0, -2, -1);
// set drawing color to blue
glColor3f(0.0f, 0.0f, 1.0f);
// bottom blue teapot
glutWireTeapot(1);

Ainsi lorsque l'on redimensionne la fenêtre, on doit redessiner les teapots, et par accumulation des glTranslatef, ceux-ci disparaissent.

What happens if the gluLookAt(0.0,0.0,5.0,0.0,0.0,0.0,0.0,1.0,0.0) line in main is moved after the second glPushMatrix in display?

Why does this occur? (Consider what happens to the modelview stack.)

On observe que le teapot bleu n'est plus affiché. On suppose que cela se produit car le gluLookAt n'est appliqué que sur les deux premiers teapots (le rouge et le vert). Après le premier pop, l'information du gluLookAt, n'est pas transmise au tracé du teapot bleu.

What happens instead if the glLoadIdentity line in main is moved to just before the “draw scene” comment in display, and why?

(Consider what happens to the modelview stack.)

En utilisant glLoadIdentity en début d'itéation, on "reset" la camera, cela inclut gluLookAt et gluPerspective. On obtient une image très zoommée.