VVD: Difference between revisions
(adding file info) |
No edit summary |
||
Line 44: | Line 44: | ||
This seems to be an array of 4D vectors, one for each vertex | This seems to be an array of 4D vectors, one for each vertex | ||
vec_t x, y, z, w; | vec_t x, y, z, w; | ||
==Binary Data== | |||
When the model is compiled all vertex data is stored inside the VVD file. If the model has LoD then a LoD fixup table is created and the order of vertexes will be effected by this. The compiler will only keep the vertexes for each LoD that are different to the ones in the reference mesh to maximize efficiency and to keep file sizes down. This optimization can sometimes create mesh problems in the LoD transitions. | |||
===Vertex Table=== | |||
All vertexes are stored inside 48 byte blocks. This block contains data for each single vertex which includes bone weighting, posistion (XYZ), normals (XYZ) and texture co-ordinates (UV). | |||
* Bone weighting (0-12) [3xfloat] - Contains a maximum of 3 floating points numbers, one for each bone. The engine allows a maximum of 3 bones per vert. Older formats such as version 37 used 4 bones. | |||
* Bone IDs (12-16) [4xbyte] - IDs of the bones the vertex is weighted to. The first bone is the parent with a maximum of 3 child bones. The first child will use the first float number for weighting. | |||
* Posistion (16-28) [3xfloat] - Floating points numbers for each axis (XYZ) in inches. | |||
* Normals (28-40) [3xfloat] - Floating points numbers for face normals. | |||
* Texture Co-ordinates (40-48) [2xfloat] - Floating points numbers for UV map. The value for V may need to inverted and incremented by 1 to get back the original value. | |||
===Tangent Table=== | |||
Below the vertex block is the tangent table. The tangents are calculated on compile and are used for normal mapping. Each tangent is stored inside a 16 byte block. | |||
* Transformations (0-16) [4xfloat] - Floating points numbers for each transform calculation for each axis (XYZ). Last float (W) is either 1 or -1. | |||
== See also == | == See also == | ||
* [[Model Creation Overview]] | * [[Model Creation Overview]] |
Revision as of 12:35, 18 October 2010
VVD is the extension for Source's proprietary model vertex data format. It stores position independent flat data for the bone weights, normals, vertices, tangents and texture coordinates used by the MDL.
Header
struct vertexFileHeader_t { int id; // MODEL_VERTEX_FILE_ID -- little-endian "IDSV" int version; // MODEL_VERTEX_FILE_VERSION long checksum; // same as studiohdr_t, ensures sync int numLODs; // num of valid lods int numLODVertexes[MAX_NUM_LODS]; // num verts for desired root lod int numFixups; // num of vertexFileFixup_t int fixupTableStart; // offset from base to fixup table int vertexDataStart; // offset from base to vertex block int tangentDataStart; // offset from base to tangent block };
Fixup Table
// apply sequentially to lod sorted vertex and tangent pools to re-establish mesh order struct vertexFileFixup_t { int lod; // used to skip culled root lod int sourceVertexID; // absolute index from start of vertex/tangent blocks int numVertexes; };
Vertex Data
A list of vertices follows the header
// NOTE: This is exactly 48 bytes struct mstudiovertex_t { mstudioboneweight_t m_BoneWeights; //see below Vector m_vecPosition; Vector m_vecNormal; Vector2D m_vecTexCoord; };
// 16 bytes struct mstudioboneweight_t { float weight[MAX_NUM_BONES_PER_VERT]; //MAX_NUM_BONES_PER_VERT is defined as 3 char bone[MAX_NUM_BONES_PER_VERT]; byte numbones; };
Tangent Data
This seems to be an array of 4D vectors, one for each vertex
vec_t x, y, z, w;
Binary Data
When the model is compiled all vertex data is stored inside the VVD file. If the model has LoD then a LoD fixup table is created and the order of vertexes will be effected by this. The compiler will only keep the vertexes for each LoD that are different to the ones in the reference mesh to maximize efficiency and to keep file sizes down. This optimization can sometimes create mesh problems in the LoD transitions.
Vertex Table
All vertexes are stored inside 48 byte blocks. This block contains data for each single vertex which includes bone weighting, posistion (XYZ), normals (XYZ) and texture co-ordinates (UV).
- Bone weighting (0-12) [3xfloat] - Contains a maximum of 3 floating points numbers, one for each bone. The engine allows a maximum of 3 bones per vert. Older formats such as version 37 used 4 bones.
- Bone IDs (12-16) [4xbyte] - IDs of the bones the vertex is weighted to. The first bone is the parent with a maximum of 3 child bones. The first child will use the first float number for weighting.
- Posistion (16-28) [3xfloat] - Floating points numbers for each axis (XYZ) in inches.
- Normals (28-40) [3xfloat] - Floating points numbers for face normals.
- Texture Co-ordinates (40-48) [2xfloat] - Floating points numbers for UV map. The value for V may need to inverted and incremented by 1 to get back the original value.
Tangent Table
Below the vertex block is the tangent table. The tangents are calculated on compile and are used for normal mapping. Each tangent is stored inside a 16 byte block.
- Transformations (0-16) [4xfloat] - Floating points numbers for each transform calculation for each axis (XYZ). Last float (W) is either 1 or -1.