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

Project #2 – Modify Solar System program by adding a Binary Sun, a lunar lander, a moonlet, an ice cap, and a tilt.

Due date: Friday, October 23, 2020; 10:00pm.

Goals:  Learn more about how to use OpenGL, interrupt-driven programming, animation, and transformations. Program some additions to an animated solar system.  Use OpenGL commands to generate transformations that control the animation. 

What to hand in:  

(1)   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 2 files placing them inside the “Project_2” subfolder. Place them directly in this folder, not in any further subfolder. Do not change the names of any files or folders.

(2)   You will hand in (at least) two files:

a.      The main project source file SolarProj.cpp. Use exactly this name for your main program!! This should be the only file you alter for your project. However, if you do change any other source file, please place it also in this folder.

b.      A PDF file with a report of your work. This include discussion of any consultations/feedback from others. See the instructions below.

Special consultation/feedback credit: You will receive a small amount of credit if you consult with other students, the professor or a TA before you hand in your program.  How this works: List anyone whom you showed your code or your running program to and who looked at it meaningfully and gave you feedback on your project. Describe what kind of feedback they gave you. Conversely: List anyone whose code and/or running program you looked at and describe what kind of feedback or suggestions you gave them.  For full credit for consultation, get feedback from or give feedback to at least two people.

Grading will be personalized in a one-on-one zoom session with one of the TAs Ruihan Yang or Nicholas Sieger or with Professor Sam Buss.  You will have to discuss your source code, run the program, make changes on the spot to your program and recompile as requested by the grader, and be able to explain how your program works and why it renders what it does.  The grading should be completed promptly, preferably no later than the due date for the next programming assignment.

FOR PROJECT #2, PLEASE DO THE FOLLOWING STEPS #1 - #13.

1.      As preparatory work, you can look at the SimpleAnimModern and SolarModern programs, available at the textbook’s website and the accompanying webpages explaining how the code works. (Some of this you do not need to know for Project #2, notably the use of the projection matrix for perspective). Project #2 asks you to modify the program SolarModern.

2.      Download the SolarModern project from the textbook’s web page.

a.      There are three core source files: SolarModern.cpp and two source files SolarMgrSLR.h and SolarMgrSLR.cpp. The only source file you will change for Project #2 is SolarModern.cpp. Start by renaming it be called SolarProj.cpp. (Use this name EXACTLY, including the same capitalization.)

b.     Download the five files LinearR3.cpp, LinearR3.h, LinearR4.cpp, LinearR4.h, and MathMisc.h.  There is a link on the textbook’s webpage to download these five (5) files, under GlLinearMath. You will NOT need to change these five files.

c.      Download the four files GlGeomSphere.cpp and GlGeomSphere.h and GlGeomBase.cpp and GlGeomBase.h.  There is another link to the GlGeomShapes project to download these files. You also will NOT need to change these four files. You do not need to get the other GlGeom* files in the GlGeomShapes project.

d.     The ZIP file F2020_Project2File.zip contains an executable file SolarDemo2020Fall.exe. This shows, approximately, what your solution for Project #2 should look like.

e.      Form a new Visual Studio C++ project called (say) SolarProject.  Put all 12 source files into this new project. Include GLEW and GLFW files if needed on your system.  It should now be able to compile and run.

3.      Understand the code in the SolarModern program. Read the online documentation of the SolarModern program. Compile and run the program. You may find the solar program runs way too fast or too slow, so that the earth and moon zip around their orbits many times per second.  If so, you can press up/down arrow keys to adjust the speed. (Or, set the initial value for the variable AnimateIncrement smaller or larger. Test out the keyboard controls:

a.      You will see a very simple solar system (in SolarModern) with a central yellow sun, a blue planet (Earth) rotating on its axis once every 24 hours and revolving around the sun every 365 days, and a moon revolving around the Earth 12 times per year.

b.      Pressing the up and down arrows will change the animation step size. Pressing the up arrow makes the animation run faster by taking bigger time steps each time the solar system is rendered. Pressing the down arrow makes it run more slowly.

c.      Pressing “r” will start and stop the animation.

d.      Pressing “s” will put the program in “single step” mode so that the animation steps one time frame each time “s” is pressed.

e.      Pressing “c” will toggle the culling of backfaces.

f.       Examine the code in SolarSModern.cpp, to understand how it makes items a.-e. work. There are variables HourOfDay, DayOfYear, and AnimateIncrement. Find all their occurrences in the source code, and understand how they are being used an updated. Also understand how the spinMode and singleStep variables are used to control the animation.

g.      Compare the starter code in SolarModern.cpp to the reference executable, SolarDemo2020.exe: SolarDemo2020.exe has

                                                    i.     A binary sun,

                                                  ii.     Earth and moon as before (but with orbits and sizes adjusted)

                                                 iii.     A small red sphere on the back side of the moon at approximately the location of the Change’e 4 lunar lander..

                                                 iv.     A second, bright magenta, planet (Planet X) in a retrograde orbit around the sun

                                                   v.     A polar ice cap above the north pole, and

                                                 vi.     The earth system (earth, moon, lander and icecaps) is tilted, similar to the tilt of the real Earth that causes the seasons.

h.      You should understand the callback-driven style of the program, and how the keyboard controls are handled by the program, and when myRenderScene is called. But you will not change this part of the code.

i.       The GlGeomSphere objects are used to render the spheres. This handles all the work of creating and drawing the VAO and VBO (and EBO), for the spheres.

j.       When the program first starts, aliasing causes the planet to appear to not be rotating, but instead always keeping the same face to the sun.   Slow down the animation (down arrow keys) to see the "true" motion.  Figure out why the animation code makes this happen.  Understand what was meant by "aliasing" three sentences ago. (We will discuss this in a zoom class meeting; or you may discuss on piazza.) 

4.      The “demo” executable, “SolarDemoFall2020.exe, in the zip file shows what your Project #2 should look like (approximately) when you are finished with the steps 4-13 below. It is suggested to add features one-by-one. That way, if you do not finish everything, you still have a nice project when you reach the time limit.

5.      Change the sun to be a binary sun.  The two suns revolve around the center of the solar system. You may set their orbital rate to look good, say similar to the orbital rate in the demo code. You should also adjust the distance between the suns and the size of the suns so that they look good. 

6.      Add a red sphere marking the approximate location of the Change’e 4 lunar lander.  This is on a fixed location on the moon. It is approximately directly away from the earth, but 45 degrees south (below the equator of the moon).  (Lunar longitude is 180 degrees, latitude is 45 degrees, south). If you slow down the motion (using down arrow), you can see the lander more clearly. This will let you see that the moon is always facing the same way towards the earth.

7.      Add a “Planet X”, a second planet orbiting the Sun.  Planet X should orbit the Sun once every 600 days (that is, once every 600 Earth days). In the SolarDemo program, Planet X is magenta, but you may use whatever color you like. Planet X does not rotate on its axis.  Hint: Since the PlanetX year is a different length than the earth’s year, Planet X’s “day of year” will be different from the “day of year” of the earth. You will need an extra variable for this; for example, named “DayOfYearX”.

8.      Add a tilt to the earth, of about 24 degrees. This tilts the earth and its moon system, but not the orbital path of the earth. It is similar to the tilt that causes the seasons of the real earth. The tilt is always rightward in the scene.  We will discuss in lecture some hints for how to do this; see also item 10 below.
The perspective in the Solar program can make it hard to see the tilt well: The tilt will easier to see you change the ViewAzimuth variable to equal 0.0 instead of 0.25 radians, so that you are viewing the solar system directly from the side.

9.      As part of steps 4-8, adjust the orbital radii, the orbital rates, view distance, colors, etc. Make changes to the sizes of the suns, planets and moons and to the radii of the orbits, so as to make viewing the solar system convenient.  (You may need to adjust the values of Xmax, Ymax, Znear, Zfar.)  Choose colors that make all planets and moons, the lander and the icecaps clearly visible and distinguishable. You do not need to match the supplied demo program.

10.   Hints for the tilt: This probably the hardest part, because the natural way to do this is tilt the earth before revolving it around the sun, and then the revolving around the sun affects the direction of the tilt.  There are several ways to make this work. One way is to make the tilt on the earth’s system be applied along a different axis than the z-axis, chosen to make the final tilt come out right.   A second way, perhaps better, is to instead of using a translation plus a rotation to revolve the earth around the sun, just use a single translation to move the earth to the correct location (as calculated with the aid of sine and cosine functions). In either case, implement the tilt so that an inhabitant of the earth still sees 365 days during each earth year. (There are other ways to implement the tilt besides these two suggestions.)

11.   Polar ice caps. Make a white triangle fan placed above the earth. It should be above the north pole and should tilt with the earth. The suggestion is to use a triangle fan with six triangles, and let it float a little off the surface of the earth. The front faces of the ice cap’s triangles should be upward, away from the earth. You will need to slow down the animation to see the relative motion of the ice caps and the earth without aliasing causing false motion.

12.   Turn in all changed source files to your shared Google drive folder, in the subfolder Project_2. This should be only the file SolarProj.cpp, and please use exactly this file name.

13.   Write a PDF report, and also place it the same folder. Call it “Project2report.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.      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.      If you have any comments for the TA and Professor about your project, please include them after the paragraph about feedback. For instance, let us know if some parts seem confusing, or you think they may not be implemented correctly, etc.

d.      Add a picture showing your system. Try to choose a view that shows off all the elements of your project well, including the tilt.

Program grading: Scale of 0 to 10.  Personal zoom grading session with one of the TAs or Professor Sam Buss. For grading, be ready to discuss any of the above topics, plus be prepared to make small modifications to the source code and recompile.