Module vertex

Module vertex 

Source
Expand description

Vertex and geometry data for models and map models.

§Overview

A VertexData file stores model geometry in a combined buffer. The remaining fields describe the data stored in the buffer like vertices or morph targets.

Each MeshV112 draw call references a VertexBufferDescriptor and IndexBufferDescriptor. Vertex buffers except the weights buffer have an associated VertexBufferExtInfo for assigning additional data like outline buffers or morph targets.

The weights buffer just contains DataType::SkinWeights and DataType::BoneIndices. This buffer is shared between all vertex buffers with each buffer selecting weight buffer “vertices” using DataType::WeightIndex and additional indexing information defined in Weights. See xc3_model for the complete indexing implementation.

Some vertex buffers have optional morph targets assigned in VertexMorphs. Morph targets define a default target for the neutral pose as well as additional targets applied on top of the default target. Morph targets define attributes not present in the vertex buffer and have a final attribute value defined as default + target_delta * weight where target_delta is defined sparsely using a list of deltas and vertex indices.

§Attribute Layout

The sections of the byte buffer for each descriptor contain each attribute for each vertex in order. This interleaved or “array of structs” layout is cache friendly when accessing each attribute for each vertex like in the vertex shaders in game.

position 0
normal 0
position 1
normal 1
...

Applications tend to work better with a “struct of arrays” approach where dedicated arrays store the values for a single attribute for all items. This approach is cache friendly when accessing the same attribute for all vertices and allows for easily adding and removing attributes. This is the approach used by xc3_model.

position 0
position 1
...
normal 0
normal 1
...

Structs§

IndexBufferDescriptor
MorphDescriptor
Morph targets assigned to a VertexBufferDescriptor.
MorphTarget
A set of target vertex values similar to a keyframe in traditional animations.
MorphTargetFlags
OutlineBufferDescriptor
Unk
UnkBufferDescriptor
UnkData
VertexAttribute
A single attribute in a VertexBufferDescriptor like positions or normals.
VertexBufferDescriptor
VertexBufferExtInfo
Extra data assigned to a non skin weights buffer.
VertexBufferExtInfoFlags
VertexData
Vertex and vertex index buffer data used by a ModelV112.
VertexMorphs
Vertex animation data often called “vertex morphs”, “shape keys”, or “blend shapes”.
WeightGroup
A range of elements in the weights buffer. Each element in the weights buffer is part of at least one WeightGroup.
WeightLod
References to WeightGroup for each of the RenderPassType.
Weights
Information used for precomputing skinning matrices based on a mesh’s level of detail (LOD) and RenderPassType.

Enums§

DataType
The data type, usage, and component count for a VertexAttribute.
IndexFormat
PrimitiveType