OpenGL Lab
In this lab, we are to render 25 parametrically described shapes using
openGL.below are the 3 different surface models available.
Download Animation Clip
right click the link and choose save target as.
Note : as the shapes animate, the specular changes accordingly, because i interpolated the normals between 2 key frames.
Return to Main
We first use for loops to draw the wireframes . For my lab, I fixed  phi then increment theta ,then fix theta increment phi.
After countless of trial and error, we get the correct loop condition.
next is the tiring job of typing all 25 parametric equations.
Wire Frame
Next we define the normals of each vertex. this is done by differentiating all the the equations with respect to phi then with theta. After this cross multiply the 2 matrix. the resulting equation defines the normal to the surface. So I differentiated by hand most of the equations, until a friend told me a site does it automatically....
Flat Shading
After many double checks and typing in the 25 normal equations, you get this 25 shapes with nice flat shading. Next step is to add in the extra functions like active rotation, zoomin, out, animation, popup menus, etc to fufill all the presquisites.
Note that i interpolate the normals between frames.
Finally is defining shininess and colour of the objects.
yaayy OpenGL lab Completed!!
Smooth Shading