Skip to main content

Module vertices

Module vertices 

Source
Expand description

Vertex format definitions and I/O for RigidModel files.

§Overview

Vertices define the 3D geometry of meshes. RigidModel files support multiple vertex formats optimized for different use cases, with extensive use of data compression to reduce file size.

§Vertex Formats

| Format | ID | Purpose | Bone Support | |———–|—.|–––––––––––––––––|–––––––| | Static | 0 | Standard non-animated geometry | No | | Collision | 1 | Simplified collision meshes | No | | Weighted | 3 | Skeletal animation (2 bones) | Yes (2) | | Cinematic | 4 | High-quality cutscenes (4 bones) | Yes (4) | | Grass | 5 | Vegetation/grass rendering | No | | Uk8 | 8 | Unknown (seen in water planes) | Unknown | | Uk12 | 12 | Unknown (seen in coral shrubs) | Unknown | | ClothSim | 25 | Cloth physics simulation | Yes |

§Compression Techniques

Vertices use multiple compression methods to reduce storage:

§Half-Precision Floats (f16)

  • Positions and UVs stored as 16-bit floats instead of 32-bit
  • Reduces size by 50% with minimal precision loss

§Normalized Vectors (u8)

  • Normals, tangents, bitangents stored as unsigned bytes
  • Converted from [-1.0, 1.0] range to [0, 255] range
  • Formula: u8_value = (float_value + 1.0) * 127.5

§Percentage Encoding (Bone Weights)

  • Bone weights stored as u8 representing percentages
  • Converted from [0.0, 1.0] to [0, 255]
  • Formula: u8_value = float_value * 255.0

§Format-Specific Fields

Different vertex formats read/write different subsets of vertex data:

  • Static: Position, UVs, normal, tangent, bitangent
  • Weighted: Static fields + bone indices + bone weights (2 bones)
  • Cinematic: Static fields + bone indices + bone weights (4 bones)
  • Collision: Position only (minimal data)
  • Grass: Position + UVs + normal + special grass data
  • ClothSim: Similar to weighted with cloth-specific data

§Material-Dependent Variations

The exact fields read also depend on the material type. For example:

  • RsTerrain materials read minimal vertex data
  • DefaultMaterial reads full vertex attributes
  • Cloth materials include additional physics data

Structs§

Vertex
Universal vertex structure containing all possible vertex attributes.

Enums§

VertexFormat
Vertex format identifier determining data layout and compression.