CSC 240: Computer Graphics

Homework 6: Solar System in OpenGL

Due: Thursday, Nov. 12, 11:59pm on Moodle

The goal of this homework is to put together several important concepts in 3D graphics:

  • Viewing through projection (orthographic vs. perspective)
  • Lighting
  • Hierarchical models

Credit: Joe O'Rourke

Write an OpenGL program that will display an animated, lighted solar system, which consists of (at least) the following components:

Solar system components:

  1. The Sun.

  2. The Earth orbiting the sun.

  3. The Moon orbiting the earth.

  4. The orbital paths should be either circular or elliptic.
Viewing requirements:
  1. Hidden surface removal should be turned on.

  2. Select a viewpoint so that the lighting effects on the planets are noticable. No need to arrange for the camera to move around: one good viewpoint suffices.

  3. The sun, earth, and moon should all be different colors.
Hierarchical modeling requirements:
  1. The motion of the components must be controlled using hierarchical models (use glPushMatrix() and glPopMatrix()).
Lighting requirements:
  1. There should be one (or more) light sources above the plane of rotation, lighting up the entire solar system. Maybe not too bright. Perhaps you will need some ambient component to this source.

  2. The sun itself should be co-located with a light source, so that the sun illuminates the planets as well. (The sun sphere will not block the light from coming out of its interior.)

  3. The sun should be emissive so that it glows (but this does not constitute a light source).

  • It is not essential to make the moon orbit at precisely the correct rate relative to the earth rotating around the sun (although it is not too hard to get it roughly correct.)

  • Suggestion: first draw the components and find a good viewpoint. Then get the animated motion working without lighting effects. After that is working, add the lighting.

  • After this is working, feel free to create a solar system that either incorporates more realistic components (planets, etc), or create a solar system that has nothing to do with reality or physics. I would love to show some examples in class!

  • Submit your code on Moodle.


For this assignment, you are welcome to use pair programming (but please switch frequently!) You can turn in one assignment, or you can get the main code working together and turn in separate extensions or experiments. Let me know if you used this option at the top of your code.


Here is an example of a sun with no emitted light (left) and a sun with emitted light (right). It may not be as dramatic a difference as you're looking for, but it should be different. The only difference between the code for these two examples is one line commented out:

 glMaterialfv(GL_FRONT, GL_EMISSION, mat_emission) 

sun1 sun2