155A - Introduction to Computer Graphics – Fall 2022
Instructor: Sam Buss, UC San Diego
Project #3 – Construct a 3D-Letter (Alphabet
Symbol), based on your Initial.
Due date: Friday, October 21, 11:00pm.
Goals: 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 and moving viewpoint can look very
three-dimensional. Discover, however, that flat, solidly colored objects look
much too flat and non-three-dimensional. Grading will be based mostly on technical merit and but also on
We will use this project as a basis for the next two projects, which will add another shape, and then add materials and lighting.
What to hand in.
· Upload to gradescope, your main source files and PDF report of your project, all placed together in a zip file. For most people, there will be three files uploaded, two source (.cpp) files and one PDF file.
o The source files are the main project source files InitialProj.cpp and MyInitial.cpp. Also include InitialProj.h and MyInitial.h if they were changed. Please use exactly these names for your main files and place them in a zip file to upload.
o A PDF file with a report of your work. See the instructions below. This will include your name, but not your student ID. It should have one or two paragraphs describing your project, and one or two images of your project.
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 Project 4.
If you wish to be graded right away, the procedure is as usual: ask Professor Buss or a TA for grading, run Visual Studio, and be ready to demo and discuss your project.
· A grading rubric is available already.
· Also, and this is important: make a copy of all your changed Project #3 source files, and place them a separate folder for safekeeping. (Files uploaded to gradescope can also serve this purpose, but we recommend keeping your own separate backup.) 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 InitialProject.zip from the web. This zip file contains 7 files: Four (4) C++ source files, one file of GLSL shader programs and two executables InitialProj.exe and InitialProj2018.exe. The rest of the C++ files will be obtained as described below.
2. Run the two executables (InitialProj.exe and InitialProj2018.exe) on a PC after extracting the files from the zip folder. (If you are not on a PC, you can build InitialProj.exe with the source code supplied, as described below. However, InitialProj2018.exe is available only for Windows. In this case, you can run it on PC lab computers or on CloudLabs) For InitialProj.exe, the GLSL source file InitialProj.glsl must be available. To do this, extract the executable files and InitialProj.glsl from the zipped compressed folder and place them together in another folder. In these programs, you will see a scene with
a. a rectangular floor,
b. a couple of cylinders,
Either an “X” shape
formed from two cylinders, a torus and a revolving ellipse;
or an “S” shape formed with cylinders and ellipsoids with an animation in the middle of “S”, depending on which program you are running.
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, 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”.
f. The animation can be put into single step mode by pressing “S” or “s”.
g. The animation can be made to run faster or slower by pressing “F” (faster) or “f” (slower).
h. In InitialProject.exe, you can use the HOME and END keys to move the viewpoint closer to or further away from the scene.
3. Your job is to re-create these programs -- sort of, but not really!! Specifically, you will
a. do something creative based on your own initial (first name or last name) instead of the "X" or the “S”. However, if you wish, you may use a different letter than your initials.
b. You must also supply some novel animation.
4. Form a new project and solution. You must collect the following twenty source files.
a. The four (4) C++ sources InitialProj.[cpp,.h] and MyInitial.[cpp,h] in the zip file.
b. The GLSL source file InitialProj.glsl from the zip file. This contains shader programs.
c. The five (5) GlLinearMath source files (MathMisc.h, and LinearR3.[cpp,h] and LinearR4.[cpp,h]), all available from the GlLinear web page accessible from http://www.math.ucsd.edu/~sbuss/MathCG2/OpenGLsoft/. These are the same as you used in Project #2.
d. The two (2) C++ programs GlShaderMgr.[cpp,h] available from the GlShader page at same URL as in item c. These programs handle reading GLSL source files and compiling and linking the shader programs.
e. The eight (8) C++ files GlGeomSphere.[cpp,h] and GlGeomCylinder.[cpp,h] and GlGeomTorus.[cpp,h] and GlGeomBase.[cpp,h]. The four for GlGeomSphere and GlGeomBase, you used already for the Solar program – it draws unit spheres centered at the origin. The four new files, for GlGeomCylinder and GlGeomTorus, draw cylinders of height two and radius 1, centered at the origin. These are available from the GlGeomShapes page, also at the same URL.
f. Include all nineteen (19) source files into your new C++ project. There are 19 source files (nine .cpp files and ten header files). These files can be added to your project 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 InitialProj.exe. The supplied source code handles all the keystroke commands, draws the flat base plane, draws two placeholder cylinders, and makes an “X” shape from cylinders, a torus and an ellipsoid. (The ellipsoid is a transformed sphere). The routines that make the “X” shape are what you need to rewrite to form a geometry based on your initials. The code you will change and write is all in MyInitial.cpp.
g. IMPORTANT: Place a copy of the GLSL source file InitialProj.glsl in the same directory as your Visual Studio project files. (The folder is probably the same one that contains your “.vcproj” project file and/or your “.sln” solution file.)
h. IMPORTANT: Wile debugging your program be sure to watch the console output window for error messages. These could report things being unable to open the glsl file, or encountering an OpenGL error. For OpenGL errors, use breakpoints and debugging to track down where the first OpenGL error is occurring. (The first one can cause lots and lots of subsequent error messages.)
i. You may add the InitialProj.glsl file to the Visual Studio project if you wish: it doesn’t make much difference, but it does make it convenient to read and edit the code in Visual Studio. (You do not need to edit it!)
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, InitalProj.cpp and MyInitial.cpp, and their associated header (.h) files. MyInitial.cpp holds the code for setting up, and rendering the “X” shape. It also controls the animation. Most (probably all) of your programming for this project will be to modify MyInitial.cpp. The other file, InitialProj.cpp, has the part of the code that draws the floor and the two placeholder cylinders. It also handles all the general OpenGL setup, shader compilation, keystrokes, OpenGL error checking, etc.
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
If this is new to you, please google to learn about it, 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: however, they are now included in the InitialProj.glsl file.
d. Two new GlGeom objects, GlGeomCylinder and GlGeomTorus hav been added (in new .cpp and .h files). They work generally similar to GlGeomSphere: GlGeomCylinder creates a cylinder of radius 1 and height 2, centered at the origin. GlGeomTorus creates a torus centered at the origin, with major radius one, and the minor radius can be set as desired. Of course, the cylinder’s and torus’s positions and shapes can be controlled by scaling matrices, translation matrices, rotation matrices, or any other affine transformation.
e. See the document at the GlGeomShapes web page for more information on how to use these.
f. The GlShaderMgr methods lets your program read GLSL shader source code from a file, and compile and link it. This is done by two lines in the InitialProj.cpp file. If you look at the code, you will see how easy GlShaderMgr makes it.
g. (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.
Your grade will be partly on technical merit and partly on artistic/creative merit. So please put a
little thought into designing an attractive scene with some attractive
The “X” demo is rather simplistic to code, and a bit lower in technical merit than desirable; however, it is attractive and thus fairly good on artistic merit. The “S” demo is technically more challenging in its animation as it is hard to make the animation work the way it does; but to be honest, it is not very attractive to look at, so it is weak on artistic merit. For artistic merit, try to do something a little innovative, and different than in the two supplied executables.
Please feel free to talk with a professor or TA (or other students) about creative/artistic aspects for your design.
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 somewhat more complex than the
scene supplied in the sample code rendering an “X”. Try to be a bit artistic
Suggestions: Use primarily the GlGeomSphere. GlGeomTorus, 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 MyInitial.cpp and IntialProj.cpp.
You may optionally 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.
There are creative ways to use the GlGeomShapes. For example, a four-sided cylinder will be rectangular in cross section, so this can be used to make a rectangular block. In addition, they have specialized render commands that render only part of a surface such as just certain parts of a sphere, cylinder or torus. For these features, see the header file (the .h files) for the GlGeomShapes objects.
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 “X” or the
“S”. But, you do not need use the same kind of animation as in the
supplied code. In the “X” example, there is just a pure circular motion. In the
“S” example, 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 or mouse event.
Your animation should run smoothly, not jerkily. A viewer watching it run should be able to see what is happening in the animation.
9. 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.
10. Leave the rectangular base plane the same as it is in the supplied code. Leave the two cylinders in the right front unchanged. These will be changed in Project #4 in a couple weeks. Your finished program should look the same as the supplied demo executable, except the "X” or “S" is replaced by your own creation and with animation of your own design.
11. Write a PDF report and upload it to gradescope. Call it “Project3report.pdf” (This name exactly, same capitalization!) It must have:
a. Your name on the first page, near the upper left corner. If you use different versions of your name, it will help with grading to use the same version in the PDF and on the in-person grading sheet. Please do not include your student ID (for privacy).
b. Next include one or two paragraphs describing your scene, including what is animated. If there are any special ingrediants, please be sure to list that. Special ingredients might include using trig functions or quadrate or cubic polynomials to confrol the animation, or render surfaces with VAO’s and VBO’s and glDrawArrays/glDrawEleements.
c. If the artistic part of the project is inspired by anything, please include that in your project description.
Add a picture or two
(at most three) showing your system. Try to choose a view that shows off all
the elements of your project well, including the animation.
You may create the PDF file in various ways: screen shots (the snipping tool or CNTL-ALT-PRINTSCREEN or FN-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 or google doc: insert your screenshots as images (it is best to use text boxes to hold your images), and then print your document to PDF.
Program grading: Scale of 0 to 20. You may request a personal grading session with a TA or Professor Sam Buss right away. OR, wait and have your project #3 graded together with project #4. It is encouraged to get a personal grading session early in fact, as this may help with your Project #4. This is especially true if you feel like you are having difficulties with either Project 3 or 4. You can see the grading rubric ahead of time.
Individual zoom grading will give an initial score in the range 0-20. The PDF report will be graded offline, and can increase or decrease your project score. Scoring for the PDF and how it affects the project score will be announced separately.