Program 4

Description: Implement a 3D moonlander game. Extend the fractal subdivision routines from Program
3 to 3D (details will be mailed to the class list). Essentially, the terrain will end up being a set of 3D
triangles. The terrain should be lit with a light located above it. Lighting is to be computed in the
following way: for each element in the terrain, compute its normal, and the intensity for the element will
be the absolute value of the dot product of (unit!) vector to the light with the (unit!) normal.

For this assignment, there will be two views. On the left, draw a top view of the terrain. On the right,
draw a side view. In the top view, indicate the location of the landing area with a box, indicate the ship's
position, and draw the projection of the 3D terrain onto the x-z plane. In the side view, draw the ship as
in Program 3, and draw the projection of the 3D terrain onto the x-y plane. Since triangles will overlap
in this projection, you will need to draw the triangles in order of depth so that farther away triangles do
not cover nearer triangles. Likewise, the ship will need to be drawn according to its depth (so that it is
drawn on top of triangles that are farther away, but is covered by triangles which are closer.)

The ship appears at the top of the screen, and the user's job is to safely land the ship on a landing area,
which should be randomly placed within the terrain below. Gravity affects the ship, so it will begin to
fall unless thrust is applied in the opposite direction. For this game, the ship should not rotate, but the
user should be able to move the ship upwards by applying thrust downward, or left, right, backwards and
forwards by applying thrust in the appropriate directions. The ship should be affected by drag [due to air
resistance] which serves to decrease velocity in the direction of travel.

If the ship does not land in the landing area, or does not slow to within a certain threshold speed, then it
crashes. You are working in 3D now, so make sure to do 3D intersection calculations. The user should
be allowed to play again. Display the current speed [magnitude of the velocity] somewhere on the
screen, along with the maximum allowable landing speed.

The viewing area should be cylindrical, meaning that the left side wraps to the right (and vice versa), but
not top to bottom.

A sample solution will be available in ~cs431/Program4. Please look to this solution to resolve any
ambiguities which exist in the text above.

What to turn in: You should turn in the source code for your java applet, and it should be named
'Program4.html' and 'Program4.java'. Other .java files can be turned in as well, but your main program
should be in 'Program4.java'. We will compile and run your applet using javac and appletviewer so
there is no need to turn in any. class files. Make sure your program compiles before you turn it in--we
cannot grade something that does not compile.
Note: Don't just rename your program and turn it in -- it won't work. Java must have the filename be
the same as the class name of the class in the file. It's best to develop your program using the name
'Program4.java'.

How to turn it in: Use the following command:
handin cs431 program4 [files]

shirley at cs.utah.edu
wmartin at cs.utah.edu
rgraham at cs.utah.edu
1