Skip to content

Instantly share code, notes, and snippets.

@gszauer
Last active August 20, 2020 21:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gszauer/5e4850492c035acccc5e06c19ebc1508 to your computer and use it in GitHub Desktop.
Save gszauer/5e4850492c035acccc5e06c19ebc1508 to your computer and use it in GitHub Desktop.
gameplay3d::Animation breakdown

Core classes

class Animation

Defines a generic property animation. To run an animation you must play an AnimationClip. Every Animation has the default clip which will run from begin-end time. You can create additional clips to run only parts of an animation and control various runtime characteristics, such as repeat count, etc.

TODO: Fill ouy with own words

class Animation::Channel

Defines a channel which holds the target, target property, curve values, and duration. An animation can have 1 or more channels. All typical simple property animations will have 1 channel. Skeletal animation will have 1 channel per joint to be animated.

An animation channel here sounds like what i consider to be an animation track. It's a single curve

TODO: Fill ouy with own words

class AnimationClip

Defines the runtime session of an Animation to be played.

This class looks like a view / playhead situation. IE it specifies that i want frames X to Y in this Animation to be an animation clip. Go ahead and loop the playback for it. The class also provides a cross fade solution, but i think that should be handled at a different level.

class AnimationClip::Listener

Defines an animation event listener. Facilitates callbacks for start, end and time events.

class AnimationValue

Defines a running animation value which can have one or more floats. IE, sampling a vec3 track does not result in a vec3, rather an AnimationValue object. I like this, it's an easy way to avoid having to template the animation classes! It plays along with the "Sample Result" class i was considering previously. Legit just a vector of floats with component size (and count).

Unfortunitaley, the actual memory pointer _value is dynamically allocated in the constructor at runtime. So you can't have a linear array of animation values that is laid out in a linear fashion. Depending on the access patterns of the value, this might not be an issue! I want to avoid following double pointers if possible.

class AniamtionTarget

Defines an interface allowing animation to target an object for changing its animation properties. Can create new Animation objects. Aniamtion targets can be scalar or transform. An animated property is registered by id. To get the id of a prop, you need it's target (scalar|transform) and it's name (cstr). Once there is an id. Animation Channels can be added or removed.

Property ID's such as "translate" or "scale" are hard coded to enums and converted by AnimationTarget::getPropertyId, which is a gian switch statement. This means there is no generic way to bind to say a float. The targets could probably be expanded? Not sure if that's the intended use case or not tough...

Virtaul methods:

  • getPropertyId - Given a string returns an int. Big ol switch statement. Returns a property id that is to be used later.
  • getAnimationPropertyComponentCount - Returns the number of components in an animation property. IE a vector3 would have a 3
  • getAnimationPropertyValue - Returns the current value of an animated property based on id (IE return the values from Transform as an AnimationTarget)
  • setAnimationPropertyValue - Sets the value of an animated property based on id (IE write the values of an AnimationTarget to a Transform).

Transform is an animation target. It overrides all methods except for getPropertyId. getAnimationPropertyValue is a giant switch statement for example that fills in the provided value struct from the floating point values of the Transform class in a big switch statement. The set version works the other way, given an aniamted value it sets the transforms properties.

class AnimationController

Defines a class for controlling game animation. It contains a list of animation clips to run trough. I'm not sure where blending happens.

Before a transform is changed it calls: Transform::suspendTransformChanged(); and after Transform::resumeTransformChanged(); This looks like it just prevents transform changed events from firing from the sampling of an animation.

Support classes

TODO: Add curve headers

Wiki Info

https://github.com/gameplay3d/gameplay/wiki/Animation

The gameplay::Animation class can animate properties of classes that extend gameplay::AniamtionTarget.

gameplay::Transform, gameplay::Node and gameplay::MaterialParamater are animation targets.

Animations can be created on the animation target. The gampley::AnimationTarget class provides methods to create animations.

Curves are defined in gameplay::Curve

A cahracter animation is multiple Animation objects targeting multiple joints. Gameplay encoder can group all the animations on joints leading to a common root into a single animation object. In the encoder use -groupAnimations option.

gameplay::AnimationClip is created from gameplay::Animation, it is a snapshot of the animation that can be played back and manupulated.

It looks like the assumption is that one Animation object contains multiple clips. And that a clip is defined by start and end frames. A-la milkshape. It's naiveley assumed that all animations run at 60 FPS.

Blending belongs to gameplay::AnimationClip as a weight property. The AnimationClip class also contains a crossFade function.

Callbacks are provided via gameplay::AnimationClip::Listener.

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