Details
Add a light class and add materials to the Model
. The class should have the following methods:
Model
Model()
Creates a new empty Model object. If an empty model's draw function is called, nothing will be drawn.
void load(string objFileName)
Loads the specified Wavefront obj file as a OpenGL vertex buffer object. If this model has already loaded an obj file, the old model is cleared before the new model is loaded. This method only reads the following obj file lines:
1. v [x coordinate] [y coordinate] [z coordinate]
2. vn [x direction] [y direction] [z direction]
3. f [vertex] [vertex index] [vertex index]
4. f [vertex]//[normal] [vertex]//[normal] [vertex]//[normal]
5. mtllib [.mtl file name]
6. usemtl [material name]
This method only reads the following mtl file lines:
1. newmtl [material name]
2. Ka [red] [green] [blue]
3. Kd [red] [green] [blue]
4. Ks [red] [green] [blue]
5. Ns [coefficient]
This method assumes that an OpenGL context and window have been created.
void draw()
Draw this model using OpenGL and glDrawArrays
. Triangles are rendered with the materials specified in the obj and mtl files. This method assumes that an OpenGL context and window have been created. Note, all triangles in the model will be drawn the same color.
void clear()
De-allocates the vertex buffer object and sets the model state back to an empty model object.
Light
Light()
Creates a new Light object located at the origin with the color white and no attenuation.
void set_position(float x, float y, float z)
Changes the light location to the specified coordinates.
void set_color(float r, float g, float b)
Changes the light color to the specified color.
void set_attenuation(float factor)
Changes the light attenuation to the specified factor.
void activate()
Sets this light to be the light used when rendering.
Submission
Your program will be evaluated for both style and functionality. Submit your code and test data as a tar file on cseval before class on Wednesday February 5th.