bw logo

Chapter 7. .cdata

Named as <chunk>.cdata, these files are defined under folder <res>/spaces/<space>, and contain binary terrain and lighting data.

For details on the information held by this and other chunk files, see the document Client Programming Guide's section Chunks Implementation files.

For details on this and other zip files' grammar, see ZipSection files.

7.1. Contents

7.1.1. terrain2 resources

A terrain2 section is contained in a chunk's .cdata file. It contains all the resources for the terrain in a chunk. The different types of terrain data are described in BNF format in the following chapter.

7.1.1.1. heights sections

The heights sections stores the height map for the terrain block. Multiple heights sections are stored in the block, one for each LOD level, each heights section stores data at half the resolution of the previous one. The heights sections are named as " heights? " where ? is replaced by a number. The highest res height map is stored in a section named heights the second highest in a section called heights1 all the way down to a map that stores 2x2 heights. This way if the height map resolution is 128x128, 7 height maps are stored in the file (heights, heights1, ... heights6)

<heightMap> ::= <header><heightData>
<header> ::= <magic><width><height><compression><version><minHeight><maxHeight><padding>
  • <magic>

    uint32 0x00706d68 (string "hmp\0")

  • <width>

    uint32 containing the width of the data

  • <height>

    uint32 containing the height of the data

  • <compression>

    (unused) uint32 containing the compression type

  • <version>

    uint32 containing the version of the data, currently 4

  • <minHeight>

    float containing the minimum height of this block

  • <maxHeight>

    float containing the maximum height of this block

  • <padding>

    4 bytes of padding to make the header 16-byte aligned

  • <heightData>

    PNG compressed block of int32 storing the height in millimetres, dimensions = width * height from the header

7.1.1.2. layer sections

The layer sections store the texture layers for the terrain block. Multiple layer sections are stored in the terrain block. Each section describes one texture layer. The layer sections are named " layer ? " where ? is replaced by a number greater than 1. I.e if the block has 3 layers, three layer sections will be stored ("layer 1", "layer 2", "layer 3")

<textureLayer> ::= <header><textureName><blendData>
<header> ::= <magic><width><height><bpp><uProjection><vProjection><version><padding>
<textureName> ::= <length><string>
  • <magic>

    uint32 0x00646c62 (string bld/0")

  • <width>

    uint32 containing the width of the data

  • <height>

    uint32 containing the height of the data

  • <bpp>

    (unused) uint32 containing the size of the entries in the layer data

  • <uProjection>

    Vector4 containing the projection of the u coordinate of the texture layer

  • <vProjection>

    Vector4 containing the projection of the v coordinate of the texture layer

  • <version>

    uint32 containing the version of the data, currently 2

  • <padding>

    12 bytes of padding to make the header 16-byte aligned

  • <length>

    the length of the texturename string

  • <string>

    the name of the texture used by this layer

  • <blendData>

    png compressed block of uint8 defining the strength of this texture layer at each x/z position

7.1.1.3. normals & lodNormals sections

The normals section stores the high resolution normal map for the terrain block. The lodNormals section stores the LOD normals for the height block, the LOD normals are generally 1/16th of the size of the normals.

<normals> ::= <header><data>
<header> ::= <magic><version><padding>
  • <magic>

    uint32 0x006d726e (string "nrm/0")

  • <version>

    uint32 containing the version of the data, currently 1

  • <padding>

    8 bytes of padding to make the header 16-byte aligned

  • <data>

    png compressed block storing 2 signed bytes per entry for the x and z components of the normal the y component is calculate in the shader

7.1.1.4. holes section

The holes section stores the holemap for the terrain block, this section is only stored when a terrain block has holes in it.

<holes> ::= <header><data>
<header> ::= <magic><width><height><version>
  • <magic>

    uint32 0x006c6f68 (string "hol/0")

  • <width>

    uint32 containing the width of the data

  • <height>

    uint32 containing the height of the data

  • <version>

    uint32 containing the version of the data, currently 1

  • <data>

    The hole data stored in a bit field of width * height, each row in the data is rounded up to 1 byte. If a bit is set to 1 it denotes a hole in the map.

7.1.1.5. horizonShadows section

The horizonShadows section stores the horizon shadows for the terrain block.

<shadows> ::= <header><data>
<header> ::= <magic><width><height><bpp><version><padding>
  • <magic>

    uint32 0x00646873 (string "shd/0")

  • <width>

    uint32 containing the width of the data

  • <height>

    uint32 containing the height of the data

  • <bpp>

    (unused)uint32 containing the bits per entry in the data

  • <version>

    uint32 containing the version of the data, currently 1

  • <padding>

    12 bytes of padding to make the header 16-byte aligned

  • <data>

    The shadow data, (uint16,uint16) * width * height, the horizon shadow data stores two angles between which there is no occlusion from any terrain or objects.

7.1.1.6. lodTexture.dds section

The lodTexture.dds section stores the LOD texture for the terrain block. The LOD texture is a low resolution snapshot of all the texture layers blended together. The texture is stored in the DXT5 format. For more information about the dds texture format please refer to the DirectX documentation.

7.1.1.7. dominantTextures section

The dominantTextures section stores the dominant texture map. The dominant texture map stores the texture with the highest blend for each x/z location in the terrain block.

<dominant> ::=<header><texNames><data>
<header> ::= <magic><version><numTextures><texNameSize><width><height><padding>
  • <magic>

    uint32 0x0074616d (string "mat/0")

  • <version>

    uint32 containing the version of the data, currently 1

  • <numTextures>

    uint32 containing the number of textures referenced by the dominant texture map

  • <texNameSize>

    uint32 containing the size of the texture entries

  • <width>

    uint32 containing the width of the data

  • <height>

    uint32 containing the height of the data

  • <padding>

    8 bytes of padding to make the header 16-byte aligned

  • <texNames>

    numTextures entries of texNameSize size containing the names of the dominant textures referred to in this map. Texture names shorter than texNameSize are padded with 0

  • <data>

    stored as a compressed bin section. byte array of width * height, each entry is an index into the texture names which indexes the dominant texture at the x/z location of the entry