CS40 Project 4: 3D Coordinate transforms

Due 11:59pm Tuesday 30 September 2014

For this lab, you will be modeling and animating entire solar system, using coordinate transformations. Mostly you will be making judicious use of Translations, Scalings, and Rotations, to work in different frames.

Getting started
Use the setup40 script to set up the appropriate git repos with the right permissions set for partners and instructors. Suppose users molly and tejas which to work together. Molly can start by running
[~]$ setup40 projects/04 tejas
Once the script finishes, Tejas should run
[~]$ setup40 projects/04 molly
Please note that the script tries its best to ease the initial creation and cloning of git repos and it tries to be smart and check that each partner agrees that they are partners. That said, there are some race conditions and if there are uncooperative formations of partners, the script and the instructor will get confused. If you play nice with the script, it will play nice with you.

If all goes well, Tejas and Molly should each have a local clone of a common git repo in their own ~cs40/projects/04 directory. You can use git status to confirm this.

If you wish to work by yourself (not recommended), use the syntax

[~]$ setup40 projects/04 none
Copying starter code
Both partners should modify their own ~/cs40/projects/CMakeLists.txt as this file is not under version control. Just add the line
add_subdirectory(04)
to the end of the file and save.

For the next step only one partner should copy over the starting code

[~]$ cd ~/cs40/projects/04
[04]$ cp ~adanner/public/cs40/projects/04/* ./
Now push the changes to your partner
[04]$ git add *.h *.cpp *.glsl *.txt *.ui
[04]$ git commit -m "project4 start"
[04]$ git push
Even if your are working by yourself, you must run git push or I can't see/grade your work. If you are working with a partner, your partner can now pull the changes. In this case if Tejas wishes to get files Molly pushed, he would run
[~]$ cd ~/cs40/projects/04
[04]$ git pull

You may need to symlink the textures folder to a local data directory. If you expect to see textures, but you don't, add the following link in your build directory.


cd ~/cs40/projects/build/04
ln -s /usr/local/doc/textures/ data
Data
The file solarData.txt in your projects/04 folder contains some basic info about our solar system (and Pluto, which has recently been disqualified). The information contains the radius of each object (in thousands of km), the distance from the sun ($a$, in millions of km), the period of rotation around the sun ($\tau$, in earth years), the eccentricity of the elliptical orbit, and the inclination of the orbit with respect to a plane through the center of the sun. You should use this information to model a solar system as a collection of rotating spheres.

You can parse this data file using code similar to that in parseData.cpp, or MyPanelOpenGL::parsePlanets.

Basic Requirements
You will need to find an acceptable coordinate system in which to draw your system. I recommend scaling the radii of the objects so they look visually appealing and convey some sense of relative scale. Feel free to adjust the sun (and perhaps the larger outer planets) differently than the rest. The sun is really big. After adjusting the radius field, you should be able to use the rest of the units as they are.

You must create a planet class or planet struct to organize necessary planet info. I have provided a sample class in planet.h/.cpp, but feel free to modify this or write a completely separate data structure.

You must draw and animate all the planets listed. All planets should revolve in the same direction around the sun, but not at the same rate. You may assume the planets revolve in circular orbits, but the eccentricity is given if you want to model elliptical orbits.

All planets should spin about their axis according to the time of day. You will likely want a way to speed up and slow down time so you can observe spinning and orbiting as desired.

Assign a texture to each of the planets. You may want to add these parameters to the data file, so you can refresh them without recompiling.

You must model at least one moon around one of the planets. You can choose the size of the moon, radius of orbit, and period of rotation, or consult a source for reasonable defaults. You can use the same moon texture for all moons, use a separate fragment shader, or modify your fragment shader to support textured and non-textured spheres.

Add keyboard controls to pan and zoom. You can decide how this is implemented. You should modify the m_view matrix when you do this.

Hints/Tips

You can use the Sphere class to model the planets. Note, you do not need to create multiple Sphere instances. You can reuse the same VBO and apply different transforms to the shader before drawing each planet.

Work incrementally. Get your data file parser working and then print out the info each planet to ensure you parsed the data correctly. Make subtle adjustments to the m_view matrix using QMatrix4x4::ortho, or until you understand what you are looking out and how the scene is effected.

Explore the MatrixStack class and try some examples in PaintGL with multiple objects.

You can use any of the QMatrix4x4 methods. Methods like translate, rotate and scale, modify an existing matrix, by multiplying it on the right.

Each planet/moon can have its own uniform model matrix in the vertex shader. You should probably only use one view matrix for the entire system.

Use the Square to help orient you if you find yourself getting lost.

Use a QTimer to animate. Do not try to maintain a global 'time'. Instead, each time the QTimer triggers, consider that $\Delta_t$ time has elapsed in the solar system. Pass this $\Delta$ to each planet so they can update their spin and rotation appropriately.

Optional features
The following are optional extensions and are not required for full credit.
Submit
You should regularly commit your changes to the project4 branch and occasionally push to your private remote. Note you must push to your remote to share updates with your partner. Ideally you should commit changes at the end of every session of working on the project. You will be graded on work that appears in your remote project4 branch by the project deadline