5.4.1 General Renderbuffers Format

Meshes often require specification of a large amount of data for e.g. mesh
positions, texture coordinates or triangle indices. Crystal Space has a
general format for storing such bulk data, giving a unified syntax for
different types of mesh objects allowing storing both in an XML-based
format or a compact binary format.

Buffer XML format

Top element

The top element has no fixed name; rather, it differs from mesh object to
mesh object. However, all top buffer elements have a common set of attributes.

file

Specifies a file name for an external file with the buffer data in a binary
representation (see below). If set, all other attributes are ignored.

Optional: specifies whether the buffer contains normalized data in case of
(unsigned) integer data. Normalized means the values are normnalized to
floats in the range of [0;1] (unsigned values) resp. [-1;1] (signed values)
when used. Unnormalized data is not changed.

indices

Optional: specifies whether the buffer is an index buffer. Index buffers are
handled differently internally and thus must be designated as such. They have
the restriction that they can have at most one component, can not contain
float data and can not be normalized.

Note that some meshes may specify additional attributes in buffer elements.

Buffer element specification

Each element in the buffer is specified as an XML element under the top
element, with the individual components being specified in element attributes.

The XML elements have the name ‘element’ or short ‘e’.

The attribute names for the individual components are ‘c0’ for the first
component, ‘c1’ for the second component and so on.

Buffer binary format

Overall, a binary buffer file contains a header with information about the
structure of the file (essentially what you would specify in the top element
attributes in the XML format) followed by the raw buffer data. Index and
general buffers have a similar but slightly different format. All values
are stored in little endian byte order.

General buffer header

uint16 magic

Magic word identifying a file as a general buffer file. Must be 0x6272.

uint8 componentType

The type of components stored in the buffer. The values are the same as in the
csRenderBufferComponentType enum.

uint8 componentCount

Number of components in per element in the buffer.

uint32 elementCount

Number of elements in the buffer.

Index buffer header

uint16 magic

Magic word identifying a file as a general buffer file. Must be 0x6269.

uint8 componentType

The type of components stored in the buffer. The values are the same as in the
csRenderBufferComponentType enum. Can not be a floating point or
normalized type.