Making an Ice Cream Cone How to build Making an Ice Cream Cone
Take a piece of paper, lay it on the desk, and draw the x and z axes on it. Label it with +x, -x, +z, -z +x is to the right +z is toward you
Start with a copy of box.cpp Notice the viewing box glFrustum(-5.0, 5.0, -5.0, 5.0, 5.0, 100.0); Notice everything is being translates back 15 units glTranslatef(0.0, 0.0, -15.0); Comment out the line that creates a box Replace it with code that makes one fat red point at the origin. Run it and see that it is working
Some building blocks: glutWireSphere(radius, slices, stacks); https://www.opengl.org/resources/libraries/glut/spec3/node81.html glutWireCone(base, height, slices, stacks); https://www.opengl.org/resources/libraries/glut/spec3/node83.html
Below making the red dot, make a green cone, vertex down. you will need to rotate it glRotated(angle, x, y,z); put glPushMatrix and glPopMatrix around the rotation and the cone. run it and see where it is relative to the dot.
Below making the cone, make a sphere of the same radius. Pick a flavor Below making the cone, make a sphere of the same radius. Pick a flavor. Translate it, if necessary, to be sitting inside and above the cone. glTranslated(x,y,z); run it
Below making the icecream, make a cherry on top, a solid sphere of a small radius. Translate it to be sitting on top of the ice cream. Around the translate and making the little sphere put glPushMatrix and glPopMatrix. Run it.
Translate the entire icecream cone 5 units to the right. Using pushMatrix and popMatrix, have that translation only apply to the icecream cone.
Notice the icecream appears to be in front of the cone, not in it Notice the icecream appears to be in front of the cone, not in it. Add depth. In main: glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); In drawscene: glClear(GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT); glEnable(GL_DEPTH_TEST);