Assignment 5 : Grand Prix
Assignment Description
In this assignment of Grand Prix, we build our Go-Kart according to our own specification and let it race/run in our favorite game environment. In this assignment, we will plant our 3D scene from Assignment 4 on top of a larger terrain and will create a simple game where you can race in 3D space. The world must contain at least 3 objects being a terrain, a skybox and a racing machine.
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 maze. After finding the SWAT members, you will need to find your way out of the maze into the world outside the maze and look for the base which is a house located somewhere in the world. To complete the game, you will need to collect all the SWAT members in the maze and reach the base.
Game Controls
Because I implemented 2 cameras in the game, the controls defer depending on which camera mode you are in.
ChaseCam Mode (The camera will chase the car and stick close to it)
Up/w : Accelerate
Down/s : Deccelerate
Right/d : Turn Right
Left/a : Turn Left
p : Change to FreeCam Mode
FreeCam Mode (Camera is freed from the vehicle)
Up/w : Move Forward
Down/s : Move Backward
Right/d : Turn Right
Left/a : Turn Left
r : Straft Up
f : Straft Down
z : Pitch Up
c : Pitch Down
q : Roll Left
e : Roll Right
p : Change to ChaseCam Mode
Terrain Generation
The terrain is generated using a 3D program that make use of the heightmap to create a mesh to make it easier to make it faster to load into the scene than doing the generation inside the game itself as loading textures are taking a long time already.

HeightMap Used in Terrain Generation (From Boon Yifei)
SkyBox
SkyBox is used to create a sense of unlimited space of the world. The skybox is created by mapping the textures onto a cube that surrounds the camera and is always centered around the camera so that you can never approach the cube

Skybox Texture used
Terrain Following
Terrain following is implemented by shooting a ray downwards from the pivot of the vehicle and check for collision with the terrain below and the car is shifted according to the the height of the polygon that the ray intersects so that the car seems to be following the terrain.
Because I only shoot the ray from the centre of the vehicle thus sometimes the wheels will penetrate into the terrain but only by a bit and I considered it a tradeoff rather than shooting 4 rays, one from each wheel as that will increase the collisions checks by a lot.
Screenshots

Starting off

Wow, look at that maze I just escaped from

Yeah finally found the Base

Yeah reach the Base, a nice Base by the sea

Overview look from Free Camera View