Real-Time Rendering
COSC1226 Assignment

Aerial Assault - By Ross Eldridge, 2107726G

About/Marking Guide | News | Screenshots | Final Report

Final Report

Screenshot

Usage

Compiling the Application

To compile the application from the source file under Linux, change to the 'src'directory and type:
make
The compiled binary will be placed in the parent directory.

Running the Application

To execute the application using the default map, type the following:
./AAGame
To use a custom map, just add the map name:
./AAGame [custom map]

Features

Control

General

ESC - Exits the program.
P - Pauses the game.
W - Toggles wireframe mode.
SPACE - Restarts if your game is over.

+ (Plus key) - Increase throttle.
- (Minus key) - Decrease throttle.

Mouse Button 1 - Fire Twin LASERs
Mouse Button 2 - Fire Mass Driver

Mouse movement controls view direction
Pitch (vertical movement) is inverted, to simulate joystick-style movement.

Playing the Game

Once the game has loaded, you will immediately begin play, flying just above the tops of the terrain. Your ship has incredible maneuverability and has anti-gravity technology. However, it has a minimum throttle of 10%, and will explode instantly upon contact with terrain, buildings or water.

You have two types of armaments at your disposal:

Control of your ship is paramount, so keep an eye on your throttle and altitude gauges. Throttle is controlled with the +/- keys, and acceleration is basically instantaneous, so be aware.

Your mission is to destroy any buildings in your zone, with minimal impact on the terrain. The soil contains precious minerals needed for ship construction. Destroying buildings will result in a positive score, whilst terrain destruction will subtract from your score.

Should you crash, and perish, never fear. We have hundreds of recruits just like you. Press SPACE and a new ship will arrive at your entry point, ready to finish the job.

Terrain

Terrain is rendered with a height map, which is loaded from file at runtime. The terrain is uses per vertex colouring, based on its height from sea level. Terrain is deformable. This is achieved by reducing the Y coordinate value of each vertex when an explosion hits. The amount of damage is based on the cosine of the distance from the explosion centre point.

Collision detection is achieved per polygon, using my own variant of Tomas Moller's algorithm. Optimisation is achieved via a uniform 2D grid, as the X/Z coordinates of a polygon never change. Other methods (such as BSD or octtrees) could not be used, as they would need to be recreated every time the terrain changes. To determine which grid spaces to check, the ray of the particle is rasterised across the grid using a line rasterisation algorithm (based on Xiaolin Wu's anti-aliased line drawing algorithm).

Voxels

Voxels are rendered using hardware distance-attenuated points (using GL_ARB_point_parameters). This is a much faster method than cubes or even billboards as each voxel only passes one vertex to OpenGL (as opposed to 4 or 8). Unfortunately, attenuation is not perfect and varies from system to system, or even from different resolutions. The configuration I ended up using works almost perfectly for ATI video cards. However, nVidia cards do not increase the point size after a certain distance, so when the camera is very close to the buildings they will be able to see through them.

Destruction is done in a similar way to terrain deformation, however, rather than changing Y values the voxel colour is darkened. If the amount damage a voxel has received goes over a certain value, that voxel will no longer be rendered. Thusly you can punch holes in the buildings.

Collision detection is done per-voxel using a ray -> sphere algorithm. To optimise this, each building is bounded by its own bounding sphere, so collisions aren't calculated unless this is breached.

File Formats

The program loads terrain height map data, building voxel data and layout, along with settings for terrain resolution and scale, in a file called 'default.map' in the 'data' subdirectory. If a file is specified at the command line, it will be loaded instead (this is assumed to be in the data directory also).

Map File Format

The file format is text based, and is as follows:
AACONFIG
[terrain bitmap file] [file resolution] [terrain resolution] [grid size] [minimum height] [maximum height]
[building layout file]

AACONFIG - Header, must be present.
[terrain bitmap file] - The name of a greyscale (8bit) BMP file containing the height map data. The bitmap must be square. e.g. height.bmp
[file resolution] - The resolution of the bitmap. If the file is 512x512 pixels, then you would put 512 here.
[terrain resolution] - The resolution of the terrain once loaded. For instance, if this value is set to 64, then there will be 64x64 vertices in the terrain map. This can be any value, the program will resize with a bilinear filter to suit.
[grid size] - The size of each terrain grid cell in world coordinates. e.g. 0.5
[minimum height] - The Y value (height) that a bitmap value of 0 will represent. Set this to a negative value if you want parts of the terrain to be submerged under water.
[maximum height] - The maximum possible height of the terrain, for the bitmap value of 255.
[building layout file] - Specifies the building layout file to use. e.g. city.bul

Building Layout File

The building layout file format is as follows:
BUILDING_DEF
[voxel size]
BUILDINGS
[voxel bitmap file] [x coord] [y coord] [z coord] [z width]
...

BUILDING_DEF - Header, must be present.
[voxel size] - The size of each voxel in world coordinates. This allows you to customise the size of buildings in the map.
BUILDINGS - Another header, antiquated but still necessary. Marks the beginning of the building layout section,
[voxel bitmap file] - The voxel data file to use for this building. e.g. shed1.bmp
[x coord] [y coord] [z coord] - The position of the origin of the building in world coordinates.
[z width] - The bitmap width of the Z portion of the file. See below for more information.

Voxel Bitmap File

This is simply a 24bit BMP file. However as bitmaps are 2D, these files have their own sub-format.

Possible Additions

Given more time, or even given my current knowledege, these are the additions I would like to have made.

Functional

Graphical

Backend

I plan to continue developing this project after the course has completed, so these may still make the cut.