Spectre : An OpenGL 3D Tank Game

Rory Strawther

CPE 471 Final Project

Winter 2004

Spectre pays homage to an old Macintosh 3D tank game of the same name. Now I am able to build it with a widely used graphics API and modern acceleration hardware.

The premise of Spectre is very simple. You drive your tank around in the arena trying to destroy your opponent. The arena is flat with objects placed throughout it. Gravity does affect the projectile. Therefore, the cannon can be elevated to vary the range of the projectile. Three direct hits or six close hits will destroy a tank. The point of view is from the cannon. The camera will elevate with the cannon. When a tank is destroyed, it will sink below the ground. To play again, press 'R' to reset the game.






User Controls:

W : Forward
S : Back
A : Turn Left
D : Turn Right
O : Raise the Cannon
L : Lower the Cannon
Space : Fire
R : Reset
Q : Quit

Design Challenges:

Mesh file for the tank and other objects-
I had to design my own mesh file to contain all the data for objects that I would need. It needed the basics such as vertex and face information, as well as texel information for UV mapping. I decided early on that only one file can be associated with a particular texture map. However, a texture map may contain more than one object. This necessitated the ability to include multiple objects in a single file. It is also possible to include many texture maps in that one file. With such a flexible format, I can include the entire arena in just one file.






There was no existing file for a tank that I wanted to use, so I designed the tank from scratch. I initially drew out a design for a simple tank that would not have too many faces in it. I plotted out where all the vertices were and then created faces.






Sketch of the Tank



Tank Texture-
My friend was kind enough to recreate the tank in the 3D package LightWave and generate a uv map layout for me. I used this layout to determine the texel information associated with a particular pixel. I also then used Photoshop to design the texture on top of the layout.






UV Map Layout








UV Texture Map



This project was a lot of work since I had to figure out a lot of the details for the tank by hand. I did not use a 3D modeling application like Studio Max and then import it into my game. I wish I could.

Example of mesh file:
;3D Tank Mesh
#Header
2
1
#Header_End
#Textures
tankUV.bmp
#Object
#Vertex_Count
94
#Face_Count
144
#Bounding_Box
8.75
-5.125
5.125
6.5
-7
7.5
0
#Vertices
;Top of turret
;Vertex 1
-1.0
7.5
1
;Vertex 2
-1.0
7.5
-1.5
...
; END OF VERTICES
#Faces
;Turret Top
;Face 1
1
3
2
;Face 2
1
4
3
;Turret sides
;Face 3
1
6
5
;Face 4
1
7
6
...
; End of Faces
#UV_Map
;Face 1
0
479
158
581
282
479
282
;Face 2
0
479
158
581
158
581
282
;Face 3
0
479
158
419
36
478
3