Skip to main content

Module skeletal

Module skeletal 

Source
Expand description

Skeletal animation: skinned models with bones and clips, played by the Animator component.

  • Import. FBX (ufbx) and glTF/GLB skins are read with their skeleton, per-vertex bone weights (up to four) and every animation clip. Clips are sampled at 30 frames per second into model-space bone poses; walking clips are made “in place” (the forward drift of the hips is removed, the sway stays) because game code moves the object itself.
  • Humanoid clips without animation files. A rig with recognisable bone names (hips or pelvis, spine, chest, neck, head, upper arm, forearm, thigh, shin, foot — .L/.R, _left/_right and similar) gets procedural clips: Idle, Walk, Run, Talk, Wave, Sit, Wipe (wiping a counter) and Look (glancing around). Clips from the file keep their names; the procedural ones are added only when no clip of that name exists.
  • Playback. Animator picks the clip, speed and looping; changing clip cross-fades over fade seconds. The pose is skinned on the CPU into a DynamicMesh, so any shader, texture and shadow work as for a static model (a few thousand vertices cost microseconds).
// In a script: walk while moving, idle otherwise.
if let Some(a) = ctx.get_mut_of::<Animator>(monster) {
    a.clip = "Walk".into();
}

Structs§

Animator
Plays the clips of a skinned model (MeshRenderer.mesh). Changing clip cross-fades.
AnimatorState
Run-time playback state next to an Animator (not saved).
Clip
An animation sampled at a fixed rate: frames[f][node] is a model-space pose.
Joint
What a vertex weight refers to: a skeleton node and the matrix from the mesh’s bind space to that node.
SkelNode
A node of the skeleton (a bone, or another node the bones hang from).
SkinnedModel
A skinned model: its bind-pose mesh, the weights, the skeleton and the clips.
Trs
Translation, rotation and scale of one bone in model space.

Functions§

load
Loads a skinned model (FBX, glTF, GLB) with its clips, plus procedural humanoid clips.
model
Skinned models by path, loaded once (the asset source is the one given to crate::meshmod::set_assets). None when the file is missing or not skinned.
update
Advances every animator and skins its model. simulate is false in the editor outside Play: the animation then runs on wall-clock time as a preview. Without a ground query the feet are not planted (see update_with).
update_with
update with physics: ground plants the feet (crate::ik::CharacterIk); ragdolls (crate::ragdoll::Ragdoll) run only when simulate is true. Called by the runtime after the physics steps of a frame.

Type Aliases§

GroundQuery
Traces down for foot IK: (from, length, the character) → height of the hit (world space).