Support model bodygroups and skin selection #15

Open
opened 2026-03-17 00:56:02 +00:00 by kit · 1 comment
Owner

MDL models can have multiple bodygroups (swappable mesh parts) and skins (material sets). Currently we always render the default bodygroup/skin configuration.

Bodygroups

  • MDL files define bodygroups as sets of alternative meshes for different body parts (e.g., head variants, holstered weapons, hat on/off)
  • Each entity has a bodygroup bitmask that selects which variant to show per group
  • The server needs to stream the bodygroup value per entity
  • The client needs to parse the bodygroup definitions from the MDL and show/hide the correct sub-meshes

Skins

  • MDL files define skin families — each skin is an alternative set of materials for the entire model
  • Entity:GetSkin() returns the active skin index
  • Server needs to stream the skin index per entity
  • Client swaps material assignments based on the skin table in the MDL header

Server side

  • Add bodygroups (u32 bitmask) and skin (u16) to EntityState
  • Read from the entity's networked data

Client side

  • Parse bodygroup and skin tables from MDL headers
  • When rendering, select the correct meshes per bodygroup bit
  • When applying materials, use the skin table to remap material indices

Relates to

  • #5 (asset rendering — MDL parsing pipeline)
MDL models can have multiple bodygroups (swappable mesh parts) and skins (material sets). Currently we always render the default bodygroup/skin configuration. ## Bodygroups - MDL files define bodygroups as sets of alternative meshes for different body parts (e.g., head variants, holstered weapons, hat on/off) - Each entity has a bodygroup bitmask that selects which variant to show per group - The server needs to stream the bodygroup value per entity - The client needs to parse the bodygroup definitions from the MDL and show/hide the correct sub-meshes ## Skins - MDL files define skin families — each skin is an alternative set of materials for the entire model - `Entity:GetSkin()` returns the active skin index - Server needs to stream the skin index per entity - Client swaps material assignments based on the skin table in the MDL header ## Server side - Add `bodygroups` (u32 bitmask) and `skin` (u16) to `EntityState` - Read from the entity's networked data ## Client side - Parse bodygroup and skin tables from MDL headers - When rendering, select the correct meshes per bodygroup bit - When applying materials, use the skin table to remap material indices ## Relates to - #5 (asset rendering — MDL parsing pipeline)
Author
Owner

Part of the broader asset rendering effort in #5. Requires server-side streaming of bodygroup/skin selection per entity.

Part of the broader asset rendering effort in #5. Requires server-side streaming of bodygroup/skin selection per entity.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
kit/gmod-web-stream#15
No description provided.