Unmanned Flight Simulator

Space Explorer

With the rapid development on space technology, the journey to the space galaxy will soon be as easy as taking a plane from Singapore to United States. How does the space look like? No one knows unless one has been there before. Before a ride to space galaxy is made possible for everyone, prehaps you might like to try playing a space simulation. Space Explorer was created for a player to explore a planet in space using a space ship.

Space Objects

Sky Dome

A speherical like structure was created to hold the entire 3D space of movement in the space galaxy. This hold the player's space ship and the planet terrain.

Planet Terrain

The terrain is made up of mesh of triangles that are joined together on each vertex at different heights. This provide a rough surface effect which provide realism on the planet terrain.

Space Ship

A space ship made up of polygonal shapes was created to simulate the player's movement on the space terrain. The movement pf the space ship on the terrain was control by the arrows key pad and the space ship's take-off (hover-up) and landing (hover down) were control by the "A" and the "S" key respectively. Due to time constraint, collision detection between the space ship and the terrain was not done.

Objects Modeling

Sky Dome

The sky dome is made up of the top part of a sphere that house the terrain and the player within it. Rendering the sky dome requires an array of pre-computed vertices (x, y, z) for each ring of the sky dome. Starting from the top of the dome, the array of vertices for each ring were retrieved and rendered using a series of triangle strip. The computation for the array of vertices for each ring was done by first deciding the number of vertices for each ring. This divides each ring equally into points or group of vertices.

Using a defined radius for the dome, a horizontal sweep around the dome create each vertex by calculating its x, y and z values around a ring. Upon completion, a vertical sweep around the dome computing each vertex will be done. Each calculation will be stored into a pre-defined array. The updated array will then be retrieved by looping through the number of vertices for each ring and rendered using triangle strip. Texture coordinates will be pre-calculated and store in the similar array which will be retrieved for mapping a space texture onto it. The spherical u and v coordinates for the texture are obtained by calculating a normalize vector at each vertex.

Space Terrain

Explicit terrain generation technique was employed in generating the terrain as a small terrain was rendered within the game environment. The terrain plane was rendered by a pool of vertices (each defined by x, y, z) having a size of 1024 on the x and z-axis respectively. Each axis of the plane as shown in the figure was further divided into 64 points starting at x(0) = -512 and z(0) = -512, we loop through each vertex on the plane to calculate the height (y value at each vertex) till we reach x(64) = 512 and z(64) = 512. To create the random height differences on the terrain surface, the y value of each vertex was manipulated by a random variable generated by the system. Each vertex (x, y, z) value will be stored in an array which will be retrieved later for rendering.

Upon completing the calculation for each vertex on the plane, an index array will be created. The index array allow us to select any 3 points we want to render each triangle. The first triangle was rendered using vextex(0), vertex(1) and vertex(65) and the second triangle rendered using vertex(1), vertex(66) and vertex(65) and so on. The final terrain will be a surface rendered by a mesh of triangles. Similarly, texture coordinates for the terrain will be pre-computed and store in the similar array and retrieved for mapping the terrain texture onto it. Each u and v texture coordinates for a vertex are calculated and depending on how the triangle is drawn (or which set of vertices is selected). The texture will then be mapped according to the texture coordinates defined by each vertex in that set of vertices.

Space Ship

The space ship is rendered using primitive polygons that were made up of quads and cylinders. It was bind to the camera view so as to give the player's a better realism of movement on the terrain.

Here is a copy of my game's source code and executable file, have fun in space!

Acknowledgement

I would like to thank Mr Luis R. Sempé for his tutorial on sky dome and terrain rendering. Below are some reference links that I refer for developing this game.

Nehe Tutorial

GameTutorials