Multimedia System and Networking UTD Slide- 1 University of Texas at Dallas B. Prabhakaran Blending & State Machines.

Slides:



Advertisements
Similar presentations
First of all – lets look at the windows you are going to use. At the top you have a toolbar, with all your various tools you can use when customising your.
Advertisements

Animation in Video Games presented by Jason Gregory
SETTING UP A PROJECT Adobe Premiere Pro CS6. Getting started… Adobe Premiere Pro project file stores links to all the video and sound files-aka…clips.
7.2. AI E NGINE AND S TEERING B EHAVIOUR I Design of an AI Engine and introduction to steering in game AI.
Blending & State Machines CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.
1/1/ / faculty of Electrical Engineering eindhoven university of technology Introduction Part 2: Data types and addressing modes dr.ir. A.C. Verschueren.
The Assembly Language Level
Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop.
Verbs and Adverbs: Multidimensional Motion Interpolation Using Radial Basis Functions Presented by Sean Jellish Charles Rose Michael F. Cohen Bobby Bodenheimer.
Channels & Keyframes CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.
SE 313 – Computer Graphics Lecture 14: Armatures Lecturer: Gazihan Alankuş 1.
Chapter 2: Algorithm Discovery and Design
Character Animation CSE 191A: Seminar on Video Game Programming Lecture 5: Character Animation UCSD, Spring, 2003 Instructor: Steve Rotenberg.
3D orientation.
CS274 Spring 01 Lecture 5 Copyright © Mark Meyer Lecture V Higher Level Motion Control CS274: Computer Animation and Simulation.
1 Programming & Programming Languages Overview l Machine operations and machine language. l Example of machine language. l Different types of processor.
Animation. Outline  Key frame animation  Hierarchical animation  Inverse kinematics.
Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.
Hashing General idea: Get a large array
Chapter 1 Program Design
Chapter 2: Algorithm Discovery and Design
© 2010 Delmar, Cengage Learning Chapter 4: Creating Animation.
© 2011 Delmar, Cengage Learning Chapter 8 Building Complex Animations.
Chapter 5.2 Character Animation. CS Overview Fundamental Concepts Animation Storage Playing Animations Blending Animations Motion Extraction Mesh.
CASE Tools And Their Effect On Software Quality Peter Geddis – pxg07u.
February 21, 2000Robotics 1 Copyright Martin P. Aalund, Ph.D. Computational Considerations.
Game Physics – Part IV Moving to 3D
Collision and Animation Systems in Games Jani Kajala Lead Programmer / Chief Technology Officer, Pixelgene Ltd (0)
CS 450: COMPUTER GRAPHICS QUATERNIONS SPRING 2015 DR. MICHAEL J. REALE.
Inverse Kinematics.
Week 5 - Wednesday.  What did we talk about last time?  Project 2  Normal transforms  Euler angles  Quaternions.
1 Performing Spreadsheet What-If Analysis Applications of Spreadsheets.
Multimedia System and Networking UTD Slide- 1 University of Texas at Dallas B. Prabhakaran Channels & Keyframes.
Compiler Construction
Computer Graphics 2 In the name of God. Outline Introduction Animation The most important senior groups Animation techniques Summary Walking, running,…examples.
Photo Story 3 Importing Pictures. When you create a new Photo Story, the first thing that you will do is import pictures. You can import pictures from.
IT253: Computer Organization
Blending & State Machines CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.
Moving Around in Scratch The Basics… -You do want to have Scratch open as you will be creating a program. -Follow the instructions and if you have questions.
Adobe Flash CS3 Revealed
How to Build a CPU Cache COMP25212 – Lecture 2. Learning Objectives To understand: –how cache is logically structured –how cache operates CPU reads CPU.
Motion Planning in Games Mark Overmars Utrecht University.
Maths & Technologies for Games Animation: Practicalities CO3303 Week 3.
Multimedia System and Networking UTD Slide- 1 University of Texas at Dallas B. Prabhakaran Rigging.
Introduction to Flash Animation CS 318. Topics Introduction to Flash and animation The Flash development environment Creating Flash animations  Layers.
University of Windsor School of Computer Science Topics in Artificial Intelligence Fall 2008 Sept 11, 2008.
CPSC 252 The Big Three Page 1 The “Big Three” Every class that has data members pointing to dynamically allocated memory must implement these three methods:
09/16/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Environment mapping Light mapping Project Goals for Stage 1.
Games Development 2 Entity Update & Rendering CO3301 Week 2, Part 1.
Lecture 10 Page 1 CS 111 Summer 2013 File Systems Control Structures A file is a named collection of information Primary roles of file system: – To store.
M1G Introduction to Programming 2 3. Creating Classes: Room and Item.
CHAPTER 14 Classes, Objects, and Games XNA Game Studio 4.0.
Introduction to Computer Programming - Project 2 Intro to Digital Technology.
LECTURE 4 Logic Design. LOGIC DESIGN We already know that the language of the machine is binary – that is, sequences of 1’s and 0’s. But why is this?
Access Module Implementing a Database with Microsoft Access A Great Module on Your CD.
CSCI1600: Embedded and Real Time Software Lecture 15: Advanced Programming Concepts Steven Reiss, Fall 2015.
Program Design. Simple Program Design, Fourth Edition Chapter 1 2 Objectives In this chapter you will be able to: Describe the steps in the program development.
Animation Animation is about bringing things to life Technically: –Generate a sequence of images that, when played one after the other, make things move.
The Stingray Example Program CMT3311. Stingray - an example 2D game May be useful as a simple case study Most 2D games need to solve generic problems.
2014 Animation Programming for Music Video Games Jessica Scott Harmonix Music Systems, Inc. October 10, 2014 #GHC
CGDD 4003 Character Animation. The Skeletal Hierarchy (aka the “rig”) Based on the concept of bones Each bone has exactly one parent Each bone has a transform.
3D Animation 3. Animation Dr. Ashraf Y. Maghari Information Technology Islamic University of Gaza Ref. Book: The Art of Maya.
Object Animation CMT3317. Do you need to do animation? We consider ways of animating composite objects – that have a number of different parts e.g. a.
Multi-Axis Tabular Loads in ANSYS Workbench
Layers in Adobe After Effect
Programming and File Management Part 2
Introduction to Events
Synthesis of Motion from Simple Animations
Blending & State Machines
ECE 352 Digital System Fundamentals
Presentation transcript:

Multimedia System and Networking UTD Slide- 1 University of Texas at Dallas B. Prabhakaran Blending & State Machines

Multimedia System and Networking UTD Slide- 2 University of Texas at Dallas B. Prabhakaran Blending & Sequencing Now that we understand how a character rig works and how to manipulate animation data, we can edit and play back simple animation The subject of blending and sequencing encompasses a higher level of animation playback, involving constructing the final pose out of a combination of various inputs We will limit the discussion to encompass only pre- stored animation (channel) data as the ultimate input. Later, we will consider how to mix in procedural animation…

Multimedia System and Networking UTD Slide- 3 University of Texas at Dallas B. Prabhakaran Blending & Sequencing Most areas of computer animation have been pioneered by the research and special effects industries Blending and sequencing, however, is one area where video games have made a lot of real progress in this area towards achieving interactively controllable and AI characters in complex environments… The special effects industry is using some game related technology more and more (battle scenes in Lord of the Rings…)

Multimedia System and Networking UTD Slide- 4 University of Texas at Dallas B. Prabhakaran Animation Playback

Multimedia System and Networking UTD Slide- 5 University of Texas at Dallas B. Prabhakaran Poses A pose is an array of values that maps to a rig If the rig contains only simple independent DOFs, the pose can just be an array of floats If the rig contains quaternions or other complex coupled DOFs, they may require special handling by higher level code Therefore, for generality, we will assume that a pose contains both an array of M≥0 floats and an additional array of N≥0 quaternions

Multimedia System and Networking UTD Slide- 6 University of Texas at Dallas B. Prabhakaran Animation Clip Remember that the AnimationClip stores an array of channels for a particular animation (or it could store the data as an array of poses…) This should be treated as constant data, especially in situations where multiple animating characters may simultaneously need to access the animation (at different time values) For playback, animation is accessed as a pose. Evaluation requires looping through each channel. class AnimationClip { void Evaluate(float time,Pose &p); }

Multimedia System and Networking UTD Slide- 7 University of Texas at Dallas B. Prabhakaran Animation Player We need something that ‘plays’ an animation. We will call it an animation player At it’s simplest, an animation player would store a AnimationClip*, Rig*, and a float time As an active component, it would require some sort of Update() function This update would increment the time, evaluate the animation, and then pose the rig However, for reasons we will see later, we will leave out the Rig* and just have the player generate and output a Pose

Multimedia System and Networking UTD Slide- 8 University of Texas at Dallas B. Prabhakaran Animation Player class AnimationPlayer { float Time; AnimationClip *Anim; Pose P; public: void SetClip(AnimationClip &clip); const Pose &GetPose(); void Update(); };

Multimedia System and Networking UTD Slide- 9 University of Texas at Dallas B. Prabhakaran Animation Player A simple player just needs to increment the Time and access the new pose once per frame The first question that comes up though, is what to do when it gets to the end of the animation clip? –Loop back to start –Hold on last frame –Deactivate itself… (return 0 pose?) –Send a message…

Multimedia System and Networking UTD Slide- 10 University of Texas at Dallas B. Prabhakaran Animation Player Some features we may want to add for a more versatile animation player include: –Variable playback rate –Play backwards (& deal with hitting the beginning) –Pause It’s kinda like a DVD player…

Multimedia System and Networking UTD Slide- 11 University of Texas at Dallas B. Prabhakaran Animation Player The animation player is a basic component of an animation blending & sequencing system Many of these might ultimately be combined to get the final blended pose. This is why we only want it to output a pose By the way, remember the issue of sequential access for keyframes? The animation player should ultimately be responsible for tracking the current keyframe array (although the details could be pushed down to a specific class for dealing with that)

Multimedia System and Networking UTD Slide- 12 University of Texas at Dallas B. Prabhakaran Animation Player As we will use players and static poses as basic components in our blending discussion, we will make a notation for them:

Multimedia System and Networking UTD Slide- 13 University of Texas at Dallas B. Prabhakaran Animation Blending

Multimedia System and Networking UTD Slide- 14 University of Texas at Dallas B. Prabhakaran Blending Overview We can define blending operations that affect poses A blend operation takes one or more poses as input and generates one pose as output In addition, it may take some auxiliary data as input (control parameters, etc.)

Multimedia System and Networking UTD Slide- 15 University of Texas at Dallas B. Prabhakaran Generic Blend Operation

Multimedia System and Networking UTD Slide- 16 University of Texas at Dallas B. Prabhakaran Cross Dissolve Perhaps the most common and useful pose blend operation is the ‘cross dissolve’ Also known as: Lerp (linear interpolation), blend, dissolve… The cross dissolve blender takes two poses as input and an additional float as the blend factor (0…1)

Multimedia System and Networking UTD Slide- 17 University of Texas at Dallas B. Prabhakaran Cross Dissolve The two poses are basically just interpolated The DOF values can use Lerp, but the quaternions should use the ‘Slerp’ operation (spherical linear interpolate)

Multimedia System and Networking UTD Slide- 18 University of Texas at Dallas B. Prabhakaran Cross Dissolve: Handling Angles If a DOF represents an angle, we may want to have the interpolation check for crossing the +180 / -180 boundary Unfortunately, this complicates the concept of a DOF (and a pose) a bit more. Now we must also consider that some DOFs behave in different ways than others

Multimedia System and Networking UTD Slide- 19 University of Texas at Dallas B. Prabhakaran Cross Dissolve: Quaternions Also, for quaternions, we may wish to force the interpolation to go the ‘short way’:

Multimedia System and Networking UTD Slide- 20 University of Texas at Dallas B. Prabhakaran Cross Dissolve: Stand to Walk Consider a situation where we want a character to blend from a stand animation to a walk animation

Multimedia System and Networking UTD Slide- 21 University of Texas at Dallas B. Prabhakaran Cross Dissolve: Stand to Walk We could have two independent animations playing (stand & walk) and then gradually ramp the ‘t’ value from 0 to 1 If the transition is reasonably quick (say <0.5 second), it might look OK Note: this is just a simple example of a dissolve and not necessarily the best way to make a character start walking…

Multimedia System and Networking UTD Slide- 22 University of Texas at Dallas B. Prabhakaran Cross Dissolve: Walk to Run Blending from a walk to a run requires some additional consideration…

Multimedia System and Networking UTD Slide- 23 University of Texas at Dallas B. Prabhakaran Cross Dissolve: Walk to Run Lets say that we have a walk and a run animation Each animation is meant to play as a loop and contains one full gait cycle They are set up so the character is essentially moving in place, as on a treadmill Let’s assume that the duration of the walk animation is d walk seconds and the run is d run seconds Let’s also assume that the velocity of the walk is v walk and run is v run (these represent the speed that the character is supposed to be moving forward, but keep in mind, the animation itself is in place)

Multimedia System and Networking UTD Slide- 24 University of Texas at Dallas B. Prabhakaran Cross Dissolve: Walk to Run We want to make sure that the walk and run are in phase when we blend between them One could animate them in a consistent way so that the two clips both start at the same phase But, let’s assume they aren’t in sync… Instead, we’ll just store an offset for each clip that marks some synchronization point (say at the time when the left foot hits the ground) We’ll call these offsets o walk and o run

Multimedia System and Networking UTD Slide- 25 University of Texas at Dallas B. Prabhakaran Cross Dissolve: Walk to Run Let’s assume that f is our dissolve factor (0…1) where f=0 implies walking and f=1 implies running The resulting velocity that the character should move is simply: –v'=Lerp(f,v walk,v run ) To get the animations to stay in phase, however, we need to adjust the speeds that they are playing back This means that when we’re halfway between walk and run, the walk will need to be sped up and the run will need to be slowed down

Multimedia System and Networking UTD Slide- 26 University of Texas at Dallas B. Prabhakaran Cross Dissolve: Walk to Run As we are sure that we want the two to stay in phase, we can just lock them together For example, we will just say that if t walk is the current time of the walk animation, then t run should be:

Multimedia System and Networking UTD Slide- 27 University of Texas at Dallas B. Prabhakaran Cross Dissolve: Walk to Run To speed up the walk animation appropriately, we will define a rate r walk that the walk animation plays at (default would be 1.0)

Multimedia System and Networking UTD Slide- 28 University of Texas at Dallas B. Prabhakaran Basic Math Blend Operations We can also define some blenders for basic math operations:

Multimedia System and Networking UTD Slide- 29 University of Texas at Dallas B. Prabhakaran Basic Math Blend Operations Its not always obvious how to define consistent behaviors between independent DOFs and quaternions Quaternion addition and subtraction don’t really give an expected result Addition of orientations implies that you start with the first orientation and then you do a rotation from there that corresponds to how the second orientation is rotated from neutral This behavior is more like quaternion multiplication (although quaternion multiplication is not commutative)

Multimedia System and Networking UTD Slide- 30 University of Texas at Dallas B. Prabhakaran Add & Subtract Blenders A reasonable behavior for an add blender could be: For subtraction, we could multiply by the conjugate of the quaternion

Multimedia System and Networking UTD Slide- 31 University of Texas at Dallas B. Prabhakaran Scale Blender As we want our quaternions to stay unit length, we don’t really want to scale them In any case, scaling a quaternion has no effect on the resulting orientation! Instead, we can think of scaling as moving towards or away from 0 (I.e., scaling by a number less than 1 brings us closer to 0, scaling by >1 takes us away from 0…) Therefore, we could define the scale blender as:

Multimedia System and Networking UTD Slide- 32 University of Texas at Dallas B. Prabhakaran Math Operations: Body Turn

Multimedia System and Networking UTD Slide- 33 University of Texas at Dallas B. Prabhakaran Body Turn As an example of math blending operations, consider a character that walks and turns One approach to achieving this is to have an underlying walk animation and ‘layer’ (add) some body turn on top of it We make a static ‘look_right’ pose and a static ‘default’ pose The subtraction gives us the difference between look_right and default If we scale this and then add it on top of the underlying walk animation. The scale we use can be based on how hard the character is turning (-1…1)

Multimedia System and Networking UTD Slide- 34 University of Texas at Dallas B. Prabhakaran Body Turn We can also speed this up by precomputing the subtraction and making a combined add/scale blender

Multimedia System and Networking UTD Slide- 35 University of Texas at Dallas B. Prabhakaran Bilinear Blend

Multimedia System and Networking UTD Slide- 36 University of Texas at Dallas B. Prabhakaran Bilinear Blend Bilinear blend is an extension to the cross dissolve that takes four input poses and two interpolation parameters s & t

Multimedia System and Networking UTD Slide- 37 University of Texas at Dallas B. Prabhakaran Bilinear Blend Bilinear (and trilinear…) blends can be useful for a wide range of applications As one example, consider a video game character who has to aim a weapon The character must be able to stand still and aim at any object within +/- 135 degrees to the side to side and +/- 45 degrees up and down An animator can supply key poses at 45 degree increments in both directions Then, for any desired angle, we can find the right four targets and do a bilinear blend

Multimedia System and Networking UTD Slide- 38 University of Texas at Dallas B. Prabhakaran Combine Blender We can also have a blender that combines poses in different ways For example, we might want to treat the upper body separately from the lower body, or treat each limb separately, etc. We can use different blenders for each body section and then combine them into a final pose This also implies that we can use smaller pose vectors in each body section to save computations and memory The actual combine operation could just have lookup tables that map index values of the incoming poses to index values of the final pose

Multimedia System and Networking UTD Slide- 39 University of Texas at Dallas B. Prabhakaran Mirror Blender Mirroring animations across the x=0 plane can be an effective way to save memory and complexity It requires that a character is symmetrical (or close enough…) Like the combine blender, mirroring requires some sort of table as input that describes how to mirror each DOF Different DOFs will need different treatment Also, DOFs on the right need to be swapped with DOFs on the left

Multimedia System and Networking UTD Slide- 40 University of Texas at Dallas B. Prabhakaran Clamp Blender DOF limits can be implemented as a blend operation This can be for performance, as it allows precise control over when (and if) DOF limits are used For example, consider that DOF limits should not be necessary when cross dissolving between two animations (assuming the animations are already within the legal limits) Use of add, subtract, and scale operations may require clamping for safety

Multimedia System and Networking UTD Slide- 41 University of Texas at Dallas B. Prabhakaran Multi-Track Blending One can also think of an animation blending system as being similar to a multi-track audio (or video) editing system Different animations (or poses) can be placed in different ‘tracks’ and each track could have some additional controls and custom behaviors

Multimedia System and Networking UTD Slide- 42 University of Texas at Dallas B. Prabhakaran Animation State Machines

Multimedia System and Networking UTD Slide- 43 University of Texas at Dallas B. Prabhakaran State Machines Blending is great for combining a few motions, but it does not address the issue of sequencing different animations over time For this, we will use a state machine We will define the state machine as a connected graph of states and transitions At any time, exactly one of the states is the current state Transitions are assumed to happen instantaneously

Multimedia System and Networking UTD Slide- 44 University of Texas at Dallas B. Prabhakaran State Machines

Multimedia System and Networking UTD Slide- 45 University of Texas at Dallas B. Prabhakaran State Machines In the context of animation sequencing, we think of states as representing individual animation clips and transitions being triggered by some sort of event An event might come from some internal logic or some external input (button press…)

Multimedia System and Networking UTD Slide- 46 University of Texas at Dallas B. Prabhakaran Simple Jump State Machine Consider a simple state machine where a character jumps upon receiving a JUMP_PRESS message

Multimedia System and Networking UTD Slide- 47 University of Texas at Dallas B. Prabhakaran More Complex Jump

Multimedia System and Networking UTD Slide- 48 University of Texas at Dallas B. Prabhakaran State Machine (Text Version) stand{JUMP_PRESSstand2crouch } stand2crouch { JUMP_RELEASEhop ENDcrouch } crouch{JUMP_RELEASEtakeoff } takeoff{ENDfloat } hop{ENDfloat } float{NEAR_GROUNDland } land{ENDstand }

Multimedia System and Networking UTD Slide- 49 University of Texas at Dallas B. Prabhakaran State Machine Extensions Global entry transitions Event masking Fancy states Modifiers Logic in states Combining blenders & state machines State machines within state machines

Multimedia System and Networking UTD Slide- 50 University of Texas at Dallas B. Prabhakaran Creating State Machines Typing in text Graphical state machine editor Automated state machine generation (motion graphing)

Multimedia System and Networking UTD Slide- 51 University of Texas at Dallas B. Prabhakaran Character Mover

Multimedia System and Networking UTD Slide- 52 University of Texas at Dallas B. Prabhakaran Character Mover When we want an interactive character to move around through a complex environment, we need something to be responsible for the overall placement of the character We call this the character mover We can think of the mover as a matrix that positions the character’s root

Multimedia System and Networking UTD Slide- 53 University of Texas at Dallas B. Prabhakaran Character Mover Usually, we think of the mover matrix as being on the ground right below the character’s center The mover sits perfectly still when the character isn’t moving and generally moves at a smooth constant rate as the character walks The character’s root translation would be animated relative to the mover

Multimedia System and Networking UTD Slide- 54 University of Texas at Dallas B. Prabhakaran Character Mover: Walking Consider a walk animation where we have the character is moving at a rate of v meters/second The actual animation is animated as if on a treadmill (but the root may still have some translation (bobbing up/down back/forth, left/right)) If the mover is moving at v meters/second though, the animation will look correct

Multimedia System and Networking UTD Slide- 55 University of Texas at Dallas B. Prabhakaran Character Mover The mover might be coded up to do some simple accelerations, decelerations, turning, and collision detection with the ground and walls Depending on the speed that the mover is moving, we might select blend to an appropriate gait animation

Multimedia System and Networking UTD Slide- 56 University of Texas at Dallas B. Prabhakaran Character Mover Sometimes, we want the character to do more complex moves, such as a dive roll to the right In this situation, we might want to explicitly animate what the mover should do This data can be written out with the animation and stored as additional channel data (3 translations, 3 rotations) These extra channels can be blended like any other channel, and then finally added to the mover when we pose the rig

Multimedia System and Networking UTD Slide- 57 University of Texas at Dallas B. Prabhakaran Project 3 Load an.anim file and play back a keyframed animation on a skinned character.

Multimedia System and Networking UTD Slide- 58 University of Texas at Dallas B. Prabhakaran Anim File animation { range [time_start] [time_end] numchannels [num] channel { extrapolate [extrap_in] [extrap_out] keys [numkeys] { [time] [value] [tangent_in] [tangent_out] … } channel … }

Multimedia System and Networking UTD Slide- 59 University of Texas at Dallas B. Prabhakaran Project 3 The first 3 channels will be the root translation (x,y,z) After that, there will be 3 rotational channels for every joint (x,y,z) in the same order that the joints are listed in the.skel file

Multimedia System and Networking UTD Slide- 60 University of Texas at Dallas B. Prabhakaran Project 3 Suggested classes: –Keyframe: stores time, value, tangents, cubics… –Channel: stores an array (or list) of Keyframes –Animation: stores an array of Channels –Player: stores pointer to an animation & pointer to skeleton. Keeps track of time, accesses animation data & poses the skeleton. Optional: –Rig: simple container for a skeleton, skin, and morphs –Pose: array of floats (or just use stl vector) –ChannelEditor: it’s always nice to separate editor classes from the data that they edit