How do I add animation to a usd model?

Asked on 2024-07-30

1 search

To add animation to a USD model, you can use blend shape animations in Reality Composer Pro. Here's a step-by-step guide based on the information from the WWDC sessions:

  1. Blend Shape Animation:

    • Blend shape animations allow you to smoothly transition from one pose to another, creating lifelike movements. These are commonly used for animating a character's face or body by blending between a series of different shapes.
    • For example, you can animate a plant from a wilted to a healthy state and vice versa.
  2. Setting Up Blend Shape Animation:

    • The blend shape animation API consists of a blend shape weights mapping, blend shape weights component, and two ways to execute the animations: procedurally or via USD animation.
    • The blend shape weights mapping allows you to set a weight associated with a blend target. You set up the blend targets on an entity, and each target can have weights associated with it. You can set a weight from zero to one.
  3. Implementing in Code:

    • Find the model entity that has the model component from the entity hierarchy.
    • Get its mesh resource and create the blend shape weights mapping from the mesh resource.
    • Create the blend shape weights component from the mapping.
    • To update the blend weights at runtime, get the blend shape weights component from the entity.
    • Get a copy of the blend shape weights set to assign weight values into the set.
    • Update all the weight values by blend weight index in the blend shape weight set and set it to zero, which indicates a healthy plant.
    • To transition from healthy to wilted, gradually increment or decrement the value with an easing function.
    • Assign the new weight values to the blend shape weights component so they will take effect.

For a detailed walkthrough, you can refer to the session Compose interactive 3D content in Reality Composer Pro (27:11).

Relevant Sessions:

  1. Compose interactive 3D content in Reality Composer Pro
  2. Optimize your 3D assets for spatial computing
  3. What’s new in USD and MaterialX

These sessions provide comprehensive insights into working with USD models and adding animations.