1 / 99

CSCE 590E Spring 2007

CSCE 590E Spring 2007. Animation and AI. By Jijun Tang. Announcements. April 16 th /18 th : demos Show progress/difficulties/change of plans USC Times will have reporters in the class High school outreach Anyone can contact their high school admin to arrange direct talks to students

tala
Download Presentation

CSCE 590E Spring 2007

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSCE 590E Spring 2007 Animation and AI By Jijun Tang

  2. Announcements • April 16th/18th: demos • Show progress/difficulties/change of plans • USC Times will have reporters in the class • High school outreach • Anyone can contact their high school admin to arrange direct talks to students • Of course, in SC only

  3. Homework • P 655 questions 1 and 2 • 5 points total • Due April 16th

  4. What is animation? • Animation is from the latin “anima” or soul • To give motion • Means to give life Anything you can do in your game to give it more “life” through motion (or lack of motion).

  5. Different types of animation • Particle effects • Procedural / Physics • “Hard” object animation (door, robot) • “Soft” object animation (tree swaying in the wind, flag flapping the wind) • Character animation

  6. Skeletal Hierarchy • The Skeleton is a tree of bones • Often flattened to an array in practice • Top bone in tree is the “root bone” • May have multiple trees, so multiple roots • Each bone has a transform • Stored relative to its parent’s transform • Transforms are animated over time • Tree structure is often called a “rig”

  7. Example

  8. The Transform • “Transform” is the term for combined: • Translation • Rotation • Scale • Shear • Can be represented as 4x3 or 4x4 matrix • But usually store as components • Non-identity scale and shear are rare • Optimize code for common trans+rot case

  9. Examples

  10. Three rotations about three axes Intuitive meaning of values Euler Angles

  11. Problems • Euler Angles Are Evil • No standard choice or order of axes • Singularity “poles” with infinite number of representations • Interpolation of two rotations is hard • Slow to turn into matrices • Use matrix rotation

  12. Rotation Matrix

  13. Quaternions on Rotation • Represents a rotation around an axis • Four values <x,y,z,w> • <x,y,z> is axis vector times sin(angle/2) • w is cos(angle/2) • No singularities • But has dual coverage: Q same rotation as –Q • This is useful in some cases! • Interpolation is fast

  14. Quaternion to Matrix • To convert a quaternion to a rotation matrix:

  15. Matrix to Quaternion • Matrix to quaternion is doable • It involves a few ‘if’ statements, a square root, three divisions, and some other stuff • Search online if interested

  16. Pose

  17. Storage – The Problem • 4x3 matrices, 60 per second is huge • 200 bone character = 0.5Mb/sec • Consoles have around 32-64Mb (Xbox and PS3 have larger, but still limited) • Animation system gets maybe 25% • PC has more memory • But also higher quality requirements

  18. Keyframes • Motion is usually smooth • Only store every nth frame • Store only “key frames” • Linearly interpolate between keyframes • Inbetweening or “tweening” • Different anims require different rates • Sleeping = low, running = high • Choose rate carefully

  19. Linear Interpolation

  20. Higher-Order Interpolation • Tweening uses linear interpolation • Natural motions are not very linear • Need lots of segments to approximate well • So lots of keyframes • Use a smooth curve to approximate • Fewer segments for good approximation • Fewer control points • Bézier curve is very simple curve

  21. Bézier Curves (2D & 3D) • Bézier curves can be thought of as a higher order extension of linear interpolation p1 p1 p2 p3 p1 p0 p0 p0 p2

  22. Non-Uniform Curves • Each segment stores a start time as well • Time + control value(s) = “knot” • Segments can be different durations • Knots can be placed only where needed • Allows perfect discontinuities • Fewer knots in smooth parts of animation • Add knots to guarantee curve values • Transition points between animations • “Golden poses”

  23. Playing Animations • “Global time” is game-time • Animation is stored in “local time” • Animation starts at local time zero • Speed is the ratio between the two • Make sure animation system can change speed without changing current local time • Usually stored in seconds • Or can be in “frames” - 12, 24, 30, 60 per second

  24. Scrubbing • Sample an animation at any local time • Important ability for games • Footstep planting • Motion prediction • AI action planning • Starting a synchronized animation • Walk to run transitions at any time • Avoid delta-compression storage methods • Very hard to scrub or play at variable speed

  25. Animation Blending • The animation blending system allows a model to play more than one animation sequence at a time, while seamlessly blending the sequences • Used to create sophisticated, life-like behavior • Walking and smiling • Running and shooting

  26. Blending Animations • The Lerp • Quaternion Blending Methods • Multi-way Blending • Bone Masks • The Masked Lerp • Hierarchical Blending

  27. Motion Extraction • Moving the Game Instance • Linear Motion Extraction • Composite Motion Extraction • Variable Delta Extraction • The Synthetic Root Bone • Animation Without Rendering

  28. Moving the Game Instance • Game instance is where the game thinks the object (character) is • Usually just • pos, orientation and bounding box • Used for everything except rendering • Collision detection • Movement • It’s what the game is! • Must move according to animations

  29. Linear Motion Extraction • Find position on last frame of animation • Subtract position on first frame of animation • Divide by duration • Subtract this motion from animation frames • During animation playback, add this delta velocity to instance position • Animation is preserved and instance moves • Do same for orientation

  30. Problems • Only approximates straight-line motion • Position in middle of animation is wrong • Midpoint of a jump is still on the ground! • What if animation is interrupted? • Instance will be in the wrong place • Incorrect collision detection • Purpose of a jump is to jump over things!

  31. Composite Motion Extraction • Approximates motion with circular arc • Pre-processing algorithm finds: • Axis of rotation (vector) • Speed of rotation (radians/sec) • Linear speed along arc (metres/sec) • Speed along axis of rotation (metres/sec) • e.g. walking up a spiral staircase

  32. Benefits and Problems • Very cheap to evaluate • Low storage costs • Approximates a lot of motions well • Still too simple for some motions • Mantling ledges • Complex acrobatics • Bouncing

  33. Variable Delta Extraction • Uses root bone motion directly • Sample root bone motion each frame • Find delta from last frame • Apply to instance pos+orn • Root bone is ignored when rendering • Instance pos+orn is the root bone

  34. Benefits • Requires sampling the root bone • More expensive than CME • Can be significant with large worlds • Use only if necessary, otherwise use CME • Complete control over instance motion • Uses existing animation code and data • No “extraction” needed

  35. The Synthetic Root Bone • All three methods use the root bone • But what is the root bone? • Where the character “thinks” they are • Defined by animators and coders • Does not match any physical bone • Can be animated completely independently • Therefore, “synthetic root bone” or SRB

  36. The Synthetic Root Bone (2) • Acts as point of reference • SRB is kept fixed between animations • During transitions • While blending • Often at centre-of-mass at ground level • Called the “ground shadow” • But tricky when jumping or climbing – no ground! • Or at pelvis level • Does not rotate during walking, unlike real pelvis • Or anywhere else that is convenient

  37. Animation Without Rendering • Not all objects in the world are visible • But all must move according to anims • Make sure motion extraction and replay is independent of rendering • Must run on all objects at all times • Needs to be cheap! • Use LME & CME when possible • VDA when needed for complex animations

  38. Mesh Deformation • Find Bones in World Space • Find Delta from Rest Pose • Deform Vertex Positions • Deform Vertex Normals

  39. Find Bones in World Space • Animation generates a “local pose” • Hierarchy of bones • Each relative to immediate parent • Start at root • Transform each bone by parent bone’s world-space transform • Descend tree recursively • Now all bones have transforms in world space • “World pose”

  40. Example

  41. Find Delta from Rest Pose • Mesh is created in a pose • Often the “da Vinci man” pose for humans • Called the “rest pose” • Must un-transform by that pose first • Then transform by new pose • Multiply new pose transforms by inverse of rest pose transforms • Inverse of rest pose calculated at mesh load time • Gives “delta” transform for each bone

  42. Deform Vertex Positions • Each vertex has several bones affect it (the number is generally set to <=4). • Vertices each have n bones • n is usually 4 • 4 bone indices • 4 bone weights 0-1 • Weights must sum to 1 • Deformation usually performed on GPU • Delta transforms fed to GPU • Usually stored in “constant” space

  43. Deform Vertex Positions (2) vec3 FinalPosition = {0,0,0}; for ( i = 0; i < 4; i++ ) { int BoneIndex = Vertex.Index[i]; float BoneWeight = Vertex.Weight[i]; FinalPosition += BoneWeight * Vertex.Position * PoseDelta[BoneIndex]); }

  44. Deform Vertex Normals • Normals are important for shading and are done similarly to positions • When transformed, normals must be transformed by the inverse transpose of the transform matrix • Translations are ignored • For pure rotations, inverse(A)=transpose(A) • So inverse(transpose(A)) = A • For scale or shear, they are different • Normals can use fewer bones per vertex • Just one or two is common

  45. Inverse Kinematics • FK & IK • Single Bone IK • Multi-Bone IK • Cyclic Coordinate Descent • Two-Bone IK • IK by Interpolation

  46. FK & IK • Most animation is “forward kinematics” • Motion moves down skeletal hierarchy • But there are feedback mechanisms • Eyes track a fixed object while body moves • Foot stays still on ground while walking • Hand picks up cup from table • This is “inverse kinematics” • Motion moves back up skeletal hierarchy

  47. Example of Forward Kinematics • http://www.cs.nyu.edu/~lyl209/hw4/doll/

  48. Example of Inverse Kinematics

  49. Single Bone IK • Orient a bone in given direction • Eyeballs • Cameras • Find desired aim vector • Find current aim vector • Find rotation from one to the other • Cross-product gives axis • Dot-product gives angle • Transform object by that rotation

  50. Multi-Bone IK • One bone must get to a target position • Bone is called the “end effector” • Can move some or all of its parents • May be told which it should move first • Move elbow before moving shoulders • May be given joint constraints • Cannot bend elbow backwards

More Related