Skip to main content

Module skeleton

Module skeleton 

Source
Expand description

Skeleton, pose, and CPU linear blend skinning.

These types form the substrate for skeletal animation. A Skeleton defines the bone hierarchy and bind-pose inverses. A Pose holds local-space transforms for each joint. JointMatrices::compute runs forward kinematics and returns the per-joint skinning matrices ready for apply_skin.

§Workflow

// Once at startup:
let skeleton = Skeleton::new(joints);
let base_pose = Pose::identity(skeleton.joint_count());

// Each frame (in a plugin at phase::ANIMATE or later):
ctx.resources.insert(my_pose); // write current pose

// SkeletonPlugin at phase::POST_SIM reads the pose and pushes a
// SkinnedMeshUpdate to ctx.output.skinned_mesh_updates.

// After runtime.step(), in the app:
for u in &output.skinned_mesh_updates {
    renderer.resources_mut()
        .write_mesh_positions_normals(queue, u.mesh_id, &u.positions, &u.normals)
        .ok();
}

Structs§

Joint
A single joint in a skeleton hierarchy.
JointMatrices
Per-joint skinning matrices computed from a Skeleton and Pose.
Pose
Per-frame local-space transforms for each joint.
Skeleton
A joint hierarchy with bind-pose inverse matrices.

Constants§

MAX_JOINTS
Maximum number of joints in a skeleton.

Functions§

apply_skin
Apply CPU linear blend skinning to a mesh.