A small orrery
in OpenGL
In this assignment you should use OpenGL to animate the movement of the
Earth and Moon around the Sun. To increase the level of realism you
should use light and use textures for the Earth and Moon. Your code
should behave something like my example: /chalmers/groups/thomas_math/VIS/OpenGL/run_orrery . If
you are using KDE and not Gnome, you need to hit the return key, with
the mouse in the window, to start the animation (it seems).
Note the following:
- You can increase the speed of the rotation by pressing + (several
times) and decrease it by typing - (with the mouse in the
OpenGL-window).
- There is a menu with three alternatives (Full light, Darkness,
Quit). Try it!
- Using textures is not
compulsory. If you do not use textures, the Sun, Earth and Moon should
have different colours (and your program should still use light). Also,
use few polygons for the spheres, so that the rotation is visible.
The physics does not have to be correct, but your program should do
the following (to force you to learn OpenGL):
- Take the tilt of the Earth axis into account. The tilt is
approximately
23.4°.
- Assume that the Earth makes a complete revolution around its on
axis in one time unit (corresponds to a day), and around the Sun in 365
time units. Assume that the Moon needs 30 time units to go around the
Earth. Make sure that the Earth rotates in the correct direction.
- You may assume that both the Earth and the Moon travel in
circular paths and in the same plane.
- The Moon keeps the same face turned to the Earth at all times due
to the tides (tidal locking). Make sure your program shows the correct
side.
- The relative sizes of Earth and Moon do not have to be correct,
but if you want to use it, the quotient between the diameters is
roughly 3.7. You may assume that the bodies have a spherical shape. Do not forget to set the normals
and the texture coordinates. Note that glutSolidSphere does not set texture coordinates.
- To make the textures look nice (to avoid flicker) you need to
build mipmaps (gluBuild2DMipmaps).
Also set the GL_TEXTURE_MIN_FILTER
to GL_LINEAR_MIPMAP_NEAREST
(which I thought looked best).
- There should be some stars (but they do not have to correspond to
real constellations).
- When one has chosen Darkness from the menu, the light should
appear to come from the Sun.
- The spheres should not deform if we change the proportions of the
window.
- Your program does not
have to consider shadows.
- For more data you can use Wikipedia, Earth, Moon.
Under /chalmers/groups/thomas_math/VIS/OpenGL
you find two textures, earth.ppm
and moon.ppm that you can
use. The images have the same format, width = 640 and height = 320. The
files consist of a four line header followed by 204800 (= 640 x
320) rows with an RGB-triple per
row. The files are in human readable form, so you can inspect them. To
see the image you can use xv,
for example. Type xv earth.ppm
.
These textures were produced by projecting the surface of the bodies
on a flat surface, so when we make the inverse transformation, the
result should be reasonable (no major distortion). I fetched the
textures several years ago (from NASA I think). If you would prefer a
cloudy Earth, there are several such textures available
on the web.
