[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ] [ Search: ]

4.12.3.2 General Concepts

This section describes general core concepts which are used by following discussions.

Polygon

A polygon is represented as a set of 3D vertices oriented in clockwise order (if the orientation is different, the polygon is not visible on screen). There are three versions of any polygon:

  1. Po is the polygon in object space. Here the vertices of the polygon are given in object space coordinates.
  2. Pw is the polygon in world space. For a sector world space is equal to object space but for a thing there is a transformation from object space to world space given as:

    Vw = Mow * Vo - Vow

    This means that the vertex in world space coordinates (Vw) is given as the vertex in object space coordinates (Vo) transformed by the matrix from object to world space (Mow) and the vector from object to world space (Vow).

    This transformation is recomputed whenever a thing moves.

  3. Pc is the polygon in camera space. Before viewing, every relevant vertex is transformed from world space to camera space using the following equation:

    Vc = Mwc * (Vw - Vwc)

Note, all three versions of a polygon are represented by the same polygon object. The change from object to world and world to camera space happens inside the Vertex class that is referenced by the polygon.

Associated with every polygon there is also a plane normal or plane equation:

N: A * x + B * y + C * z + D = 0

There are also three versions of this plane equation; one for object space, one for world space, and one for camera space:

No: Ao * x + Bo * y + Co * z + Do = 0
Nw: Aw * x + Bw * y + Cw * z + Dw = 0
Nc: Ac * x + Bc * y + Cc * z + Dc = 0

Camera

A camera is represented as a matrix (Mwc) and a vector (Vwc). In fact the camera describes the transformation between world and camera space. The inverse transformation (Mcw) from camera space to world space is also kept inside a ‘csCamera’ object because it can be used for movement (for example, to move forward one would want to move forward along the Z-axis in camera space and not in world space).

Texture

There is also a texture associated with every polygon. The texture represents a 2-dimensional rectangular space where (0,0) is one corner of the texture and (1,1) is the opposite corner. If a texture is overlayed onto a rectangular polygon such that one corner is mapped onto (0,0) in texture space and the opposite corner is mapped onto (2,2) then the texture will be tiled four times across the surface of the polygon.

To transform object to texture space we have the following equation:

Vt = Mot * (Vo - Vot)

Similarly for world space:

Vt = Mwt * (Vw - Vwt)

And for camera space:

Vt = Mct * (Vc - Vct)

So, just as there are three versions of the polygon (Po, Pw, and Pc) and three plane equations, we also have three equations transforming the various spaces to the texture. Mot and Vot (object to texture space) are fixed (calculated at load time). Mwt and Vwt (world to texture space) are the same for sectors but for things they are calculated whenever a thing moves. Mct and Vct (camera to texture space) are calculated every time the corresponding polygon is visible and needs to be drawn on screen.

Note that the texture transformation matrix is actually a transformation from 3D to 3D. We simply don't use the Z component in texture space (it is just ignored).


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated using texi2html 1.76.