Qt3D-Animation-Framework

From Qt Wiki
Revision as of 15:37, 16 January 2017 by Sean Harmer (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

En Ar Bg De El Es Fa Fi Fr Hi Hu It Ja Kn Ko Ms Nl Pl Pt Ru Sq Th Tr Uk Zh

Details

  • Summary: Add efficient support for various kinds of animation to Qt 3D
  • Project lead: Antti Maatta & Kevin Ottens (ervin)
  • Project participant: Antti Määttä (anmaatta)
  • Branch: wip/animation

Goals

  • Perform animations on the backend of Qt 3D for more throughput and to free up the main thread
  • Support key frame animation
  • Support morph target animation
  • Support Qt Quick style animation elements

Details

Here are some random thoughts on long term features. Not all of this needs to be in 5.9 by a long shot and may reach out as far as 5.11 or beyond. We can introduce various features over several versions. Driver animations are likely the simplest to implement.

Key frame animation is well described in the Game Engine Architecture book, including for joints. In particular take note of the layering and interactions with other typical subsystems such as inverse kinematics, rag-doll, constraints and state machines. For 5.9 I'd suggest we get the basic animation pipeline in place and extend it to higher levels and more interactions in 5.10 and beyond.

The Blender docs also have some nice documentation about animation features used in Blender which we may wish to support: https://www.blender.org/manual/en/animation/index.html

  • Key frame animation
    • F-Curves
      • Key framed values
      • Interpolation
        • Discrete
        • Linear
        • Bezier
      • Extrapolation
        • Constant
        • Linear
    • Skeletal animation (maybe for 5.10?)
      • Joints, Skeletons, Poses
      • Animation aspect calculates matrix palette
      • Skinning done in renderer
    • Blending of animations
      • Weighted flat list
      • Blend tree
      • Both of the above?
    • Post animation tweaks:
      • Inverse kinematics (maybe for 5.10?)
      • Rag doll (requires physics aspect)
    • Driver animation
      • Properties updated by user-provided functions or from a preset list of options
      • For user-provided, possibly use functor approach as per texture image data
      • Implemented on backend
    • Markers
      • Events in the timeline
      • Could be used to indicate when to switch between cameras or when to play another animation clip etc
    • Constraints (separate aspect maybe)
      • Easier for some types of animation, e.g. animating a camera along a path defined by a curve

Preliminary plans for 5.9

Here's an early version of plans for the Animation Framework on 5.9

Animation

  • KeyframeAnimation
    • Positions(time values)
    • Duration(max(Positions))
    • Values(Transform, matrix, quaterion, vectorN, float, double,...)
    • Provided as QVariant array, transformed to raw values
    • Support subset of Qvariant types
    • Tangents(for bezier curve interpolation)
    • Constant, Linear, Cubic, Quadratic interpolation
    • BeginRepeatMode, EndRepeatMode,
      • Null, Constant, Repeat
    • Easing(affects only interpolator)
  • Custom animation
    • Sampled with functor
  • AnimationGroup
    • Inherits Animation
    • Group multiple animations together to act as one animation
    • Time set to group is propagated to all group subanimations
  • AnimationController
    • Inherits AnimationGroup
    • Provides time(position) to animations
    • Input time is provided as parameter, or using time from aspect
      • Seamless control of animation using property animations or user control
    • Add animations to controller to animate them
    • Select which animations to update
    • scale, offset parameters control how time is propagated to animations
    • AnimationController is also an animation, so that users can create animation chains, sequences

Animator

  • ScaleAnimator, RotationAnimator, TranslationAnimator, TransformAnimator, ShaderVariableAnimator, VisibilityAnimator, WeightAnimator, SkinnedMeshAnimator, MorphingMeshAnimator...
  • Animator connects animations with animatable target
  • Each animation added to animator has a ’channel’ with a weight parameter, which tells how much this channel affects the target
  • This allows blending of animations
    • For example to blend walking animation and running animation.
    • In future, add physics channel to blend with physics simulation

Morphing Mesh

  • Provides support for mesh morphing(blend shape)
    • Base mesh + morph targets
  • Subclass of QGeometryRenderer
    • The Attributes in geometry provide base mesh
  • MorphTargets
    • MorphTarget contans set of attributes providing the target coordinates
    • Weight, telling how much this morph target is applied to the base
  • Normalized method
    • (1 - w0 - ... wn) * base + w0 * target0 + ... + wn * targetn
  • Relative method
    • base + w0 * target0 + ... + wn * targetn
  • Rendering Morphing Mesh
    • Either in shader, which requires material support
    • Or SW, which doesn’t require material support
    • Animations affect only the weights, selecting right attributes based on weights is done at render time.
  • Picking/View calculation
    • For accurate picking/view, requires morphing done in SW
    • For inaccurate picking/view, provide bounding geometry with each morph target and blend those too

Skinned Mesh

  • Skeletal animation of mesh using joints, bones, skeleton
    • Not in 5.9 though
  • Provide simple skinned mesh method, with skeleton defined using QTransforms from Entity hierarchy.
  • Generate matrix palette from array of QTransforms
    • i-th transform in the array corresponds to the i-th matrix in the palette
    • At-rest transform either provided separately or recorder when the palette is set
  • The final matrix palette is not calculated in the animation aspect, but in the render aspect, after the world transformations have been calculated
  • Skinned mesh rendering
    • In shader, requires material support
    • Matrix palette provided in specific way to support custom shaders
  • Picking, view calc
    • Similar problems to morphing mesh
    • For accurate picking, SW skinning is required

Animation Aspect

  • Frontend
    • Control of the animation
    • Propagates time from controllers to animations
  • Backend
    • Number crunching(keyframe interpolation)
  • There is a problem with QTransform(and perhaps some others)
    • The animated scale, rotation, translation must be sent back from backend to frontend every frame wasting time and effort
      • Many times the values are not needed in the frontend
    • Solution 1, don’t animate transform or any other property, which is mirrored in frontend
      • - Not flexible at all, no reflection from animations to the user
    • Solution 2, take the hit, efficiency is the same as animating in frontend(minus optimized interpolation)
      • - Complex animations cause unnececcary work.
      • + Animation fully reflected to the user
    • Solution 3, optimize frontend-backend communication
      • ???

Animation import

  • Support loading of animations from some file formats
    • Collada support