|
The drawing of objects relies upon collections of vertices and collections of faces. Vertex
collections are considered to be ownerless, but face collections are owned by a particular
object.
It can be useful to think of objects as a list of commands for the renderer, rather than a more
traditional data structure.
Vertex collections come in this form :
[standard chunk header - type is 0x0101]
|
Offset
|
Length
|
Description
| |
0
|
4
|
Quantity of vertices.
| |
4
|
(number of vertices)*48
|
A list of the vertices. Each vertex has information on
position, texture co-ordinates, colour, and the normal at that vertex. The ordering
is as follows :
-
8 bytes - 2 floating point numbers, texture space x (a.k.a. u)
followed by texture space y (a.k.a. v)
-
16 bytes - 4 floating point numbers, the colour at this vertex.
The numbers are r, g, b, a in that order.
-
12 bytes - 3 floating point numbers, the normal at this vertex,
stored as an x, y, z triplet.
-
12 bytes - 3 floating point numbers, the position of this vertex,
stored as an x, y, z triplet.
|
Every vertex encountered within a file is assigned a particular numerical id. That id is simply
the number of other vertices already encountered within the current file before the present one.
It is also possible to reset this count to 0 using a vertex reset block :
[standard chunk header - type is 0x0100]
[no extra data]
The start of a new object is precipitated by an object start block :
[standard chunk header - type is 0x0200]
|
Offset
|
Length
|
Description
| |
0
|
4
|
Object id. This allows the game to figure out from the track file which
objects should go where.
|
An object is a collection of faces and possibly state change commands. Faces are textured, and they
are textured with the currently active texture image. Which image is current may be affected with a
texture state change. It is also possible to affect reverse face removal with a different state
change command. Texture changes have this form :
[standard chunk header - type is 0x0201]
|
Offset
|
Length
|
Description
| |
0
|
4
|
New texture id. If this value is 0xffffffff, texturing is disabled -
otherwise the specified texture is made current.
|
Enable/Disable effect commands have this form :
[standard chunk header - type is 0x0203 for disable or 0x0204 for enable]
|
Offset
|
Length
|
Description
| |
0
|
4
|
Rendering feature to enable or disable. Has one of these values :
-
0x00000000 : reverse face removal
|
Face sets refer to vertices by their numerical ids. However, when a vertex reset block has been
encountered, the effect is to reset the game's capacity for finding vertices, so no vertices
prior to the reset may be referenced, even if their ids have not yet been reallocated.
Face descriptions have this form :
[standard chunk header - type is 0x0202]
|
Offset
|
Length
|
Description
| |
0
|
4
|
Type of faces enclosed. This has one of the following values :
-
0 - TRIANGLES. Every three vertices form a unique triangle.
Naturally, vertices 3n, 3n+1 & 3n+2 form triangle n.
-
1 - TRIANGLE STRIP. Forms a set of triangles with shared edges.
Starting with n=1, for odd n, vertices n, n+1 & n+2 define that
polygon. For even n, n+1, n & n+2 are used. (total vertices)-2
triangles are produced.
-
2 - TRIANGLE FAN. Forms a set of triangles all connected to
the first vertex. Starting with n=1, triangle n is drawn using
vertices 1, n+1 & n+2. (total vertices)-2 triangles are produced.
-
3 - QUADS. Every four vertices form a unique quad, which must
be convex. Naturally, vertices 4n, 4n+1, 4n+2 & 4n+3 form quad n.
-
4 - QUAD STRIP. Forms a set of quads with shared edges. Quad n
is formed from vertices 2n-1, 2n, 2n+2, 2n+1.
-
5 - POLYGON. All vertices are used to construct a single, multi-sided
polygon. Note that this polygon must be convex.
-
6 - LINES. Pairs of vertices make independant line segments, i.e. vertices 2n-1
and 2n define line n.
-
7 - LINE STRIP. A connected ground of line segments is drawn, reaching from the
first vertex to the last. Line n is defined by vertices n and n+1.
-
8 - LINE LOOP. This is exactly the same as LINE STRIP, except that one extra line
is drawn between the very last vertex and the very first.
-
9 - POINTS. Each vertex is used to plot a unique point. The appearance of this
point will change depending on OpenGL implementation - specifically whether the
Care should be taken with non-triangular types, since the effects of clipping on
these can be non-predictable when the texel to world space mapping is non-rectangular.
Notice that quad strips and triangle strips with the same vertex lists will normally
cover the same space. The same is true of a triangle fan and a polygon.
It is worth trying to use the most implicit face
type possible for your data, since doing so can significantly improve drawing
performance.
| |
4
|
4
|
A single floating point number, the coefficient of friction for these surfaces.
| |
8
|
4
|
Quantity of referenced vertices
| |
12
|
4*(quantity of referenced vertices)
|
A list of vertex references, used to build whatever primitives were described
|
|