In this programming exercise we are going to construct a three-d model by combining a number of simple shapes. We will then light to model to make a realistic three-d scene.
The model we are going to construct is a simplified model of the portico on the Vermont State House.
The portico is the porch on the front of the building.
Here are the shapes you will need to construct:
To color the shapes, feel free to use one of the predefined materials that the authors provide in Utils.cpp. I suggest using the bronze material.
Click the appropriate button above to download starter code for this assignment. Right now that program draws a torus that is illuminated by a moving light source. You are going to replace the torus with the shapes needed to make the portico.
In assignment two I provided a Cylinder class that you can use to make the columns. The only thing missing from that class is the ability to generate normals for the vertices. Modify the Cylinder class to make it capable of generating normals for the vertices of the cylinder.
To draw a slab, you should start with basic code for drawing a cube. You can find code in the first assignment to draw a cube. That code is also missing normals: you will need to supplement the list of vertices of the cube with a list of normal vectors. To make a slab, you would simply translate and scale the cube.
To make a triangular prism for the roof of the portico, you can follow the same approach that you used for the cube. In this case you will have to write down both a list of vertices and a list of normals for the prism.
To draw multiple different shapes in a program, you will simply load the data for the different shapes into different vertex buffers. Then, to draw each individual shape in turn you will activate the vertex buffers for that shape and call either glDrawArrays
to draw a list of triangles or glDrawElements
to draw a shape that uses an indexed representation for the triangles.