3D Basics

Welcome to the world of 3D, if you're like me then one day, when you looked at Quake or Duke (although I have discovered that Duke uses more complex polyhedra or something) or even The Pandora Directive (best game on the planet - buy it) you thought for the first time "How the hell did they do that?". And you decided that you want to do it too. Thats how it happened to me anyway. But its not as easy as first thought, that is if you were stupid enough to think its easy ;)

Anyway, 3D worlds are all based around some sort of coordinate system. There are three basic coordinate systems for 3D space: Cartesian (x,y,z), Cylindrical Polar (rho,theeta,z) and Spherical Polar (r,theeta,phi). Dont worry if you dont know what these are because the one we use for our programs is usually Cartesian coordinates (x,y,z). In my engine, I use the left-handed coordinate system :

Left Handed Coordinate System

Where z points into the screen.

To define a point in this system, you must specify x, y, and z values. So, a point P might be at (50,50,50).

typdef struct {

} static_vertex;

typedef struct {

} vertex;

This can easily be expanded to define a straight line as simply two points which are joined, eg: (50,50,50) to (100,100,100). To get a curved line, you would need to do alot more complex math in youre engine to do it properly, but to approximate, you can use many smaller straight lines connected end to end.

A polygon is a collection of points which are all connected to form a coplanar shape with an arbitrary number of sides. Polygon's can be oriented in any way desirable. They are used to build bigger complex shapes by sharing sides, eg. a cube is made of six polygons. Polygon's can have any number of sides ( at least three). A more interesting example is a monster from Quake, they are made up of lots of small polygon's (I think they have up to 500 of em).

typedef struct {

} polygon;

Of course, this structure will grow later as we add shading and texture mapping.

Objects are defined as a collection of polygon's connected as stated above.

typedef struct { // an object is a movable item

} object_3D;

E-mailMain PageLinks
Click Here!