# CS40 Lab 3: 3D Coordinate transforms

Due 11:59pm Tuesday 24 February 2009
You may work with one partner on this assignment. For this lab, you will be writing code from scratch, but you can use the planet.c example in w04-transforms as a possible starting point. You will be modeling an entire solar system, using coordinate transformations. Mostly you will be making judicious use of glTranslatef, glRotatef, glPopMatrix, glPushMatrix, to work in different coordinate systems.
Data
The file solarData.txt in your labs/03 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.
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.

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. You can use glutSolidSphere to model the planets

Assign a color 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 should enable double buffering as well as the depth buffer. Code samples will demonstrate how to enable these features.

Add keyboard controls to pan and zoom. You can decide how this is implemented. Remember you can change either the projection or model view.

Hints/Tips
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 GL_PROJECTION matrix using gluPerspective, glOrtho, or glFrustrum until you understand what you are looking out and how the scene is effected.
Optional features
The following are optional extensions and are not required for full credit.
• Model the orbits as ellipses. See pdf notes on elliptical orbits. Create a highly eccentric orbit (a comet maybe?) to see the effect enhanced
• Model rings around Saturn or another planet
• Design a small 3D spaceship and put it in orbit around a planet, or launch it from one planet to the other. To be visible, the spaceship would actually have to be roughly the same size a a planet, which is not a very small spaceship.
• Draw lines to indicate the path of the orbits. See documentation on glEnable(GL_LINE_STIPPLE) and glLineStipple(...) for drawing dotted or dashed lines
• Have the camera follow the path of a planet
Submit
Once you are satisfied with your programs, hand them in by typing handin40 at the unix prompt. You may run handin40 as many times as you like, and only the most recent submission will be recorded. This is useful if you realize after handing in some programs that you'd like to make a few more changes to them.