Character Animation CGDD 4003 The Skeletal Hierarchy (aka the “rig”) Based on the concept of bones Each bone has exactly one parent Each bone has a transform Not necessarily a matrix (later) How it differs from its parent If its transform is identity matrix Same translation Same rotation (orientation) The root bone has no parent (e.g. pelvis) Rotations/translations are relative to local coordinates There are also synthetic root bones (ground shadows) Kinematics Forward kinematics Moving a parent bone moves the children Easy to program, hard to animate Inverse kinematics (IKs) Moving child bones affects parent bone Easier for animators Solve iteratively Need to draw this on the board… Euler Angles (pronounced “Oi-luh”) 3 angles to describe orientation around 3 axes Order of rotations is important! Two rotations can result in the same orientation Usually stored in a 3x3 matrix. Two similar rotations have similar values in matrices Linear blending will be ok Size is large Enter the Quaternion Another way to represent rotations Great for interpolation (thus, common) Uses 4 components (x, y, z, w) In general, (x, y, z) is the axis of rotation Length of (x, y, z) is sine of half the rotation angle w is the cosine of half the rotation angle (20° vs. 340°) Animation vs. Deformation Animation Changing poses to the skeleton over time No sense of the vertices that surrounds it Deformation Applying the skeleton to the mesh No sense of animation (time) Animation Controls Need to be able to start, stop, determine time, change speed Have a control for each animation for each instance of object Animation Storage How big? Store 4x3 matrix for each bone, for each frame 30 fps, 50 bones 5 major characters, 100 animations each 15 minor characters, 20 animations each Animation lasts 4 seconds 𝑆𝑝𝑎𝑐𝑒 = 30𝑓𝑝𝑠 ∙ 4𝑠𝑒𝑐 ∙ 50𝑏𝑜𝑛𝑒𝑠 ∙ 4 ∙ 3 ∙ 4 ∙ 5 ∙ 100 + 15 ∙ 20 220𝑀𝐵 Xbox 360 has 512MB and Wii has 88MB The animation system takes up nearly ¼ of all memory? Can we do better? = Animation Storage Eliminate unnecessary data Most bones don’t need shear, scaling Some don’t need translation (hips, knees, elbows) Some characters hardly move! Space Scaling, Shearing, Translation = 3 Rotation (quaternions) = 4 T.K. Baha from Borderlands Animation Storage Assume: 10% of bones shear 20% of bones scale 50% have translation 90% have orientation One bone / frame is now: 4𝑏𝑦𝑡𝑒𝑠 ∙ 0.1 ∙ 3 + 0.2 ∙ 3 + 0.5 ∙ 3 + 0.9 ∙ 4 = 24 𝑏𝑦𝑡𝑒𝑠 vs. the 48 bytes previously However, we have to reconstruct the 4x3 matrix for each bone now! Note: We’re now at 110MB, still 5 times bigger than budget for Wii. Can we do better? Animation Storage Obvious candidate: don’t use 30 fps! Keyframing: set important poses and then interpolate (old animation technique) On “average”, 10 keyframes per second 1/3 the space = 37MB! OK for Xbox (64MB), bad for Wii (22MB) Keyframing problems: Loses data Note: we’re at 37MB. Can we do better? Animation Storage Linear interpolation between frames 𝑟𝑒𝑠𝑢𝑙𝑡 = 1 − 𝑡 ∙ 𝐹1 + (𝑡 ∙ 𝐹2 )) 𝑡 is time and 𝐹1 and 𝐹2 are frames Higher Order Interpolation Use Bezier (pronounced “Beh-zee-ay”) Cubic function, with continuity (C0, C1, C2…) Define controls at endpoints (𝑇1 and 𝑇2 ) Can drop the memory usage by ¼ Continuity Image from Autodesk.com Playing Animations Local time is in reference to the animation E.g. 0.0 – 5.0 for a 5 second animation Can also normalize from 0.0-1.0 and have playback speed Global time is the elapsed time May not match the local time Can pause Blending Animations Playback of multiple animations together Linear Interpolation (aka “lerp”) For quaternions Normalizing lerp (nlerp) – each component is linearly blended and then renormalized Spherical lerp (slerp) – the most common Log-quaternion lerp – complex Blending Animations Bone masks: Imagine waving and walking at the same time 0.0 = don’t use this bone when blending 1.0 = completely include that bone 0.5 = fractional blend Motion Extraction Things get hard when the character moves Animator may/not model at (0,0,0) What happens during walking? Sliding feet? What about climbing a ledge? Must match world/physics engine! Motion Extraction: “process of taking an animation and deriving the overall movement of a character” – from your text! Motion Extraction What if the model doesn’t stay at the origin? Linear Motion Extraction Take position of root bone at first/last frame Divide by duration Works great for straight lines Not so great for running in circles Composite Motion Extraction Takes into account the rotation Variable Delta Extraction – just ask the root bone how much it moved since the last frame Example Mesh Deformation 1. Transform each bone into World Space 1. 2. 3. 4. Start at the root of the skeleton Multiply it’s transform by the instance’s transform (you now know where the root bone is in the world) Take the transform of each child bone and multiply it by the root bone’s world transform Use recursion all the way down Mesh Deformation 2. Find the delta from the rest pose 1. 2. 3. Deform the vertices 1. 2. 4. Must “undo” the rest pose using the inverse transform Multiply world transform by the inverse Each vertex is affected by several bones (4 max) Influential bones stored as a list of bytes Deform the vertex normals Other Considerations