maths & technologies for games animation: practicalities

17
Maths & Technologies for Games Animation: Practicalities CO3303 Week 3

Upload: mikasi

Post on 12-Jan-2016

32 views

Category:

Documents


0 download

DESCRIPTION

Maths & Technologies for Games Animation: Practicalities. CO3303 Week 3. Today’s Lecture. Animation Issues Transformation Decomposition Keyframes Interpolation Revisited Playing Animations Blending Multiple Animations Motion Extraction. Animation Issues. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Maths & Technologies for Games Animation: Practicalities

Maths & Technologies for GamesAnimation: Practicalities

CO3303

Week 3

Page 2: Maths & Technologies for Games Animation: Practicalities

Today’s LectureToday’s Lecture

1. Animation Issues

2. Transformation Decomposition

3. Keyframes

4. Interpolation Revisited

5. Playing Animations

6. Blending Multiple Animations

7. Motion Extraction

Page 3: Maths & Technologies for Games Animation: Practicalities

Animation IssuesAnimation Issues

• We have seen a method to interpolate a model’s pose between keyframes

• Surely we can now build an animation system?

• No– Several major practicalities to deal with– Need further refinements to the previous theory

Page 4: Maths & Technologies for Games Animation: Practicalities

Animation IssuesAnimation Issues

• Assume our game has:– 30 characters with 64 bones, 60 animations each– Animations are 5 seconds long, store 8 keyframes / s

• Memory usage = 30*64*60*5*8* sizeof(keyframe)• If our keyframe is a 4x4 matrix then = 295Mb• If a quaternion, position and scaling, then = 184Mb

– Too much memory used• Implies poor cache performance

• Can improve on this

Page 5: Maths & Technologies for Games Animation: Practicalities

Animation IssuesAnimation Issues

• Sometimes need to play more than one animation at the same time– E.g. Character running and firing a gun– Or character standing and firing– Would like to blend the firing animation with the

character’s other motion – 2 animations at once– Simple interpolation insufficient

• Also, how to combine movement in the scene with movement in the animation?

• Will look briefly at several practical animation techniques to address these issues

Page 6: Maths & Technologies for Games Animation: Practicalities

Transformation DecompositionTransformation Decomposition

• Each bone in a model has a separate transform– Each relative to its parent, forming a hierarchy

• Last year we used matrices for this hierarchy• Now we have seen that matrices are not a good

choice for animation in general– Expensive to interpolate & too much storage

• So we decompose the transform into:– Rotation, translation, scale etc.

• Use vectors for translation and scale• Quaternions for rotation

Page 7: Maths & Technologies for Games Animation: Practicalities

Transformation DecompositionTransformation Decomposition

• Can write a quaternion-based transformation class– With the same functionality as a matrix class– But able to interpolate rotations efficiently

• Use for current transformations of animated models – one for each bone in hierarchy

• However, when storing keyframes, we can remove uneeded elements– E.g. no scaling – don’t store scaling

• Will reduce the storage by 40% or so

Page 8: Maths & Technologies for Games Animation: Practicalities

• Key frames authored by artists– Based on needs of animation

• Must make sure it suits our needs too:– Rotations small enough for interpolation method (e.g.

nlerp)– No unsupported components (e.g. shear)

• All bones key-framed at once or independently

Key FramesKey Frames

• Might pre-process keyframes:– Precalculate values (e.g. sin θ)– Add extra frames to improve

motion when using approximations

Page 9: Maths & Technologies for Games Animation: Practicalities

Interpolation RevisitedInterpolation Revisited

• Choices with interpolation:– Use lerp or normalised lerp

(nlerp) always– Or use slerp sometimes– Or use slerp approximations

(sometimes)

• First choice can be the best– Unless there are large angular movements in your

animation (rare)

• Less than 5% inaccurate for < 45 degrees

nlerp

Page 10: Maths & Technologies for Games Animation: Practicalities

Higher Order InterpolationHigher Order Interpolation

• We may wish to use more complex interpolations:– To produce smooth curves

• Higher order interpolation needs less key frames– Up to ten times less– Only a little extra data– Overall greatly aids our memory problem

• Example: cubic Bezier curve formula

• Use as a replacement for linear interpolation– Needs extra points to define curve

Page 11: Maths & Technologies for Games Animation: Practicalities

Playing AnimationsPlaying Animations

• Each animation has a length– Usually measured in seconds

• Within that time there will be several key frames– Around 0.5 to 8 per second - may not be evenly spread

• Our model will know its current animation position– E.g. 1.2 seconds into an 2 second walk animation

• Need a fast method to extract the which key frames are needed at this point– Need the frame before, the frame after and the

interpolation value t

Page 12: Maths & Technologies for Games Animation: Practicalities

Playing AnimationsPlaying Animations

• For each animation store a single structure:– Number of bones in animation– Length (in seconds)– Key frame data

• When a model plays an animation it stores an additional structure:– Pointer to the animation it is using– Current position (time) in the animation

• Can be converted to key frames + t value

– Speed of playback

• This way several models can use the same animation at the same time

Page 13: Maths & Technologies for Games Animation: Practicalities

Blending AnimationsBlending Animations

• Game characters often do several things at once:– E.g. Running and shooting

• Many animations only use part of the body– E.g. A waving animation

• Like to use different animations at the same time• And/or apply them only to parts of the body

• Possible with further linear interpolation of several animations:– A first lerp to get pose 1, a second lerp to get pose 2– Then a final lerp to blend these two together

Page 14: Maths & Technologies for Games Animation: Practicalities

Multiway BlendingMultiway Blending

• Can add weightings to the animations:FinalPose = Pose1 * w1 + Pose2 * w2– If w1>w2, then Pose1 is more prominent– Almost identical to quaternion and vector linear

interpolation from last week

• Can blend more than two animations too• This is called multiway blending• Uses:

– Smoothly changing from a run to a walk– Different animations for legs and upper body– Separate facial animations– All of the above happening at the same time

Page 15: Maths & Technologies for Games Animation: Practicalities

Bone MasksBone Masks

• Can also have per-bone weights for blending animations - called a bone mask

• For a waving animation, the bones in the arm would have a weight of 1.0– The animation fully affects the arm

• The rest of the body would have 0.0– No effect on the body– Don’t need to store key frames for these parts

• The shoulder would have a weight of 0.5– Blending the waving animation with any underlying

animation

Page 16: Maths & Technologies for Games Animation: Practicalities

Motion ExtractionMotion Extraction

• A run animation actually moves the character in the scene – even if our model is stationary

• How to match the motion stored in the animation and the position of our models?

• Use motion extraction techniques, generally:– Analyse movement of a root bone in the animation– Subtract that motion from the animation – so the

animation doesn’t move– Replicate the movement onto our actual scene model

• The result will look the same, but with the scene model tracking the animation root

Page 17: Maths & Technologies for Games Animation: Practicalities

Animation SummaryAnimation Summary

• Many aspects to a full animation system– A very intricate areas of games development

• Only able to touch upon the issues in the time available here– Matrices, quaternions, interpolation are just the

building blocks

• Look at simple, but functional system in the labs• In the real world you will find more complex

systems in use– But with the same principles