3D Theory - Games Generation Example

On these pages we will analyse various types of games and discuss possible approaches.

Common Features

Here are some things which may be similar in these types of games.

The game may consist of a number of objects each made up of polygons (often triangles). The vertices of each triangle are stored in the coordinate system of the object you are building. We can move the object around by transforming all its verticies.

In order to prevent the object from getting distorted by repeated transorms (each of which may have small rounding errors) we tend to keep the verticies in there original form and generate the current position from this at each frame using a transform matrix to represent its position and orientation.

If we assume you are modelling, say an aircraft, then choose a local coordinate system for the aircraft, say x along the fuselage, y along the wing or whatever. Then encode all the vertices for that object in that coordinate system directly. Then to rotate that object multiply each vertex(vector) by the rotation matrix to give the transformed vertex(vector). This rotates the whole object around its origin. You can then offset the aircraft to be where you want on the screen by adding a fixed vector to each vertex (or equivalently by using a 4x4 matrix). 
It is best to avoid Euler angles if possible. Sometimes there are angles implied in the situation itself, for example in the case of an aircraft, the control surfaces imply rotation around certain axis. In this case we need to convert the angle information to matrix form as soon as possible. I guess the thing to keep in mind is that, when combining rotations, order is important. So if you want yaw then roll then pitch then yaw you will need a different matrix than if you want yaw then pitch then roll, these angles are relative to the aircraft not the ground.

Car Racing Game


metadata block
see also:
Correspondence about this page

Book Shop - Further reading.

Where I can, I have put links to Amazon for books that are relevant to the subject, click on the appropriate country flag to get more details of the book or to buy it from them.

cover Game Programming for Teens.

other games programming books

Commercial Software Shop

Where I can, I have put links to Amazon for commercial software, not directly related to this site, but related to the subject being discussed, click on the appropriate country flag to get more details of the software or to buy it from them.

cover Dark Basic Professional Edition - It is better to get this professional edition

cover This is a version of basic designed for building games, for example to rotate a cube you might do the following:
make object cube 1,100
for x=1 to 360
rotate object 1,x,x,0
next x

cover Game Programming with Darkbasic - book for above software


other commercial software

This site may have errors. Don't use for critical systems.

Copyright (c) 1998-2020 Martin John Baker - All rights reserved - privacy policy.