Repository navigation
Ariadne: a model file's own animation (clips, skins, morph targets) - #1520
Merged
Merged
Conversation
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.
…acOS lanes never started)
…e/animations # Conflicts: # src/cvc/CMakeLists.txt
…e source-list conflict resolved there)
…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
…, 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.How it works
cvc::modelreads the file's animation through assimp:model::posed(clip, t)evaluates them inmerged()'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.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 noduration:lasts as long as its longest clip.GeometryNode::updateVertices), with the node'sfit:kept (scene_fit/apply_scene_fit, whichfit_to_groundis now built on, unchanged).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 throughjointMatrices/morphWeightsuniforms and per-vertex joint/weight attributes, with at most four morph targets. This PR goes the other way:cvc::modelimport item 1 built (cvc::model keeps the file's node tree; merged() places each mesh by it #1467);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'sbones,morphs,morph_weights;clip,clips,find_clip,local_transforms,posed,animated;transform_tdeclared beforemesh.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_clipat realize (the model read from the node's file, the clip found, the node's fit),pose_clip_trackeach frame (posed once per track, written to every node it names).clip.Tests
model_testModelClips, four tests over glTF files built in the test (data: URIs):find_clipby name and number, a STEP channel's step, and a morph target's deltas and rest weight.local_transforms.ariadne_loader_testAnimationClipTracks: 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.cvcgl_ariadne_clip: headlessrealize_sceneandtick_sceneon a skinned glTF bar, 12 checks:fit: { height: 4 }copy's posed points fitted too.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:cvcgl_contour_labandcvcgl_volume_grid_contours(this build has nocvc::planar), andcvcgl_ari_golden, whose seven goldens have the same pixel counts as master.-j 2.PlantLogPowerConvergence.FitsTheLedgerAndPredictsHeldOutSeedstimed 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 passesari validate.Not verified: Linux, macOS, wasm and pycvc; a real-world rigged file (the tests build small glTF files of their own).
Not done
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.CUBICSPLINE) are read as linear.