Skip to content

Instantly share code, notes, and snippets.

@shrinktofit
Last active August 10, 2022 04:12
Show Gist options
  • Save shrinktofit/ff18ff176a6c38d26b80eb445098280e to your computer and use it in GitHub Desktop.
Save shrinktofit/ff18ff176a6c38d26b80eb445098280e to your computer and use it in GitHub Desktop.
Animation: distinguish bone nodes

Abstract

In our engine, bones exist in form of scene node. We can't tell if a node denotes a bone or not. This sometimes becomes obstacle in animation system.

Problem Statement

Obstacles

Why do we need to distinguish bone nodes from normal? I'll list some cases.

Before we start, assume we're processing such a typical hierarchy:

graph TB
    Root("Root<br/>{components}: Animation")-->Skin("Skin<br/>{components}: SkeletalMeshRenderer")
    Root-->Pelvis("Pelvis 🦴")
    Pelvis-->Spine("Spine 🦴")
    Pelvis-->LeftThigh("LeftThigh 🦴")
    Pelvis-->RightThigh("RightThigh 🦴")
    Pelvis-->PelvisEffect("PelvisEffect ➕<br/>{components}: ParticleSystem")
    Spine-->LeftShoulder("LeftShoulder 🦴")
    LeftShoulder-->LeftUpperArm("LeftUpperArm 🦴")
    LeftUpperArm-->LeftLowerArm("LeftLowerArm 🦴")
    LeftLowerArm-->LeftHand("LeftHand 🦴<br/>{components}: ➕ ParticleSystem")
    LeftHand-->LeftIndexFinger("LeftIndexFinger 🦴")
    LeftHand-->Sword("Sword ➕<br/>{components}: ParticleSystem")
    LeftThigh-->LeftUpperLeg("LeftUpperLeg 🦴")
    style PelvisEffect stroke-width:2px,stroke-dasharray: 5 5
    style Sword stroke-width:2px,stroke-dasharray: 5 5

In which:

  • This portion of scene hierarchy is instantiated from a model prefab imported from external model file(glTF, FBX).

  • Nodes may have a special <components>: child line indicates its components.

  • Root is the instantiated prefab root. Animation component or animation controller component is attached to root node.

  • Nodes suffixed with a 🦴 means this node participates in skinng process.

  • Nodes or components suffixed with a ➕ means this node or component is later-added as a prefab overrides. These usually are attachments that user want to have the attachment follow the transform of bone.

Blending

Suppose we're going to blend TRS animations on above hierarchy, we need to sort out which nodes partipates in animating and blending.

First, all bone nodes should participate in animating and blending. Other nodes, in theory, might also be animated but in practicle users don't need these node to be animated.

Given that we don't know the boundary of bone node and normal node, animation on bone node is implemented as normal node TRS animation. Under this assumption, we can not construct a effective buffer to blend poses.

What is bone?

In skinning process, vertices are affected by bones. There might be the essential defininition of bone. Follow this thread, we

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment