Docsity

Computer Science 470: Gouraud Shading with Triangle Meshes - Prof. Robert Clark, Exams of Computer Science

Toggle sidebar
bg1
COMPUTER SCIENCE 470
Midterm Program 2
Starting with your completed pipeline program, make additions and modifications to allow for
Gouraud shading. A triangle mesh data file will be provided and thus this program will be using
triangles as primitives rather than lines. Triangles will be specified as three vertices in counter-
clockwise order (you may assume correct input data) and you may assume that the triangles do
share some edges and vertices. Identical vertices in the triangles should be duplicated in each
triangle. A complete input file will be given below.
You may assume the same basic configuration of triangles (though different files may have
different vertex coordinates) – the basic configuration is shown above. Thus, when determining
vertex normals you should hard-code the calculation with the assumption that edges inside the
triangle mesh will be smoothed over. Thus, vertex 0 of triangle 0 is shared with all three triangles,
vertex 1 of triangle 0 is shared between triangle 0 and triangle 1 and vertex 2 of triangle 0 is
shared between triangle 0 and triangle 2. Since our current clipping routines only work for lines
and not polygons you may assume that NO edges will be clipped. You should also assume that
any edges shared by triangles are to be smoothed over during rendering. Finally do NOT use any
distance factor at all in calculating shading values. Your program should output the following
values:
•Polygon normals for all polygons (triangles).
•For each vertex in the first triangle specified (triangle 0):
•World coordinates
•Perspective (CVV) coordinates (including w).
•Screen coordinates (x, y, and the z value) needed for hidden surface removal
•The vertex normal
•The overall shade value for the vertex.
•The ambient term for the vertex.
•The diffuse term for the vertex.
•The specular term for the vertex.
•Finally, for full credit, you should use the provided graphics interface to actually draw
the shaded triangles.
Use the MyCanvas class method pixel() to draw a shaded representation of the entire triangle
mesh with the lighting and materials specified in the data file.
0
1 2
v0
v1 v2
pf2

Partial preview of the text

Download Computer Science 470: Gouraud Shading with Triangle Meshes - Prof. Robert Clark and more Exams Computer Science in PDF only on Docsity!

COMPUTER SCIENCE 470

Midterm Program 2

Starting with your completed pipeline program, make additions and modifications to allow for

Gouraud shading. A triangle mesh data file will be provided and thus this program will be using

triangles as primitives rather than lines. Triangles will be specified as three vertices in counter-

clockwise order (you may assume correct input data) and you may assume that the triangles do

share some edges and vertices. Identical vertices in the triangles should be duplicated in each

triangle. A complete input file will be given below.

You may assume the same basic configuration of triangles (though different files may have

different vertex coordinates) – the basic configuration is shown above. Thus, when determining

vertex normals you should hard-code the calculation with the assumption that edges inside the

triangle mesh will be smoothed over. Thus, vertex 0 of triangle 0 is shared with all three triangles,

vertex 1 of triangle 0 is shared between triangle 0 and triangle 1 and vertex 2 of triangle 0 is

shared between triangle 0 and triangle 2. Since our current clipping routines only work for lines

and not polygons you may assume that NO edges will be clipped. You should also assume that

any edges shared by triangles are to be smoothed over during rendering. Finally do NOT use any

distance factor at all in calculating shading values. Your program should output the following

values:

  • Polygon normals for all polygons (triangles).
  • For each vertex in the first triangle specified (triangle 0):
    • World coordinates
    • Perspective (CVV) coordinates (including w).
    • Screen coordinates (x, y, and the z value) needed for hidden surface removal
    • The vertex normal
    • The overall shade value for the vertex.
    • The ambient term for the vertex.
    • The diffuse term for the vertex.
    • The specular term for the vertex.
    • Finally, for full credit, you should use the provided graphics interface to actually draw

the shaded triangles.

Use the MyCanvas class method pixel() to draw a shaded representation of the entire triangle

mesh with the lighting and materials specified in the data file.

v v1 v

A sample data file: Triangles 3 15 25 -15 10 0 -10 20 0 - 15 25 -15 -20 10 -25 10 0 - 15 25 -15 20 0 -10 50 10 - ModelingTransforms 1 Translate -15.0 0.0 0. Camera position: 0.0 2.0 0. View up vector (user supplied): 0.0 1.0 0. View Reference Point: 0.0 0.0 -10. Near:

Far:

Window: Left: -20. Right:

Bottom: -20. Top:

Viewport: x: 0 y: 0 width: 800 height: 800 AmbientIntensity 0.2 0.2 0. Lights 1 Position: -15.0 4.0 0. Intensity: 1.0 1.0 1. Material Ambient refl coeff: 0.9 0.3 0. Diffuse refl coeff: 0.9 0.3 0. Specular refl coeff: 0.7 0.7 0. Shininess: