Skip to content

Ariadne: a model file's own animation (clips, skins, morph targets) - #1520

Merged
transfix merged 16 commits into
masterfrom
scene/model-animation
Nov 24, 2026
Merged

transfix merged 16 commits into
masterfrom
scene/model-animation

Conversation

@transfix

Copy link
Copy Markdown
Owner

A scene can now play a model file's own animation: its nodes' keys, its skins and its morph targets. Before this, a glTF/FBX/Collada model was drawn in its rest pose and nothing in the file moved. This is item 8 of the Ariadne scene-format gap plan.

Stacked on #1515 (item 7, keyframe animation), whose animations: this builds on. Until #1515 merges, this PR's diff includes #1515's commits; merging master in afterwards leaves only this PR's.

scene:
  nodes:
    - { node: robot, source: { file: robot.glb }, fit: { height: 1.8 } }
  animations:
    - animation: walk
      loop: true
      tracks:
        - { node: robot, clip: walk }    # or clip: "0", the first

How it works

  • cvc::model reads the file's animation through assimp:
    • clips: node channels' translation, rotation (a quaternion, slerped) and scale keys in seconds, step or linear, and morph-weight channels;
    • skins: bones on their nodes with their offset (inverse bind) matrices, and each vertex's influences, weights summing to 1;
    • morph targets: position and normal deltas, and their rest weights.
  • model::posed(clip, t) evaluates them in merged()'s vertex order: morph targets are blended, a skinned mesh is placed by its bones (glTF's rule: not by its node), and every other mesh by its node's animated transform. local_transforms(clip, t) gives the nodes alone. instances() is now the same walk over the authored transforms.
  • A clip: track: { node, clip } in an animation draws the node's model posed as far into the clip as the animation has run. loop:, speed:, seek and pause work as for any track, and an animation with no duration: lasts as long as its longest clip.
  • Each frame, the model is posed on the CPU and its points (and normals) are written into the node's mesh in place (GeometryNode::updateVertices), with the node's fit: kept (scene_fit / apply_scene_fit, which fit_to_ground is now built on, unchanged).
  • Refused with a warning:
    • a clip the model does not have (the warning names the ones it has);
    • a node with no model file;
    • a node whose mesh is not the model's (an LOD ladder, a model: in its place), noted in the log.

Why the CPU and assimp, not VTK's glTF importer

The plan suggested vtkGLTFImporter. It skins and morphs on the GPU: it adds its own actors to a renderer and edits their vertex shaders through jointMatrices / morphWeights uniforms and per-vertex joint/weight attributes, with at most four morph targets. This PR goes the other way:

The cost is CPU time per frame per posed node, linear in its vertices. GPU skinning can come later behind the same posed() results.

Changes

  • inc/cvc/model/model.h, src/cvc/model/model.cpp:
    • bone, skin, morph_target, and a mesh's bones, morphs, morph_weights;
    • clip, clips, find_clip, local_transforms, posed, animated;
    • transform_t declared before mesh.
  • src/cvc/model/assimp_io.cpp: read_skin, read_morphs, read_clips (assimp's ticks per second, 25 when unset).
  • scene_geometry: SceneFit, scene_fit, apply_scene_fit, read_scene_node_model.
  • scene_animation.h / loader: SceneAnimationTrack::clip. A clip track needs a node, and its key, keys and state are not used.
  • scene_realize.cpp: bind_clip at realize (the model read from the node's file, the clip found, the node's fit), pose_clip_track each frame (posed once per track, written to every node it names).
  • Schema: an animation track's clip.
  • ARIADNE.md §5.4, Animations: a model's own clip.

Tests

  • model_test ModelClips, four tests over glTF files built in the test (data: URIs):
    • AGltfAnimationReadsAsAClip: a clip's name and length, find_clip by name and number, a STEP channel's step, and a morph target's deltas and rest weight.
    • PosedMovesNodesAndBlendsMorphs:
      • a node slid linearly, one turned with slerp (45 degrees at half time), one stepped (its key replacing the authored translation);
      • morph weights blended (rest 0.25, then 0.5 and 1);
      • the last keys held past the end; local_transforms.
    • ASkinnedMeshFollowsItsBones: two bones on j0 and j1 with one influence a vertex; the bind pose at rest; the head swung a quarter about the elbow, and 45 degrees at half time.
    • AModelWithoutClipsPosesAsMerged.
  • ariadne_loader_test AnimationClipTracks: a clip track's node and clip with no keys; a clip with no node left out; key, keys and state beside a clip not used.
  • New cvcgl_ariadne_clip: headless realize_scene and tick_scene on a skinned glTF bar, 12 checks:
    • Refused: a missing clip, named with the ones the model has; a node with no model file.
    • Start: the first pose at realize.
    • Half way: the head at 45 degrees, the foot where it was.
    • End: a quarter turned, with the animation lasting the clip's 1 s and stopping.
    • Fit: a fit: { height: 4 } copy's posed points fitted too.
    • Seek: a seek back to 0 restores the first pose.

Verified locally

Windows, MSVC, with cvcGL (no examples, no pycvc), on master 63f9de1 plus #1515's branch. The full ctest suite, 8,573 tests at -j 10:

  • Pass: everything but ten.
  • Already failing here: cvcgl_contour_lab and cvcgl_volume_grid_contours (this build has no cvc::planar), and cvcgl_ari_golden, whose seven goldens have the same pixel counts as master.
  • Load: six thread, async, state and lock tests failed under load and pass rerun at -j 2.
  • Timeout: PlantLogPowerConvergence.FitsTheLedgerAndPredictsHeldOutSeeds timed out and passes alone in 62 s.

With the JSON-schema validator built in:

  • ariadne_schema_test: 13 pass (one skip, the without-validator case).
  • ariadne_loader_test: 267 pass.
  • model_test: 28 pass.
  • cvcgl_ariadne_clip's document passes ari validate.

Not verified: Linux, macOS, wasm and pycvc; a real-world rigged file (the tests build small glTF files of their own).

Not done

  • A model: key's model (a node's geometry swapped for a fitted vehicle model) is not posed: its mesh is not the file's own.
  • Cubic-spline keys (glTF CUBICSPLINE) are read as linear.
  • A node not reached from the root by a path is posed by its own transform alone.
  • GPU skinning.

A scene's `animations:` moves its nodes (position, rotation, scale, color,
opacity, visible) or writes state keys along keyframes over the scene clock:
linear, step or smooth (cubic Hermite, Catmull-Rom tangents, flat at the ends)
between keys; once, loop or pingpong at the end; a speed (below 0,
backwards) and autoplay. A node id names every node with it (each repeat:
copy's child), a path a/b one. Each animation's <prefix>.animations.<id>.time,
.playing and .speed are written as it plays and read each frame, so a script
seeks, plays, pauses and changes its speed. An animated scene runs on the
scene clock, as clock: {} would make it. Gap item 7 of the scene-format plan.

- New inc/cvc/ariadne/scene_animation.h / src/cvc/ariadne/scene_animation.cpp:
  SceneAnimation, SceneAnimationTrack, sample_track, advance_animation,
  node_key_width (no renderer).
- Loader: parse_scene_animations; bad tracks left out with a warning.
- Realizer: RealizedScene::animations (SceneAnimationBinding), realize_animations
  (start pose, clock on), tick_scene_animations in tick_scene after physics and
  clip sync.
- docs/ARIADNE.md §5.4 "Animations".
- Tests: ariadne_loader_test AnimationsParsed, AnimationTrackSampling,
  AnimationPlayback; cvcgl_ariadne_animation.
The closed schema (#1464, now on master) gains $defs/animation and
$defs/animation_track, and animations: in both scene definitions (scene: and a
scenes: entry). Checked with the validator built in: ariadne_schema_test 13
(one skip), ariadne_loader_test 265, and cvcgl_ariadne_animation's document
validates.
docs/ARIADNE.md conflicted where this branch adds the Animations paragraph and
#1491 its Picking a node paragraph at the same place in §5.4: both kept.
cvc::model reads a file's animations as clips (node channels' translation,
rotation and scale keys in seconds, step or linear/spherical; morph weight
channels), each mesh's skin (bones on their nodes with their offsets, each
vertex's influences, weights summing to 1) and morph targets (position and
normal deltas, rest weights), through assimp. local_transforms(clip, t) and
posed(clip, t) evaluate them: morph targets blended, a skinned mesh placed by
its bones, every other mesh by its node's animated transform, in merged()'s
vertex order. instances() is the same walk over the authored transforms.

Tests: model_test ModelClips (a glTF animation read as a clip; nodes moved
linear, spherical and step, morph weights blended; a two-bone skin; a model
without clips poses as merged).
An animations: track { node: robot, clip: walk } draws the node's model (the
file its source: names) posed as far into its clip as the animation has run:
the file's node keys, skins and morph weights (cvc::model::posed), on the CPU
each frame, written into the node's mesh in place with its fit: kept. An
animation with no duration: lasts as long as its longest clip. A clip the
model lacks (naming the ones it has), a node with no model file, and a mesh
that is not the model's (an LOD ladder, a model: in its place) are refused.

- scene_animation.h: SceneAnimationTrack::clip; loader parses clip tracks.
- scene_geometry: SceneFit, scene_fit / apply_scene_fit (fit_to_ground is
  built on them, unchanged), read_scene_node_model.
- scene_realize.cpp: bind_clip at realize, pose_clip_track each frame.
- Schema: an animation track's clip.
- docs/ARIADNE.md §5.4 Animations: a model's own clip.
- Tests: cvcgl_ariadne_clip, ariadne_loader_test AnimationClipTracks.
…ment

# Conflicts:
#	src/cvc/ariadne/schema/ari.v1.schema.json
#	src/cvc/tests/ariadne_loader_test.cpp
#	src/cvcGL/ariadne/scene_realize.cpp
…R materials and environment)

# Conflicts:
#	src/cvc/tests/ariadne_loader_test.cpp
# Conflicts:
#	src/cvc/CMakeLists.txt
…, and others

# Conflicts:
#	docs/ARIADNE.md
#	inc/cvc/ariadne/scene_animation.h
#	src/cvc/ariadne/loader.cpp
#	src/cvc/ariadne/schema/ari.v1.schema.json
#	src/cvc/tests/ariadne_loader_test.cpp
#	src/cvcGL/CMakeLists.txt
#	src/cvcGL/ariadne/scene_realize.cpp
# Conflicts:
#	src/cvcGL/CMakeLists.txt
@transfix
transfix enabled auto-merge (squash) November 24, 2026 20:27
@transfix
transfix merged commit acef735 into master Nov 24, 2026
30 checks passed
@transfix
transfix deleted the scene/model-animation branch November 24, 2026 22:00
transfix added a commit that referenced this pull request Nov 25, 2026
Conflict in ari_test_command_test.cpp: #1508 gave FramesAndTimeout's stuck
document 5 s for the same Debug-runner flake that a651d0c gave 4 s;
master's version kept.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant