reset password
Author Message
leannedavid
Posts: 14
Posted 08:14 Nov 10, 2016 |

Page 374

Case Study 7.1: Flying a Camera Through a Scene

Write an application that allows the user to fly a camera through some scene. The user presses keys to control the camera. At each keystroke the camera is slid in one of the three dimensions, or is rotated about one of its axes (through function calls similar to those used in Figure 7.13 aka the Camera class we're working on in class), and the scene is redrawn from the camera's new point of view. (You should decide which keystrokes to use for sliding the camera, and which to use for rotating it.) Also allow the user to change the view angle and aspect ratio of the camera with other keystrokes.

Experimentation with a camera is made much more intelligible if you cover the horizontal plane with a set of grid lines, as in Figure 7.24. This is easily done in a loop as such as:

for(int x = -100; x < 100; x++){
    glBegin(GL_LINES);
           glVertex3d(x, 0, 100);
           glVertex3d(x, 0, -100);
    glEnd();
}

that draws a set of 200 x-contours. A similar loop draws the z-contours. Add a keystroke control so the user can toggle the grid lines on and off.

OpenGL offers primitives that can be used to model interesting scenes. Use several objects described in Chapter 5, such as spheres, cones, dodecahedra, and the teapot, to make such a scene. Use the wireframe versions. 

Last edited by leannedavid at 10:30 Nov 10, 2016.
jcalilu
Posts: 20
Posted 08:21 Nov 10, 2016 |

Attached are the figures mentioned from the project.

Attachments: