Math 155A - Introduction to Computer Graphics – Winter 2018
Sam Buss,  Univ. of California, San Diego

Project #3 – Construct a 3D-Letter (Alphabet Symbol), based on your Initial.
Due date: Friday, February 2, 9:00pm.

Goals: Create a parametric surface (namely, a portion of a surface of rotation) using quad strips and triangle fans or strips.  Learn how to model simple scenes with ellipsoids and cylinders; get more practice with matrices and affine transformations in 3-space. Create some custom animation.   Discover that wireframe objects, especially when combined with animation can look very three-dimensional.  Discover, however, that flat, solidly colored objects look much too flat and non-three-dimensional. 
    We will use this project as a basis for the next three projects, which will add another shape, then add materials and lighting, and then add textures.

What to hand in.

·        You do not need to have this assignment graded individually right away. If you prefer, you may wait until you finish Project #4, and then have them graded jointly.  However, it is permitted to have an individual grading; it is especially encouraged if you had difficulties or found parts of it confusing! This is because your code will be used again in the next project.
If you wish to be graded, the procedure is as usual: ask Professor Buss or a TA for grading in APM B325, run Visual Studio, and be ready to demo and discuss your project.

·        You must however, upload two items to gradescope, deadline is as above.  (Late uploads are accepted, but may be subject to a point deduction).

o   You must upload your main source file, called MyInitial.ccp.  If you make major changes to any other source files, please upload them to gradescope at the same time.

o   You must upload a PDF document, one or two pages long, showing two (at most three) images of your scene.  Your scene will be animated, so your two pictures should give a good view of your scene plus show clearly what the animation does.

·        Also, and this is important: make a copy of all your Project #3 source files, and place them a separate folder for safekeeping. (Perhaps even move them a Google drive folder.)  This will be available for you and us to refer back as needed, either for in-person grading or in case they are needed for Project 4.


1.      Download the file from the web.  This zip file contains 16 files:  Fifteen (15) C++ source files, and an executable LetterProj.exe.  The 15 source files are the complete source for this executable! The full URL for the zip file is:

2.      Run the executable on a PC.  You will see a scene with a rectangular floor, a couple cylinders, and a letter "S".  (That's my initial.).  Note the following commands act on the scene:

a.      Pressing the arrow keys changes the view position. 

b.      Pressing the “W” or “w” key toggles wire frame mode.  Note how flat and non-three-dimensional the objects look when filled in.  (We will fix this in project 5, when by adding material properties and lights to the scene).

c.      Pressing the “C” or “c” key toggles culling of back faces. 

d.      Pressing the “M” or “m” key increases or decreases the mesh resolution on the spheres (ellipsoids) and cylinders.

e.      The animation can be turned off and on by pressing “R” or “r”. It can be put into single step mode by pressing “S” or “s”.  The animation can be made to run faster or slower by pressing “F” (faster) or “f” (slower).

3.      Your job is to re-create this program -- sort of!!  Specifically, you will do something creative based on your own first initial instead of the "S".   You will also supply some animation.

4.      Form a new project and solution.  Include the all source files from the zip file in it – there are 15 source files (seven .cpp files and eight header files). These fiften files can be added all at once, as Visual Studio lets you select multiple files (use control or shift keys) to be added to the project/solution all at the same tile. When compiled, this code should run identically to the supplied executable.  The supplied source code handles all the keystroke commands, draws the flat base plane, draws to placeholder cylinders, and makes an “S” shape from ellipsoids and a cylinder.  The routines that make the “S” share are what you need to rewrite to form a geometry based on your initials.

5.      Understand the various components of the source code, at least at a high level. 

a.      The main program was getting rather long and complicated, so it is now split into two source files, LetterProj.cpp and MyInitial.cpp, and their associated header (.h) files. MyInitial.cpp holds the code for setting up, and rendering the “S” shape.  Most of your programming for this project will be to modify MyInitial.cpp.  The LetterProj.cpp has the part of the code that draws the floor and the two placeholder cylinders. It also handles all the general OpenGL setup, and keystrokes, opengl error checking, and etc.

b.      Variables are shared between different .cpp source files, by using header files, and extern declarations.  This means that one .cpp source file defines the actual variable, but other .cpp source files are able to access it via the header files.
If this is new to you, please google to learn about, or ask the professor, a TA or someone else about it.

c.      The vertex shader and fragment shader are unchanged from the previous (Solar) project.

d.      A new GlGeom object, GlGeomCylinder has been added (in new .cpp and .h files).  This works generally similar to GlGeomSphere: It creates a cylinder of radius 1 and height 2, centered at the origin. Of course, the cylinder’s position and shape can be controlled by scaling matrices, translation matrices, rotations matrices, or any other affine transformation.

e.      (Optional for now). The rectangular floor is rendered by glDrawElements() command instead of a glDrawArrays() command.  This form of drawing allows vertices to be put in an array without duplication, and then rendered based on the indices of the vertices.  We will use this more in the next project, but you do not need to change this for the current project.        

6.      MAIN PART OF THE PROJECT: Design some geometric shapes that are based (*loosely* based is OK) on the first initial of your first name or last name, --- or even some other letter, if you prefer.  Do something creative so that no two of you have the same geometry.  Your scene should be at least as complex as the scene supplied in the sample code rendering an “S”.  Try to be a bit artistic and creative. 
Suggestions: Use primarily the GlGeomSphere and GlGeomCylinder routines.  These are similar to what you already used for the solar system. Cylinders work similarly to spheres, and there are examples how use them in the code of
You may also use triangles, triangle fans, triangle strips. However, you should NOT make use of points or lines; the objects should have “outside surfaces”.  It is important that all surfaces are outward facing. 

7.      SECOND MAIN PART OF THE ASSIGNMENT: Animate some portion of your geometry.  This should be something comparable to what is done in the supplied code with the “S”. You do not need use the same kind of animation as in the supplied code. In the supplied code, note that the middle pieces of the "S" is animated part of the time and stationary part the time.  This gives smooth motion based on a Bezier curve.  It is not necessary to have this kind of start-and-stop animation in your program: it is OK if the animation runs all the time.  It is also OK if you want to make the animation happen only when triggered by a keyboard event.
Your animation should run smoothly, not jerkily.  A viewer watching it run should be able to see what is happening in the animation.

8.      The keyboard controls that toggle back face culling and wireframe mode, and also the mesh resolution controls, should also apply to your new geometries whenever possible. The arrow keys should still work to change the view position.

9.      Leave the rectangular base plane the same as it is in the supplied code.  Your finished program should look the same as the supplied demo executable, except the "S" is replaced by your own creation and with animation of your own design.

10.   Turn in the project as described above.   There are two things to upload to gradescope (a PDF file and your main source program).  In addition, make copies of all your files and save them somewhere safe.
Uploading to gradescope:

a.      You will get instructions on how to upload your source file MyInitial.cpp to gradescope. 

b.      Your PDF file should have two images showing your scene at different points in the animation. For these, choose a viewpoint so that it is easy to see what is in the scene. Then choose two points in the animation that do a good job of illustrating the action of your animation.  If necessary, you may use three pictures instead of two. You may create the PDF file in various ways:  screen shots (CNTL-ALT-PRINTSCREEN) can be stored to PDF files, and then multiple PDF files can be combined into a single PDF (using an appropriate PDF editor). Another good way, is to form a Word document, insert your screenshots as images (it is best to use text boxes in Word to hold your images), and then print your Word document to PDF.

Program grading: Scale of 0 to 10.  OPTIONAL: You may request a personal grading session with a TA or Professor Sam Buss.  OR, wait and have the project graded together with project #4.