Index

Animation

Trial includes support for describing animations – meaning how properties aught to evolve over time. These systems can be used to animate individual properties of objects or full skeleton rigs. The constructs on offer for this are fairly standard, allowing import from model files, including skinning.

The relevant concepts for animation are as follows:

When loading stuff from a model file you will not have to worry about any of the underlying stuff. All you need is an animated-entity and an asset to load the model with. From there you can just play, fade-to, and add-layer/remove-layer to manage your animations on the entities.

Animated-Assets

In order to use the animation pipeline from model files, the model format system needs to provide a subclass of the animation-asset. Currently the only format that supports this is the trial-gltf importer.

Using one should be as simple as this:

(define-asset (workbench model) model-file
    #p"model.gltf")

(make-instance 'animated-entity :animation-asset (asset 'workbench 'model))

Once loaded the asset must contain a skeleton, a hash table of clips, and a hash table of meshes. The animated-entity will automatically extract and reference the properties as needed when you play, fade-to, etc.

Trial will also parse out the following extra animation properties from the model, if supported:

Defining Clips

Aside from the fully automated import of animations and skins from model files as used with the animated-entity, you can also programmatically define animation clips to animate other properties and features.

To do so, use define-clip which has the following general structure:

(define-clip sandstorm
       (strength speed)
  0.0   0.0      (vec 0.0 0.0)
  1.0   0.8      (vec 0.2 0.0)
  1.5   _        (vec 1.0 0.0)
  2.0   1.0      _)

Wherein _ is used to omit a track from a keyframe. By default track interpolations are set to :linear. If you specify :hermite or :cubic for a track, you must wrap each keyframe value in a list to pass the extra values needed for the interpolation handles.

Once a clip is defined, you can retrieve it by its name via clip and use sample to apply the track's effects to an object that contains the properties to be animated.

Note that in general sample is modifying, meaning it updates the values in place to avoid producing garbage.

Animation clips are only meant for tweening properties. There is no support for evaluating functions at certain times or running other more complex code. If you need a system to put together sequences of actions and other such changes, please have a look at action-lists. They are trivial to integrate with Trial and are geared for that use.