A ring of rings spins and dilates around a ice cream cone.
The purpose of this lab was to understand how to the glPushMatrix() and glPopMatrix() for isolating 3D objects for animations. Given lab4_start.cpp as an example we had to change the drawObjects() function to draw our own object and make it animate somehow. The object had to made up of at least 6 sub objects.
You can download the lab4.c and compile it with g++ with 1:
g++ -o test -lglut -lGLU lab4.cpp
I chose to do a pleasant ice cream cone. The cone is made of 3 cylinders and a disk for the base. The ice cream is made of 3 stacked tori (donuts) and a embedded tetrahedron for the tip. The ring of rings is a set of tori arranged in a circle.
The render was only showing a bright solid color for the ice cream cone so I found how to add lighting to the scene so you can see depth and get shading. This openGL light tutorial I found showed me how to quickly add diffused and ambient lighting source to my scene and got me the sense of depth I was looking for.
The rings have a few parameters that cycle from 0 to some constant with the f function:
float f(float A,float f,float p){
return A*sin(t*f*3.14/180+p*3.14/180);
}
t is a global time keeping variable that all the parameters depend on. The parameters that cycle for the rings are:
Even when looking at the original example my understanding of what glPushMatrix() and glPopMatrix() were doing was fuzzy. This was because my understanding of the use of transform matrices was fuzzy also. I searched for popmatrix in google and found a forum question for Processing with the reply and explained what I needed know:
pushMatrix(); translate(10,0); //move shpae right 10 pixels rect(0,0, 20,20); //draw rectangle popMatrix(); //reset coordinates translate(-10,0); //move shape left 10 pixels rect(0,20, 20,20);
reset was the key word that made everything crystal clear.



1 It took me a little time to figure out I need to include GLU for everything to work.
Date: 2011-09-20 23:36:53 EDT
HTML generated by org-mode 6.21b in emacs 23