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/_rightand similar) gets procedural clips:Idle,Walk,Run,Talk,Wave,Sit,Wipe(wiping a counter) andLook(glancing around). Clips from the file keep their names; the procedural ones are added only when no clip of that name exists. - Playback.
Animatorpicks the clip, speed and looping; changingclipcross-fades overfadeseconds. The pose is skinned on the CPU into aDynamicMesh, 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). Changingclipcross-fades. - Animator
State - 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.
- Skel
Node - A node of the skeleton (a bone, or another node the bones hang from).
- Skinned
Model - 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).Nonewhen the file is missing or not skinned. - update
- Advances every animator and skins its model.
simulateis false in the editor outside Play: the animation then runs on wall-clocktimeas a preview. Without a ground query the feet are not planted (seeupdate_with). - update_
with updatewith physics:groundplants the feet (crate::ik::CharacterIk); ragdolls (crate::ragdoll::Ragdoll) run only whensimulateis true. Called by the runtime after the physics steps of a frame.
Type Aliases§
- Ground
Query - Traces down for foot IK:
(from, length, the character)→ height of the hit (world space).