

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An assignment for cmsc 740 students in the spring 2006 semester. The assignment involves extending the program from assignment 1 to include keyboard control, texturing, lighting, and animation in opengl. Students are required to allow user movement with keys, map textures to terrain and sky, implement lighting, and create an animation with a rotating sun and changing light direction and intensity.
Typology: Assignments
1 / 2
This page cannot be seen from the preview
Don't miss anything!


This assignment involves familiarization with OpenGL texturing and lighting, as well as simple animation. The assignment web-page is at www.cs.umd.edu/class/spring2006/cmsc740/assg2/. For this assignment, you should make the following extensions to your program from assignment 1.
● Keyboard control: Allow the user to move the viewer’s position with the keyboard. Keys w/s should move the viewer forward/backward, a/d should move left/right, and e/c should move up/down. (2 points)
● Texturing: We are providing you two bmp files, Grass.bmp and Sky.bmp. You may use these as textures, or generate your own. Map the grass texture to your terrain, with texture coordinates u and v each ranging from 0...1 from one end of the terrain to the other. For the sky, generate a large cube that encloses the entire scene (viewer and geometry) and map the sky texture to each face of the cube. (3 points)
● Lighting: Light your scene using ambient lighting and a directional light. This will require you to specify normals for the vertices of your terrain. You can approximate the normal at each vertex by computing two approximate tangent vectors to the vertex and taking their cross product. The tangent vectors can be computed from the heights of the four adjacent vertices (you will need to special case the edge and corner vertices).
The directional lighting should not affect the sky box. You should glDisable the directional light before rendering the sky box, and glEnable it again before rendering the terrain. (4 points)
● Animation: Make the sun rise and set. Render the sun as a yellow gluSphere floating over your terrain. To make the sun continuously rotate around the terrain, use glutIdleFunc to register an idle callback function – OpenGL will repeatedly call this function when it does not need to perform any other tasks. Each time this function is called, it should compute the amount of time since it was last called (for example, by using
angle of rotation by a corresponding amount. This angle should be passed into a glRotate call in your draw function.
As the sun rotates, you should also change the direction of the directional light so that it appears to be coming from the sun. As the sun gets close to setting, the light intensity should gradually dim out, and gradually fade back in again as the sun rises. You should make the sky box change brightness as well, either by using an ambient light, or by directly altering its vertex colors. (6 points) (Total: 15 points)
[Assignment tips are on the next page …]
Tips: