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

Project #3 – Construct a 3D-Letter (Alphabet Symbol), based on your Initial.
Due date: Friday, February 1, 9: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. 
    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 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, 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 subject to a point deduction).

o   You must upload your main source file, called MyInitial.ccp. 

o   You must upload a PDF document, one or two pages long, showing two (or 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.

INSTRUCTIONS:

1.      Download the file InitialProj.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. The full URL for the zip file is:
http://www.math.ucsd.edu/~sbuss/CourseWeb/Math155A_2019Winter/Project_3/InitialProj.zip.)

2.      Run the two executables (InitialProg.exe and InitialProj2018.exe) on a PC. (If you are not on a PC, you can build InitialProg.exe with the source code supplied, as described below.) 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 both 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, with a revolving ellipse;
or an “S” shape formed with cylinders and ellipsoids with an animation in the middle of “S”.

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

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

4.      Form a new project and solution.  You must collect the following sixteen source files. 

a.      The four (4) C++ sources LetterProj.[cpp,.h] and MyInitial.[cpp,h] in the zip file.

b.      The GLSL source file InitialProj.glsl from the zip file.

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 four (4) C++ files GlGeomSphere.[cpp,h] and GlGeomCylinder.[cpp,h]. The two for GlGeomSphere program you used already for the Solar program – it draws unit spheres centered at the origin. The two new ones, for GlGeomCylinder, draw cylinders of height two and radius 1, centered at the origin.

f.       Include the all fifteen (15) source files into your new C++ project. There are 15 source files (seven .cpp files and eight 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 to placeholder cylinders, and makes an “X” shape from cylinders 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 Solution files.

h.      You may add the InitialProj.glsl file to the project if you wish: it doesn’t make much difference, but it does make it convenient to look at the code in Visual Studio.

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

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, rotation matrices, or any other affine transformation.

e.      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 LetterProj.cpp file.  If you look at the code, you will see how easyi GlShaderMgr makes it.

f.       (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 creative 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 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 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 LetterProj.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. 

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 “S”. But, 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.

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

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

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