Assignment 4 : Go-Kart Collision


Assignment Description

In this assignment., we create a simple game where a Go-Kart with 1 or more polygons is set into motion and use it to detect collisions with other objects or mesh in the scene.  Because my earlier scene is a basketball court with only a few lamp posts to do collision, I decide to make another scene in 3D studio max and load it into my scene. I modelled a maze containing some spheres which are to be collected in the simple game by running the Go-Kart into spheres after finding them in the maze.


Game Description

This is a simple game where you drive a Armoured Personal Carrier  around a maze to collect SWAT members that are lost in the game.  You will complete the game when u find the 5 SWAT team members.  As there was insufficient time, I was unable to do an elapsed timer to check for how long you take to complete the game.


Game Controls

Up/w                    : Accelerate

Down/s                : Decelerate

Left/a                    : Turn Vehicle Left

Right/d                  : Turn Vehicle Right

b                           : Toggle Bounding Box Display


Collision Detection Method

I used Oriented Bounding Box(OBB) test against other Oriented Bounding Box.  I used the Separating Axis Theorem to detect the overlapping of OBBs.  Oriented Bounding Box is able to bound the mesh tighter than a Axis Aligned Bounding Box (AABB) and thus I choose this method of detection.

For OBBs, the separating axis test must be generalized to three dimensions. A box's scalar projection onto a unit vector L creates an interval along the axis defined by L.

The radius of the projection of box A onto L is

The same is true for B, and L forms a separating axis if

Note that L does not have to be a unit vector for this test to work. The boxes A and B are disjoint if none of the 6 principal axes and their 9 cross products form a separating axis. These tests are greatly simplified if T and B’s basis vectors (B1, B2, B3) are transformed into A’s coordinate frame.

However to increase efficiency, I did a Sphere Sphere collision test first before I do a OBB intersection test because OBB intersection test is computationally much more expensive than a Sphere to Sphere Collision test.  I check the Go-Kart against all objects in the scene. As there was insufficient time, I was unable to implement a quad-tree to divide the scene up further to make the collision checks more efficient.

Collision Response

The collision response I did in this simple game is that when you hit a wall, you will bounce back in the opposite direction of that you were traveling.  In order to more simulation physics, I did a damping effect on the speed such that you will only bounce back at 75% of the speed you are traveling at and also include a friction component so that you need to keep pressing the accelerate key if you want the vehicle to continue to move forward as left alone the vehicle will slow to a stop.


Screenshots

Starting Screen, Vroommming!!

With Bounding Boxes Activated

    Yeah going to collect one of the SWAT team member

YEAH Win!!!!!


Download Source, Textures and Binaries

 

Back to Home

Hosted by www.Geocities.ws

1