Math 155A - Introduction to Computer Graphics – Fall 2020
Instructor: Sam Buss,  Univ. of California, San Diego

Project #3 – Construct a 3D-Letter (Alphabet Symbol), based on your Initial.
Due date: Friday, October 30, 10: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 artistic merit.
    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.

·       You will again use the shared Google Drive folder named something like 155A_handin_FIRST_LAST where “FIRST” and “LAST” are your first and last name. You will hand in your project 3 files placing them inside the “Project_3” subfolder. Place them directly in this folder, not in any further subfolder. Do not change the names of any files or folders.

·       You will hand in (at least) three files:

o   Any changed source files. The main project source files InitialProj.cpp and MyInitial.cpp.  Also MyInitial.h if it changed. Use exactly these names for your main files!! If you do change any other source file, please place it also in this folder.

o   A PDF file with a report of your work. This include discussion of any consultations/feedback from others. See the instructions below. This will be handed in twice: First, copy it into the shared google drive. Second, also turn it in to Gradescope.

·       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 in zoom office hours, run Visual Studio, and be ready to demo and discuss your project.

·       Also, and this is important: make a copy of all your Project #3 source files, and place them a separate folder for safekeeping. (Files in the Google drive folder also serve this purpose, but we recommend keeping your own 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.

INSTRUCTIONS:

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. (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 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,

c.      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”. 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).

f.      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 do something creative based on your own first initial instead of the "X" or the “S”. However, if you wish, you may use a different letter than your initial.   You must also supply some novel animation. (The supplied programs used “S” for “Sam” and “X” just to choose something else.)

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.     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.

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 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 ajor radius one, and the minor radius can bet set as desired.  Of course, the cylinder’s and totus’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.            

6.     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 animation.
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.

7.     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 somewhat more complex than the scene supplied in the sample code rendering an “X”.  Try to be a bit artistic and creative. 
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 instance, they have specialized render commands that render only part of a surface. A four-sided cylinder will be rectangular in cross section.

8.     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 “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 get 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. Call it “Project3eport.pdf” (This name exactly, same capitalization!) It must have:

a.     Your name and student ID on the first page, near the upper left corner.

b.     Feedback/consultation. Next have a paragraph describing:

                                               i.     Everyone you received feedback from, and the type of feedback they provided. If the feedback was helpful, describe this.

                                             ii.     Everyone you gave feedback to, and the type of feedback you provided.

                                            iii.     Feedback can happen either while you are writing your program (say, if you run into problems), or after your program is finished (say, if you just want someone to check that it looks OK).

                                            iv.     If you get feedback from someone not in the course, please explain.

                                              v.     Your help from feedback should follow the guidelines for academic integrity on the course web: “However, you should definitely NOT: hand in someone else's code as your own, directly copy code from others, or work too closely with one person for the entire quarter. These will be viewed as serious violations of academic integrity. It is OK however to see someone else's code, and then take a short break (say, three minutes) and then write your own version of the code on your own. If you are not sure what is permitted, please talk with a TA or Professor Buss. (Any help you get from a TA or Professor Buss is permitted of course!)

c.      Next include a paragraph describing your scene, including what is animated. If it is inspired by anything, please include that.

d.     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 (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. Please put your name in the PDF, but NOT YOUR PID (for privacy).

Program grading: Scale of 0 to 10.  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 having difficulties with either Project 3 or 4.

Individual zoom grading will give an initial score in the range 0-10. 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.