欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

AnimationBlending

程序员文章站 2022-02-13 20:08:07
...

Animation

Written with StackEdit.

Code Structure for Animation

struct JointPose {
	Quaternion m_rot; //q
	Vector3 m_trans; //t
	F32 m_scale; //s
}

struct AnimationSample{
	JointPose* m_aJointPose;
}

struct AnimationClip{
	Skeleton* m_pSkeleton; //指向骨骼
	F32 m_framePerSecond;
	U32 m_frameCount; 
	AnimationSample* m_aSamples; //每帧的数据
	bool m_isLooping;
}

len(m_aSamples) is m_frameCount+1 when m_isLooping == False, else m_frameCount;

Animation Retargeting

  • Animation is usually compatible with only one skeleton
    • But some closely related skeletons can use these animations
    • Only if engine supports ignoring animation channels that cannot be found in skeleton being animated
    • Advanced research on retargeting animations on totally different skeletons

Continuous Channel Functions

  • According SQT data format for each sample,
    • 10 scalar-valued functions per joint
    • the time continuous functions per joint is a channel
    • channel functions should be smooth and continuous across the entire animation clip
    • many engines LERP bettwen the samples, making it piecewise linear approximations to the underlying continuous functions

Metachannels

  • channels that do not have to do with posing
    • but used to be synchronized with the animation
  • event trigger channel
    • sound, particle effects and so on
  • animated locator
    • special joint
    • such as camera position, orientation, fov…
  • texture coordinates scrolling
  • texture animation
  • animated parameter
    • material
    • lighting

Skinning and Matrix Palette Generation

Attaching the vertices of a 3D mesh to a posed skeleton is call skinning

Per-Vertex Skinning Information

  • a skinned mesh is attached to a skeleton by means of its vertices.
  • each vertex can be attached to one or multiple joints
    • if multiple, the position becomes weighted average of the positions that it would have assumed had it bound to each joint independently
    • so each vertex information should including
      • the index of joints to which it is bound
      • the weighting factor for each joint
    • the maximal no of bound joints is usually 4
  • data structure:
    struct Skinned Vertex{
    	float m_position[3];
    	float m_normal[3];
    	float m_u, m_v; //u,v for texture cordinates
    	U8 m_jointIndex[4];
    	float m_jointWeight[3];
    }
    

Mathematics of Skinning

  • Skinning matrix: transform vertices from original position in bind pose to current position that correspond to the current pose.
    • always in model space
  • One joint example
    • (Kj)W = (BjM_{j \to M})-1CjM_{j \to M} MMW_{M \to W}
    • VMC^C_M = VMB^B_MKj_{j}
  • Multiple Joints:
    • VMC^C_M = Σi=0N1\Sigma_{i=0}^{N-1} wiVMB^B_MKji_{j_i}

Animation Blending

more than 1 animation clip contribute to the final pose of character

LERP Blending

  • (PLERP)j = LERP((PA)j, (PB)j, β\beta) = (1 - β\beta)(PA)j + β\beta(PB)j
  • PskelLERP_{skel}^{LERP} = { (PLERP)j } |j=0N1 ^{N-1}_{j=0}~
  • β\beta is called the blending percentage or blend factor
  • SQT format data is easy to blend, not as 4X4 matrix
  • T and S: vector LERP, Q: LERP or SLERP
  • independently on each joint, parallel calculated

Applications of LERP Blending

  • Temporal Blending
    • finding intermediate poses between sampled poses
  • Motion continuity: Cross Fading
    • clip transitions may pop, not smooth
    • C0 continuity: path trace smooth
    • C1 continuity: velocity smooth
    • C2 continuity: second derivatives of the motion path smooth
    • C3 and higher …
    • LERP blending used in transitions to achieve C0 or C1 continuity is called cross fading
    • overlap time, β\beta from 0 to 1
    • types of cross fading
      • smooth transition: Clip A and B play simultaneously, β\beta changes over time
      • Frozen transition: A stops and B gradually takes over
        • usually used in unrelated clips
      • blend factor β\beta functions
        • linear, cubic
        • ease-in, ease-out
      • Core poses
        • every clip starts and ends in these poses
        • C0 continuity: ensure two core poses match
        • C1 continuity: authoring a single smooth animation into A end and B start

Directional Locomotion

pivotal movement: always face to where it turns
targeted movement: moving sideways, backward, forward, keeping its face to a target

  • targeted movement
    • forward, strafe left, strafe right
    • LERP blend between two adjacent clips, β\beta according to angle
    • backward not included because of legs crossing each other
      • one feasible approach: use to hemispherical blends, one for forward and another for backward; explicit transition animation is played between hemisphere switch
  • pivotal movement
    • always play forward clips
    • slightly leaning sideways when turning
    • author three clips: move straight forward, extremely left turn, extremely right turn
    • LERP blending between them to create desired turn pose

Complex LERP Blends (DELETE 583)

相关标签: Animation

推荐阅读