Skip to main content

gltf_from_rigid

Function gltf_from_rigid 

Source
pub fn gltf_from_rigid(
    value: &RigidModel,
    dependencies: &mut Dependencies,
) -> Result<Gltf>
Expand description

Converts a RigidModel to glTF format.

This function takes a Total War RigidModel and produces a glTF document that can be saved to disk or further processed.

§Arguments

  • value - The RigidModel to convert
  • dependencies - Dependencies cache for resolving texture references

§Returns

A Gltf document containing the converted model data.

§LOD Handling

Since glTF doesn’t natively support LOD levels, each LOD from the RigidModel is exported as a separate scene within the glTF document. The first scene (index 0) contains LOD 0 (highest detail).

§Mesh Data

For each mesh, the following data is exported:

  • Vertex positions (vec3)
  • Texture coordinates (vec2, up to 2 sets)
  • Vertex normals (vec3) - reconstructed from tangent/bitangent if needed

§Materials

Materials are created for each mesh with:

  • Base color texture (diffuse map)
  • Normal map
  • Metallic-roughness properties