Warheads 3D

Jason Rickwald
(group members: Pete Lawrence and Eric Kwong)


Game Basics
When the program first loads hit Escape to fly to the current player (there are three players). Also, hitting 1, 2, or 3 will fly you to players 1, 2, and 3 respectively. You can navigate the world using the arrow keys and by clicking and dragging the mouse. Remember, Escape will quickly take you back to the current player. Hover over the menu bar on the right to pull it out. Use the arrow keys to set up the trajectory of your shot (this can be seen with the green line coming out of your ship). Give the shot more or less power with the slider (sliding it to the right gives it more power). Hitting FIRE will fire off your shot. The other two buttons will activate a defense that will last until your defense points are back down to 0.

What Didn't Happen (Or What Needs Work)

My major contributions to this project are listed below. Also, any other "minor" contribution that I could think of is at the bottom of the page.


The Planet

Planets In the Scene

figure 1
(figure 1)

figure 2
(figure 2)

figure 3
(figure 3)(that's supposed to be an 'x', not 's')

figure 4
(figure 4)(again, 'x' not 's')

figure 5
(figure 5)

I wrote the entirety of the planet code.

The planet begins its life as 8 triangles in the configuration seen in Figure 1. These triangles are the roots for 8 binary triangle trees. The trees are subdivided down to some preset detail, and at each split the new vertex is pushed out to where it should be on the unit sphere.

Next, we didn't want the planets to just be smooth spheres, so I used a Fault Terrain Generation algorithm to produce some irregularity in the planets. It works by finding random planes that cut through the sphere (See Figure 2) and pushing out all points on one side of the plane while pulling in all points on the other. Doing this enough times gives a fairly nice looking planet.

The material at a vertex of the planet is based on its distance from the center of the planet. The materials between snow, grass, water, dirt, glowing mantle, and black core.

Making the planet out of binary triangle trees was very beneficial for collision detection. First the radius is checked for the planet. If the object is outside of the radius we just dismiss it. If it is within the radius we find the closest binary triangle tree, then work down through the tree until we have the triangle that is closest to the object. Finally, we do a sphere-plane intersection test between the object and the triangle. This method is fast and works correctly for objects that fly into craters.
* We did notice a collision detection bug that would only seem to happen with fast moving projectiles (the projectile would fly right through the planet and usually explode on the other side). We didn't have time to look into it, but I believe it has something to do with the speed of the projectile and its small radius.

We wanted the planet to be deformable (craters after explosions), so I had to write code to do this. The code is relatively simple, but could use some more tweaking. You pass it the location and radius of a sphere. It will find all the vertices of the planet that are inside that sphere an push them to an approximation of the curvature of that sphere (see Figure 4). You can see screenshots of my initial tests of this code in Figure 5. However, we ran into a bug early on where if the explosion was positioned below the surface of the planet the planet would grow a "tumor" instead of developing a crater. This was quickly dealt with by first adding a step that moved the center of the explosion sphere to the planet vertex closest to it (see Figure 3).

Some pictures of in-game craters can be seen in Figures 6, 7, and 8. Also in Figure 7 some of the glowing mantle can be seen.

figure 6
(figure 6)

 

figure 7
(figure 7)

figure 8

(figure 8)


The Explosion

The Explosion

The explosion is simply an interesting combination of GLU primitives. These primitives are: a large sphere with a size that grows and shrinks with time which acts as the main blast, a torus with a radius that grows with time that acts as a shock wave, and forty small spheres that act as "debris." The torus starts its growth very quickly, and then falls off. It is also oriented on a random plane. Similarly, the debris explode outward very fast at first, and then their speed falls off. Also, each piece of debris is given a random trajectory and initial velocity (within a range).

All parts of the explosion start out with a red color, and then turn yellow with time. Also, the main explosion sphere and the shock wave alpha fade in at the beginning of the explosion and then fade out at the end. Screenshots of the explosion can be seen above or below in Figure 9 (though it may be hard to see the debris against the starry background).

As a final effect I added a "screen shake" effect in the camera that is based on a variable in the explosion. An explosion will cause a violent shake in the camera that dies off as the explosion itself dies off. I believe it is this effect that really makes the explosion impressive ;).

figure 9
(figure 9)

The Spaceships

Blobby
"Blobby"
Firefly
"Firefly"
Steve
"Steve"

 

figure 10
(figure 10)

I used Milkshape to make three Spaceship models for use in our game (pictured above). I then used a converter to turn those models right into C code for OpenGL, so we were able to hard code all three models right into display lists with no loading time from a file.

I also wrote code that displays a ship's name and stats above and below it. This text can be turned off and on.

Next, I created a simple "shield" aura that can be turned on and off if a defense is in use. There are two colours for it -- blue and red. If on, the shield aura fades in and out with time. See Figure 10.

Lastly, I took Pete's gravity code and incorporated it into the ship's step function for when the ship is launched off of its planet. This can be turned on and off. Also, I wrote code that will rotate the ship "out of control" if the gravity code is turned on. You can see a ship flying freely in-game in Figure 11.

figure 11
(figure 11)


The Other Stuff

Other contributions include:

  • Writing the initial skeleton code for the project.
  • Writing most (if not all) of the game logic. The game logic is still incomplete, though, due to time constraints.
  • Making a model for the weapon projectile (similar process to the Spaceships above).
  • Writing code to orient the weapon projectile in the direction that it is traveling. See Figure 12.
  • Incorporating all modifications to the projectile into the sub-projectile.
  • Helping to debug numerous glitches.
figure 12
(figure 12)