Expand description
RigidModel file format support for Total War games.
§Overview
RigidModel files (.rigid_model_v2) are the primary 3D model format used by Total War games
to store mesh geometry, materials, skeletal animation data, and visual effects. These files
contain everything needed to render game assets including characters, buildings, terrain,
vegetation, and props.
§File Structure
A RigidModel file contains:
- Header: File signature (
RMV2), version number, skeleton ID - LOD (Level of Detail) structures: Multiple quality levels for distance-based rendering
- Mesh blocks: Individual mesh units, each with geometry and material data
- Vertex data: 3D positions, normals, UVs, bone weights (often compressed)
- Material definitions: Textures, shaders, attachment points, rendering parameters
§Supported Versions
| Version | Support | Notes |
|---|---|---|
| 6 | ✅ Full | Older format |
| 7 | ✅ Full | Intermediate format |
| 8 | ✅ Full | Current/newest format |
§Material System
RigidModels support 40+ material types for different rendering needs:
- Standard rendering: DefaultMaterial, Decal, Tree, Grass, Water
- Skeletal animation: WeightedSkin, WeightedCloth
- Terrain: RsTerrain, WeightedTextureBlend, TiledDirtmap
- Special effects: Collision, DebugGeometry, PointLight
Each material type determines:
- Which vertex format is used (affects vertex compression and available data)
- What textures and parameters are stored
- How the material is rendered in-game
§Vertex Formats
Different vertex formats optimize storage for specific use cases:
- Static (0): Standard geometry without animation
- Weighted (3): Skeletal animation with bone indices and weights
- Cinematic (4): High-quality vertices for cutscenes (supports 4 bones)
- Grass (5): Vegetation-specific format
- ClothSim (25): Cloth physics simulation vertices
- Collision (1): Simplified collision mesh vertices
Vertices use various compression techniques:
- Half-precision floats (f16) for positions and UVs
- Normalized u8 vectors for normals, tangents, bitangents
- Percentage encoding for bone weights
§Usage
ⓘ
use rpfm_lib::files::rigidmodel::RigidModel;
use rpfm_lib::files::{Decodeable, Encodeable};
// Decode a RigidModel file
let model = RigidModel::decode(&mut reader, &None)?;
// Access LODs and meshes
for lod in model.lods() {
println!("LOD distance: {}", lod.visibility_distance());
for mesh_block in lod.mesh_blocks() {
println!("Mesh: {}", mesh_block.mesh().name());
println!("Vertices: {}", mesh_block.mesh().vertices().len());
}
}
// Encode back to bytes
model.encode(&mut writer, &None)?;§Credits
Most of the reverse-engineering work for this module was done by Victimized, Phazer, and Ole. Their research enabled the implementation of this format decoder/encoder.
Modules§
- materials
- Material system for RigidModel files.
- vertices
- Vertex format definitions and I/O for RigidModel files.
Structs§
- Lod
- Level of Detail structure containing meshes at a specific quality level.
- Mesh
- Mesh geometry container with vertices, indices, and metadata.
- Mesh
Block - A single mesh unit with geometry and material data.
- Rigid
Model - Root structure representing a complete RigidModel file.
- Shader
Params - Raw shader parameter data (not fully decoded).
Constants§
- EXTENSION
- File extension for RigidModel files.