|
Computer Graphics |
Fall 2000
|
Computer Graphics
Homework 09
6 hours
Copyright © 2000 David C. Banks

Run "insight" on the SGI. Select the OpenGL Programmer's Manual and skim over chapter 2 (state management and drawing geometric objects) and chapter 9 (texture mapping). Copy the sample programs in chapter 9. Compile. Run. Take snapshots and put them on your Web page. Don't bother to tar/gzip the sample programs.
You will use your own texture file and apply it to a sphere.
Use one of your first assignments that produced a ppm file. Read the file into an array for OpenGL to use. Create a sphere from triangles (be careful about the degenerate quadrilaterals at the north and south poles), preferably from the code you wrote for the previous assignment. Make the texture filename be a command line parameter. To create your (s,t) texture coordinates with s and t each in the interval [0,1], let s=phi/pi, and let t=theta/(2pi).
Note that OpenGL wants the texture to have dimensions that are powers of 2, such as a 128x64 image.
Tar and gzip your code, documentation, and Makefile. Include a description of how to run your program, giving a sample invocation (with command line flags) that works. Put images on your Web page.
Create (or find) a sequence of images, then texture-map them onto some spheres. Your program should expect a sequence of images to have names like texture.000.ppm texture.001.ppm .. or hurricane.000.ppm hurricane.001.ppm .. and so forth. Tar and gzip your code, documentation, and Makefile. Include a description of how to run your program, giving a sample invocation (with command line flags) that actually works. Make the spheres orbit around a point and revolve as they go. Put images/animations on your Web page.
Read the OpenGL Programmer's Manual, chapter 3 (Viewing), especially the section at the end on Manipulating the Matrix Stacks. The idea is to rotate/translate/rotate and draw a body such as a planet. The vertices of the planet will be transformed like this:
p = M*p
where M is the current transformation matrix. The moon's vertices will be transformed by
p = M * R*T*R*p
where R*T*R is the rotate/translate/rotate for the moon. When you glPushMatrix(), you make a copy of matrix M to use temporarily for the moon. After drawing the moon, you glPopMatrix() to clear out the residual matrix-junk that moved the moon around, leaving the matrix M back on top of the matrix stack. Then you push the matrix down the stack in order to transform the next moon. And the next, looping over all the moons.
Since the planets are satellites of the sun, and moons are satellites of the planets, you should make a recursive call in your code. Create a C++ class that stores the number of satellites a body has, pointers to the satellite objects, and member variables with the body's rotation rate, radius, distance from its parent, and orbit rate. You will use the orbit rates for the rotations, and the distance for a translation. A method like body.update(float timeStep) will update the position of a body using the current time step, and then will call the body.satellite[i].update(timeStep) method for each of the body.numSatellites satellites belonging to the body.
Apply textures to spheres for the inner planets and their moons, then put them in orbit. Here is some data for the size, orbit, and rotation of these planets. 1 AU = 149,597,870 km.
average body's orbit's body's
distance radius year rotation
Body (AU) (km) (days) (days)
------- ----------- ------ ------- ---------
Sun 0.0 695990 0.0 30
Mercury 0.38709893 2439 87.97 58.6
Venus 0.72333199 6052 224.7 -243
Earth 1.00000011 6378 365.26 0.997
Mars 1.52366231 3389 687 1.02
Here is some data for the moons.
average orbit moon
planet.moon distance period radius
(1000km) (days) (km)
----------- --------- ------- ------
Earth.Moon 384.40 27.322 1737
Mars.Phobos 9.38 0.319 11
Mars.Deimos 23.46 1.262 6
Put images/animations on your Web page. Link to your code and documentation (but not to your copy of the textures).
Model the entire solar system. Here are some links for data. Search the Web for more. Overview. NASA. Planets. Satellites. Texture maps. More textures.
Put images/animations on your Web page. Link your code/documentation (but not your textures -- the README will describe where to fetch them and how to convert them for your program to use).
Model the entire solar system, but use Open Inventor rather than OpenGL. Use the SoWriteAction to generate a .iv file. Convert it to VRML. Put it on your Web page.