200 likes | 373 Views
Character Animation. Fundamental Concepts The Skeletal Hierarchy Bones are usually arranged in a tree hierarchy. Associated with each bone is a transform that determines how that bone’s motion differs from its parent.
E N D
Character Animation Fundamental Concepts The Skeletal Hierarchy Bones are usually arranged in a tree hierarchy. Associated with each bone is a transform that determines how that bone’s motion differs from its parent. This root bone is often the pelvis or the shoulders or sometimes halfway down the back. Animations change the transforms of each bone over time and thus create motion. Forward kinematics: motion is transmitted “forward” down the hierarchy of bones. Inverse kinematics (IK): where an end-bone’s position is fixed at a certain place and the bones higher up the hierarchy are moved to keep it there Rig: the organization of bones and how they are joined to each other in a model The Transform A particular bone’s orientation, translation, scale, and shear A transform expresses a geometrical transformation, and in almost every animation system, these are linear transforms (straight lines to straight lines). Any 4×3 matrix can be represented as a combination of the four elements: translation, rotation, scale, and shear.
Character Animation Fundamental Concepts Euler Angles Euler angles are a set of three angles that can describe any orientation of an object in 3D space. These three angles each describe a rotation around a particular axis. Each rotation is applied to the result of the previous one. Different xyz rotation sequences may result in the same final orientation.
Character Animation Fundamental Concepts The 3 × 3 Rotation Matrix Describing the orientation as a 3×3 matrix Storage space problem Quaternions Quaternions are the best method of representing rotations without the polar problems of Euler angles or the large size and interpolation problems of 3×3 matrices. Quaternions (x,y,z,w): (x,y,z) defines an axis of rotation, and the length of the vector (x,y,z) defines the sine of half the rotation angle. The value of w defines the cosine of half the rotation angle Because a quaternion defines an axis and a rotation angle, it shows no preference to any particular orientation. This leads to good interpolation properties. In most cases, interpolation between two orientations always occurs along the path of least rotation, which is a desirable thing when interpolating. Quaternions are almost always the animation programmer’s representation of choice for orientations, even though they might not be very intuitive to work with.
Character Animation Fundamental Concepts Animation versus Deformation Pose: The collective transforms of a skeleton at a certain moment in time. Animation is the process of changing the pose over time. Animationsdo not know about vertices, they simply specify poses, Deformation is the process of taking a single pose generated by animation and applying it to a mesh’s vertices, moving them to the correct position so they are ready to be rendered. Deformation does not know about the concept of time, simply transferring poses onto vertices. This provides a clear separation between rendering and animation to allow the renderer to run at a different rate than the rest of the game, Models and Instances A single model is a description of an object consisting of meshes with vertices, triangles, textures, and so on. For an animation system, a model includes a skeleton that holds the properties of each bone and how they are linked together. A single model can be used multiple times in a scene, each use is an instance of the model
Character Animation Fundamental Concepts Animation Controls Animation control is a data structure that links a particular instance in the scene with a particular animation, and stores information such as the animation’s speed and start time, and can be told to stop, pause, or change speed. Since each instance may have many controls hanging from it (one for each animation playing on that instance for different bone set), and each animation may have many controls pointing to it (one for each instance playing that animation), controls usually live in two linked lists: one for instances and one for animations.
Character Animation Animation Storage Un-optimized storage space with 4X3 matrix for each bone/frame/animation: TotalSpace = 220MB Decomposition and Constant Elimination For each bone, decompose the 4×3 matrix into its four components (translation, orientation, scale, and shear) and check which components are constant or identity over the lifetime of the animation. For each animation, store constant values just once and eliminate identity values completely. Keyframes and Linear Interpolation To use fewer frames per second Store animations at a lower speed and interpolate between the keyframes to produce the intermediate frames, using linear interpolation (quaternions)
Character Animation Animation Storage Higher Order Interpolation Most motions are not straight lines; they are some sort of curve. Therefore, it probably makes sense to use a curve rather than a straight line for reconstruction by interpolation. T1 and T2 are intermediate (implicit) frames (F1->T1) (T2->F2) Looping Many animations loop which must be continuous with no pops, either in value or in velocity. The first and last frames match exactly and are smooth.
Character Animation Playing Animations Local time: to sample an animation, pick the time in the animation in which it is interested. Global time: the time that actually passes in the game. An animation’s local time may pass at a different rate to global time. Real-world time: Animation systems do not generally care about real-world time. The speed of an animation is the ratio between the passing of global time and the incrementing of local time. E.g. 1-same, ½-slow, 2-faster Scrubbing An animation system can deal with multiple global times simultaneously. The ability to sample animations at any time (within a certain sensible range around the global time) is called scrubbing (random access) (no incremental animation data).
Character Animation Blending Animations The capability to play back multiple animations and blend them together. The Lerp Linear interpolation or lerp: the weighted blend between two transforms. Linear interpolation between two bones, with a single weight determining the amounts of both bones. Blending two translations, scales, shears: vector calculation Blending two rotations (quaternions): perform a standard blend for each component and then normalize the result. Multiway Blending Method 1: To perform a sequence of two-way blends, starting with the first animation, and sequentially blending in each subsequent animation by the supplied amount, with event weight (e.g. 0.5+0.5) between two. The results change according to the order of the animations because of uneven weight influences (later animations will have more influences) Method 2: Supply a weight for each animation. Multiplying each animation by its weight when summing. Final result against the total weight.
Character Animation Blending Animations Bone Masks Apply an animation to only a few select bones, rather than to the whole skeleton. Bone mask is simply a list of numbers, generally a value from 0.0 to 1.0, one for each bone in the skeleton, and it is applied to an animation. When the animation is blended with others, the mask is multiplied by the animation’s overall weight when performing the blend. The result of this multiplication of the bone mask and the overall weight is called the effective weight, and is what is actually used when blending the multiple animations. Masked Lerp Apply bone masks to lerp of two animations. Hierarchical Blending Blending (sub)sets of animations which are organized hierarchically.
Character Animation Motion Extraction Animation vs. Motion Animation: change relative positions or transforms of internal bones of a render object instance (character) (residual motion) Motion: change position and/or angle of a render object instance as whole. Problem: how to sync animation and motion of a character Motion extraction is the process of taking an animation and deriving the overall movement of a character from it. Linear Motion Extraction (LME) Compute average velocity of root bone between its positions in the first and last frames in the animation. Use this average velocity as the character’s motion velocity (straight line motion) Composite Motion Extraction (CME) Use same LME approach for rotation motion, but linear (non-curve) motion. Solution: encode the translational movement as always being relative to the current orientation of the instance.
Character Animation Motion Extraction Variable delta extraction Let the instance always follow the motion of the root bone exactly. For each frame, the animation system samples the root-bone’s transform at the current time, samples (or remembers) the root-bone’s transform on the previous frame, and finds the difference between them, which is the delta. This delta is then applied to the instance’s position and orientation. Finding your roots Synthetic root bone (SRB): to create a new root bone, one whose only purpose is to allow the animator to define exactly what he wants to happen to the game orientation of the object. With an SRB, the animator can (1) directly control how the character moves through the world in an animation and (2) control the exact relationship between the graphical appearance of the mesh due to the animation of its physical Skeleton and where the game thinks it is. When transitioning or blending between two animations, the position of the SRB in both is kept constant, and all the other bones in the skeleton are blended. If a tree animates in a forest … Separation, or not separation, of game and graphics
Character Animation Mesh Deformation Local pose: a sequence of transforms, each relative to a parent transform in a manner described by the connections in the skeleton. Use this local pose to deform the vertices of a mesh for drawing. Stage 1: Transform each bone into world Space Convert local pose to a global pose or a world pose, where each transform describes the bone’s position in the world, without needing any other frame of reference except for the shared world origin and orientation. Transform root bone to world space by the instance’s position and root bone’s local transform. Transform children bone to world space by their parent bone’s world position and their local transforms. Put all bones in an array using pre-order or breath first traversal. Stage 2: Find the delta from the rest pose First is to transform the mesh out of its rest/default/binding pose before transforming it into the pose in animation. (inverse transform of default pose). Combine the world transforms of the vertices created in stage 1 and the inverse transforms of their rest pose, to create the final transform in animation.
Character Animation Mesh Deformation Stage 3: Deform the vertex positions Up to 4 bones to affect/deform a vertex, where each bone may have different weight on the vertex. This allows the vertex deformation code to do the following for each vertex: vec3 FinalPosition = {0, 0, 0}; for ( i = 0; i < 4; i++ ) { intBoneIndex = Vertex. Index[ i] ; float BoneWeight = Vertex. Weight[ i] ; FinalPosition += BoneWeight * ( Vertex. Position * PoseDelta[ BoneIndex] ) ; } Stage 4: Deform the vertex normals Standard method: computer inverse of 3X3 matrix of the vertex. Optimization: The transformation is orthonormal. That is, its basis vectors are of unit length and at right angles to each other. An orthonormal matrix’s inverse is its transpose. Inverse matrices of deltas between two transforms Only deform normalsof the first few listed bones in decreasing sorted weights.
Character Animation Inverse Kinematics Forward kinematics: parent bone -> child bone Inverse Kinematics: child bone -> parent bone Single-Bone IK The process of orienting a particular bone in a desired direction. First, find the vector along which the bone being rotated must point. Then find the vector along which the bone currently points. With these two vectors, find the rotation that maps one to the other using standard matrix or quaternion methods and apply this rotation to the bone. MultiboneIK This is used where the application wants a given bone to end up in a certain place and wants to allow movement of a certain number of bones higher up the skeletal tree to allow this motion. The number of bones allowed to move is typically constrained in some way, and the IK solver is informed which bones it may move and which it may not. Chain of bones linked by joints along up-ward parent-child hierarchy of tree of bones.
Character Animation Inverse Kinematics Multibone IK Cyclic coordinate descent algorithm: At each stage, pick one of the joints to move and leave the other joints fixed in their current state. Measure the error between the current position of the end effectorand the target, such as the physical distance between them. Then move the chosen joint to try to minimize this error. Typically start with the last or (lowest on the hierarchy) bone in the chain. If the result is still not satisfied, starting from the last bone again. IK by Interpolation Animation by Example: The artist supplies a number of example poses, and the animation system blends between them to create a composite pose. These poses can capture all the details of the complex movement of the neck, head, and shoulders that naturally happens as the character looks around. The most common version uses nine different poses, e.g. 9 directions of a character’s head
Character Animation Attachments Frequently, animated characters carry objects. The game needs to know, for a certain pose, where the weapon needs to be placed. Solution: Make a bone in the character’s skeleton that represents the weapon’s root bone. The mesh that is both character and weapon in one is used to deform the combined mesh. In the case of separate character and weapon meshes, the bone will not be used by the mesh deformation routines, but its world-space transform will be used to set the root transform of the weapon mesh. Collision Detection In many games, collision detection does not interface with animation at all, except in as much as the game asks the animation how the root bone moves. In these cases, approximating objects by a bounding box, sphere, ellipsoid, or other simple object oriented the same way as the game instance’s world-space transform is perfectly adequate. Solution for more accurate collision detection: Store a bounding volume for each bone, that bounds the vertices influenced by that bone during deformation. The ray being tested then checks for intersection against each of these bounding volumes.