Skip to main content

Mesh library

Overview

Meshes are usually embedded into rigid model files (.3db and .cmp) with exception of UI where mesh data is stored in separate .vms file.

VMeshData

VMeshData is pretty much a big vertex/index buffer that contains all vertices and triangles of one or multiple parts. However when containing meshes of multiple parts VMeshData isn’t directly aware of how many has, it’s a dumb storage, but an indirect indication that another part begins within its data set is when VMeshGroup.vertexStart is 0 and when vertex index in triangle also starts from 0. Normally parts never share vertices, but mesh groups within a part may.

NameTypeDescription
meshTypeuint32Always 1. Game crashes otherwise.
primitiveTypeuint32Direct3D primitive type.
groupCountuint16Mesh group count.
indexCountuint16Element buffer count.
vertexFormatuint16Direct3D FVF (Flexible Vertex Format).
vertexCountuint16Vertex buffer count.
groupsvaryingMesh groups.
indicesvaryingElement indices.
verticesvaryingVertex attribute data.
  • Element indices are uint16.
  • Vertex attribute length depends on FVF mode.
  • VMeshData can be mapped to OpenGL VAO (Vertex Array Object)

Primitive types are:

ValueType
1Point list
2Line list
3Line strip
4Triangle list
5Triangle strip
6Triangle fan

These are vertex format flags and modes which Freelancer uses:

NameMask valueDescriptionVertex value
D3DFVF_XYZ0x0001Positionfloat[3]
D3DFVF_NORMAL0x0010Normalfloat[3]
D3DFVF_DIFFUSE0x0040Coloruint32
D3DFVF_TEXn0xFF00UV1-8float[2]
  • D3DFVF_XYZ, D3DFVF_NORMAL, D3DFVF_DIFFUSE and D3DFVF_TEX0 to D3DFVF_TEX8 supported.
  • D3DFVF_PSIZE and D3DFVF_SPECULAR are not supported and will result in corrupted drawing.

A mesh group is a collection of vertices and vertex indices forming triangles that are grouped by a single material identifier. It is fairly common in Freelancer for a model or even an individual part of a compound model to use multiple materials. So a model or each of its parts may use one more groups if they use multiple materials.

NameTypeDescription
materialIduint32Material ID (FLCRC32 of material name).
vertexStartuint16Vertex buffer start index.
vertexEnduint16Vertex buffer end index.
indexCountuint16Element buffer index count.
paddinguint16Padding. Should be 0xCC.

VMeshRef

Pointer to chunk of data in VMeshData.

NameTypeDescription
sizeuint32VMeshRef byte size, always 60.
meshIduint32Mesh ID (FLCRC32 of VMeshData parent entry name).
vertexStartuint16Vertex buffer start index.
vertexCountuint16Vertex buffer index count.
indexStartuint16Element buffer start index.
indexCountuint16Element buffer index count.
groupStartuint16Mesh group start index.
groupCountuint16Mesh group count.
extentsfloat[6]Bounding box as max and min of x, y and z.
centerfloat[3]Bounding sphere center.
radiusfloatBounding sphere radius.

VWireData

Uses mesh vertices to construct lines for HUD wireframe view.

NameTypeDescription
sizeuint32VWireData header size, always 16.
meshIduint32Mesh ID.
vertexStartuint16Vertex buffer start index.
vertexCountuint16Unique vertex count.
indexCountuint16Element buffer index count.
vertexRangeuint16Range between maximum vertex index and minimum vertex index.
indicesvaryingA pair of element indices per line drawn.
  • Like element indices in mesh these are uint16.
  • There's a limit to how many indices a drawn wireframe model (including any attachments) can have.