The car model I used for this assignment is a open source
model available on the internet.
The file for this model has got a simple structure:
First the number of vertices are given and their
coordinates. After that the number of triangles are
given followed by the number of vertices which form one
triangle.
At the start of the program the file is read and the model you
can see below is constructed.
This model consists of 125 vertices and 93 triangles.
The test to figure out whether the car collides with another
object or not is a "sphere to sphere test". First the
Euclidean distance between the center of the car and the objects
(which are the three pillars of the scenes) is
computed. Then the Euclidean distance is computed and compared
to the radius of the sphere around the car. If the radius is
larger than the computed distance, then the two objects
collide.
On the first picture below you can see the sphere around the car and the pillar
which is inside of the sphere, so in this case we have an
collision. In the second picture the car does not collide with
the pillar.
The rules for the game a very simple: earn points by moving
the car through the scene without colliding with other
objects. In case of collision you will lose points or earn
negative ones.