Gerard Pace - 2007528V

3D Games and Real Time Rendering

S2000 Challenge

Good picture

Introduction

S2000 challenge is a racing game inspired by the Micromachines game for Playstation, with other influences from some old rally arcade games. I decided to use Honda's S2000 as the basis of this game because it is one of the most powerful and nimble cars of its size in the world. Since I designed my game to be fast paced and high action, a car of the S2000's caliber seemed appropriate.

The game is a one or two player game, with an emphasis on the two player mode. The two players race against each other on the same screen with the camera initially positioned behind them. The goal is to either get ahead of your opponent by a predefined distance, or knock them off the track. Every time this happens, the player who either got ahead or stayed on the track wins a point. Both players are then respawned next to each other to battle for the next point.

Different tracks are available, as well as different camera modes which can be changed while the game is in progress.



Design and Implementation

Car

Polygon Mesh

The car model is made up of a polygon mesh that is texture mapped against photos of an S2000 toy car. I manually took the photographs of the car, then calculated the points for the polygon map and the corresponding points for the texture mapping. This was quite a time consuming task however I am quite happy with the result.

Good picture

Forces

The forces acting on the car at any one time are Acceleration, Friction, Gravity, Normal, Collision and Turning. These forces are calculated at every time interval, and the velocity and consequently position of the car are also updated every time interval. This provides a realistically looking movement along the track and in the air. I have used the proper physics laws in all force calculations rather than the simpler method of ignoring forces and just dealing with velocity as was done in Assignment 1 Part B. I did this as I wanted a more realistic motion for the car traveling along the ground. A number of the forces impacting on the car can be seen in vector form above the car by pressing F5.

Good picture


Track

Polygon Mesh

Tracks begin life as a data file that contains the number of corners in the track and the co-ordinates for each corner. Initially, when first developing the game I used these data files as the tracks themselves, however, they were very unattractive as all the corners were sharp and everything was straight. This also meant that when a car hit a sharp bump, it bounced unrealistically. I therefore decided to make a smoothing program, smoother.cpp. This program takes the data from a .data file, and smooths it to a level defined on the command line to a .trk file. The .trk file has many more points on the mesh of the track which results in softer slopes and corners and better shading due to an increase in the number of normals. The track can be displayed with the normals and segments visible.

Good picture

Forces

The track places a normal force on both of the cars in the game. The track first determines if the car is on a segment of the track. If so, the velocity vector of the car is tested against the normal of the track. If it is pointing in the same direction (that is the angle between the two is greater than -PI and less than PI), then a large normal force is set, otherwise a smaller force is set. This ensures that the collision is inelastic as energy is lost when the car falls from a height to the track. If this did not occur the car would keep bouncing and never come to rest.


Collision Detection

Collision Detection was done with a version bounding boxes. Each bounding box was made up of eight points, twelve rays and six planes. The yaw, roll and pitch of the car was taken into account when comparing the bounding boxes. The tests conducted between the two cars were that every edge (ray) of each car was tested against every plane of the other car. While quite a difficult method, it provides a perfect collision detection method. If time permitted, I would have used actual points from the polygon mesh of the car as tests in the collisions as my algorithm would be able to handle any points number of points. However, it wasn't necessary for this game as a square around the cars was sufficient. As far as maths goes, this was by far the most difficult aspect of the game. Below is an image that shows which planes are involved in the collision, and the rays of the box can also be seen.

Good picture


Camera

There are three types of camera available:

The camera in use can be changed with F2.
In two player mode the Zooming is dictated by the distance between the two cars, while in one player it can be increased or decreased by holding down the right mouse button and dragging up and down.
The rotation of Camera 2 and 3 can be changed by pressing the left mouse button and dragging the mouse. The rotation point of Camera 2 is the center point between the cars and the rotation point of Camera 3 is the Point (0,0,0).

Good picture

Other Features

Other features of the game include:



User Guide

Starting a Game

Good picture

From the command line, start a two player game on the default track by typing:
$ ./s2000

To play with one player type:
$ ./s2000 1

To play with two players on the track "track/track01.trk", type:
$ ./s2000 2 track01.trk

To play with one player on the track "track/track01.trk", type:
$ ./s2000 1 track01.trk

Key Bindings

Player 1

Player 2

General

Mouse Bindings


Conclusion

In summary, I really enjoyed my work on this project and look forward to starting a similar project in the future with the knowledge I have gained from undertaking this one. While I wish I started earlier in order to reduce the stress I encountered towards the end, I satisfied my goals for the project and I am happy with the final product.

Good picture


Valid XHTML 1.0!