Two templates nested in a Mesh carry extra
per-vertex data as raw DWORDs, described by Direct3D 9 codes: FVFData uses
a flexible vertex format (FVF) code, and DeclData a list of
VertexElement objects. The numbers of those codes come from Direct3D 9’s
d3d9types.h; this page lists them all.
FVFData
template FVFData {
<B6E70A0E-8EF9-4e83-94AD-ECC8B0C04897>
DWORD dwFVF;
DWORD nDWords;
array DWORD data[nDWords];
}
Microsoft describes it as the mesh data minus the position data: dwFVF
says which components each vertex has, and data holds them as DWORDs.
Floats are stored by their bit pattern.
FVF flags
| Value | Name | Meaning |
|---|---|---|
0x0001 | D3DFVF_RESERVED0 | Reserved |
0x0002 | D3DFVF_XYZ | Untransformed position, three floats |
0x0004 | D3DFVF_XYZRHW | Transformed position, four floats; not with XYZ or NORMAL |
0x0006 | D3DFVF_XYZB1 | Position and 1 blending weight |
0x0008 | D3DFVF_XYZB2 | Position and 2 blending weights |
0x000A | D3DFVF_XYZB3 | Position and 3 blending weights |
0x000C | D3DFVF_XYZB4 | Position and 4 blending weights |
0x000E | D3DFVF_XYZB5 | Position and 5 blending weights |
0x4002 | D3DFVF_XYZW | Transformed and clipped position (x, y, z, w) |
0x400E | D3DFVF_POSITION_MASK | Mask for the position bits above |
0x0010 | D3DFVF_NORMAL | A normal, three floats |
0x0020 | D3DFVF_PSIZE | A point size, one float |
0x0040 | D3DFVF_DIFFUSE | A diffuse colour, one packed D3DCOLOR |
0x0080 | D3DFVF_SPECULAR | A specular colour, one packed D3DCOLOR |
0x0F00 | D3DFVF_TEXCOUNT_MASK | Number of texture coordinate sets, 0 to 8, in bits 8 to 11 (D3DFVF_TEX0 = 0x000 to D3DFVF_TEX8 = 0x800) |
0x1000 | D3DFVF_LASTBETA_UBYTE4 | The last blending weight is four unsigned bytes of matrix indices |
0x8000 | D3DFVF_LASTBETA_D3DCOLOR | The last blending weight is a D3DCOLOR of matrix indices |
0x6000 | D3DFVF_RESERVED2 | Reserved |
Bits 16 to 31 give the size of each texture coordinate set, two bits per set: set n uses bits 16 + 2n and 17 + 2n.
| Bits | Name | Floats in the set |
|---|---|---|
| 0 | D3DFVF_TEXTUREFORMAT2 | 2 (the default) |
| 1 | D3DFVF_TEXTUREFORMAT3 | 3 |
| 2 | D3DFVF_TEXTUREFORMAT4 | 4 |
| 3 | D3DFVF_TEXTUREFORMAT1 | 1 |
A D3DCOLOR is one DWORD holding alpha, red, green and blue, 8 bits each, from the most
significant byte down (0xAARRGGBB).
DeclData and VertexElement
template DeclData {
<BF22E553-292C-4781-9FEA-62BD554BDD93>
DWORD nElements;
array VertexElement Elements[nElements];
DWORD nDWords;
array DWORD data[nDWords];
}
template VertexElement {
<F752461C-1E23-48f6-B9F8-8350850F336F>
DWORD Type;
DWORD Method;
DWORD Usage;
DWORD UsageIndex;
}
Each VertexElement describes one component of every vertex, such as a
tangent or a second set of texture coordinates; data holds the values.
The file’s element has no stream number or byte offset, unlike Direct3D’s own
D3DVERTEXELEMENT9. Microsoft does not describe the layout of
data; with no offsets, it follows that the elements of a vertex lie one
after another in the order declared, vertex after vertex.
Type
| Value | Name | Bytes | Meaning |
|---|---|---|---|
| 0 | D3DDECLTYPE_FLOAT1 | 4 | One float, expanded to (f, 0, 0, 1) |
| 1 | D3DDECLTYPE_FLOAT2 | 8 | Two floats, expanded to (f, f, 0, 1) |
| 2 | D3DDECLTYPE_FLOAT3 | 12 | Three floats, expanded to (f, f, f, 1) |
| 3 | D3DDECLTYPE_FLOAT4 | 16 | Four floats |
| 4 | D3DDECLTYPE_D3DCOLOR | 4 | A packed D3DCOLOR, mapped to 0 to 1 and reordered to RGBA |
| 5 | D3DDECLTYPE_UBYTE4 | 4 | Four unsigned bytes |
| 6 | D3DDECLTYPE_SHORT2 | 4 | Two signed shorts, expanded to (v, v, 0, 1) |
| 7 | D3DDECLTYPE_SHORT4 | 8 | Four signed shorts |
| 8 | D3DDECLTYPE_UBYTE4N | 4 | Four unsigned bytes, each divided by 255 |
| 9 | D3DDECLTYPE_SHORT2N | 4 | Two signed shorts, each divided by 32767, expanded to (v, v, 0, 1) |
| 10 | D3DDECLTYPE_SHORT4N | 8 | Four signed shorts, each divided by 32767 |
| 11 | D3DDECLTYPE_USHORT2N | 4 | Two unsigned shorts, each divided by 65535, expanded to (v, v, 0, 1) |
| 12 | D3DDECLTYPE_USHORT4N | 8 | Four unsigned shorts, each divided by 65535 |
| 13 | D3DDECLTYPE_UDEC3 | 4 | Three unsigned 10-bit values, expanded to (v, v, v, 1) |
| 14 | D3DDECLTYPE_DEC3N | 4 | Three signed 10-bit values, each divided by 511, expanded to (v, v, v, 1) |
| 15 | D3DDECLTYPE_FLOAT16_2 | 4 | Two 16-bit floats, expanded to (v, v, 0, 1) |
| 16 | D3DDECLTYPE_FLOAT16_4 | 8 | Four 16-bit floats |
| 17 | D3DDECLTYPE_UNUSED | 0 | No data; used with the UV and LOOKUPPRESAMPLED methods |
Method
What the tessellator does with the element. Files describing ordinary meshes use 0.
| Value | Name | Meaning |
|---|---|---|
| 0 | D3DDECLMETHOD_DEFAULT | Copy the data as it is (interpolated when tessellating) |
| 1 | D3DDECLMETHOD_PARTIALU | Compute the tangent in the u direction of a patch |
| 2 | D3DDECLMETHOD_PARTIALV | Compute the tangent in the v direction of a patch |
| 3 | D3DDECLMETHOD_CROSSUV | Compute the normal as the cross product of the two tangents |
| 4 | D3DDECLMETHOD_UV | Copy out the patch’s u and v at the point; type must be UNUSED |
| 5 | D3DDECLMETHOD_LOOKUP | Look up a displacement map |
| 6 | D3DDECLMETHOD_LOOKUPPRESAMPLED | Look up a presampled displacement map; type must be UNUSED |
Usage and UsageIndex
What the element is for. UsageIndex tells apart several elements with
the same usage, such as texture coordinate sets 0, 1 and 2.
| Value | Name | Meaning |
|---|---|---|
| 0 | D3DDECLUSAGE_POSITION | Position |
| 1 | D3DDECLUSAGE_BLENDWEIGHT | Blending weights |
| 2 | D3DDECLUSAGE_BLENDINDICES | Blending matrix indices |
| 3 | D3DDECLUSAGE_NORMAL | Normal |
| 4 | D3DDECLUSAGE_PSIZE | Point size |
| 5 | D3DDECLUSAGE_TEXCOORD | Texture coordinates, or other user data |
| 6 | D3DDECLUSAGE_TANGENT | Tangent |
| 7 | D3DDECLUSAGE_BINORMAL | Binormal |
| 8 | D3DDECLUSAGE_TESSFACTOR | Tessellation factor |
| 9 | D3DDECLUSAGE_POSITIONT | Transformed position |
| 10 | D3DDECLUSAGE_COLOR | Colour: index 0 diffuse, index 1 specular |
| 11 | D3DDECLUSAGE_FOG | Fog blend value |
| 12 | D3DDECLUSAGE_DEPTH | Depth |
| 13 | D3DDECLUSAGE_SAMPLE | Displacement sampler value |