Semester Programming Assignment - Part #1 (SP1) - CSU540 Computer Graphics - Fall 2005

"Two Cones" -- Professor Futrelle

Version of 25 October 2005


Building an object from triangles and lighting it

This Sp1 is due by the end of Thursday, November 3rd, emailed as a jar, as in previous assignments. You've seen the collected critiques for PA3. Pay careful attention to the various successes and failings noted there.

The basic idea:

Build two abutting cones from a collection of independent triangles, with the two vertexes of the cones on the z-axis and the base of each cone in the x,y plane, z=0. Much of the basics are shown in the following three sketches I did in class, and edited later:

The details

  1. Build one cone, then copy points to the other.
  2. Cone starts with two points, one on z-axis, other on x-axis.
  3. Rotate the x-point 2π/n creating the third vertex of the triangle.
  4. Create the triangle object with the vertices in the correct order.
  5. Make a copy of the triangle with copied vertices. Rotate each of the base vertices by 2π/n, creating the second triangle.
  6. Continue in this way until you have n triangles.
  7. Copy all these triangles to create the set for the opposite cone, but changing the z-axis point of each.
  8. Rearrange the order of the points in the triangles, if necessary, as you copy them, to assure they're in the right order to create outward normals in the second cone.
  9. Rotate all the points π/4 around the x or y axis, followed by a translation of the center of the cone pair to the center of the screen.
  10. Compute the normals for each triangle.
  11. Compute the brightness for each triangle face, including some constant ambient illumination.
  12. Ray trace the object twice, with different light directions.
  13. Start all this with n=3 (6 faces) because ray tracing will be linear in the number of faces. Then raise n and see how far you can go.

And finally: Be proud of your results! This is pretty advanced work for a beginning graphics course with code built from scratch.

Notes on strategies, steps, fallbacks, etc.

Wire frames: Draw only the edges - no ray tracing required.

Constant illumination: Ray trace, but use only one color. Harlequin approach - each triangle a random color.

Empty code and javadoc. Empty method bodies, but with a returned value/object as needed.

Fancy stuff: Other variants could include different colors, two light sources, different ambient level, Two cone objects, especially if they intersect, extreme shapes, e.g. flat bottom.

Concept of convexity: "no (con)cavities" - pool ball is convex. Technically draw any chord from one point on the surface to any other point - it will be entirely in the interior. For a single convex object, ray tracing is not necessary. Only need to do "backface culling" - ignore any triangle, face, facet, whose normal is point away from the view direction.


Go to CSU540 home page. or RPF's Teaching Gateway or homepage