Computer GraphicsHomework 9

Computer GraphicsHomework 9
Triangle mesh model in a scene
1. Use OpenGL to display a 3D model in a scene with appropriate lighting. The goal is to have this look like a picture of a real-world scene (even it it’s a fantasy world).
2. Use the same model you used in Homework 8.
a. You will want to place it precisely in the scene. Use scaling and translation to put it exactly where you want.
b. If you calculate a bounding box while reading in the file, you can figure out how much to scale and translate so that the model is at the origin and within a -1 to 1 cube.
3. Calculate a normal vector at every vertex using the algorithm described in class.
a. If you have a Vertex class and a Triangle class, add instance variables to hold a normal for each of them.
b. If you don’t have those classes, you have “parallel arrays” instead. This is fine—you will just need more arrays to hold (x,y,z) values for normal vectors for the triangles and vertices.
c. Use smooth shading.
d. Normal vectors are transformed along with vertices by the current transformation matrix. This is (usually) what we want, except for scaling. Normal vectors should always be unit length for the lighting to look right. Since you know how you’re scaling you can compensate for it by setting the right length of every normal vector, or you can do it the easier (but slower) way by enabling GL_NORMALIZE (see p. 103 in the textbook).
4. Add a floor and a backdrop to the scene so that the model looks somewhat realistic, rather than floating in space.
5. Add a light (or lights) so that your model looks realistically lit. Do not use the randomly colored triangles anymore.
6. Try to use texture mapping.
a. You may use textures on the model if you want, but make sure you also use lighting.
b. You may use textures on the floor or walls or elsewhere in the environment instead of (or in addition to) on the model itself.
7. Remember that this will be graded on the basis of creativity, completeness, construction, and communication. (See course syllabus.)
Due 11:59 p.m., 17November 2015.

READ ALSO :   Research methodology