Advanced Computer Graphics: Animation James Gain Department of Computer Science University of Cape Town [email protected] Advanced Computer GraphicsCollaborative Visual Computing Laboratory.

Download Report

Transcript Advanced Computer Graphics: Animation James Gain Department of Computer Science University of Cape Town [email protected] Advanced Computer GraphicsCollaborative Visual Computing Laboratory.

Advanced Computer Graphics:
Animation
James Gain
Department of Computer Science
University of Cape Town
[email protected]
Advanced Computer GraphicsCollaborative
Visual Computing Laboratory
Objectives
To introduce the field of computer animation.
To describe the principal methods of parametric animation,
motion capture and physical dynamics.
To cover the animation of articulated figures.
To show how Quaternion rotations address the animation
problems with Euler angle rotations.
6/11/2015
Advanced Computer Graphics
2
Computer Animation
Animation creates the illusion of life by showing strobed discrete
images which the human visual system reconstructs using
persistence of vision into a continuous sequence.
Computer animation controls the position and attributes of all
virtual entities over time.
Widely used in simulation.
Temporal aliasing occurs if an animation changes too quickly
relative to the frame rate. For example: objects moving rapidly
across the field of view, bicycle wheels which appear to turn
backwards.
Modelling specifies the geometry. Rendering determines visual
appearance. Animation determines evolution over time.
6/11/2015
Advanced Computer Graphics
3
Hand-Drawn Animation
Created in a fairly fixed sequence, called key-frame animation:
1. A storyboard is laid out, which roughly outlines the animation. Shows
2.
3.
4.
the structure and ideas of the story.
The soundtrack is recorded.
Key frames of the animation are drawn. These show extremes of
action or characteristic expressions.
Intermediate frames are filled in by inbetweeners. Together with key
frames these constitute a pencil test.
Pencil tests are transferred to cels (sheets of acetate film).
Each cel becomes a single frame in a film (60 frames per second).
5.
6.
The process is time consuming and expensive. Some principles are
transferable to computer animation: squash and stretch; slowin slow-out.
6/11/2015
Advanced Computer Graphics
4
Parameter-based Animation
[+]
[-]
Fine control
Requires experience
Time consuming
Frustrating
Key-framing: Animators specify object parameters (position and orientation) at
key frames.
Inbetweening: Intermediate frames generated
by interpolation.
Animators have control over:
•
•
6/11/2015
Path: Linear interpolation (Lerping) leads
to discontinuous direction changes. Instead
use Hermite curves.
Speed: a linear function is highly unrealistic.
Slow-in Slow-out (smooth acceleration/
deceleration) is preferred
Advanced Computer Graphics
5
Motion Capture
[+]
[-]
Realistic
Expensive
Not Re-usable
Real-world position and orientation of objects
(particularly people) can be tracked and
applied to computer generated characters.
Track predetermined points (called markers or
sensors) on the moving entity in order to
reconstruct the event digitally.
Capture systems are optical (cameras + markers),
electromagentic (attached magnetic sources +
receiver) or electromechanical (exoskeleton
measuring bend angles).
Widely used in VFX (e.g. digital extras in “Titanic”).
6/11/2015
Advanced Computer Graphics
6
Physically-based Animation
[+]
[-]
Automatic
Complicated to build and use
Realistic
Computationally expensive
Kinematics (object control):
• Describes the position and velocity of points.
• Forward example: at time t the cube is at p. Afterwards it
•
6/11/2015
v
moves with constant acceleration in direction .
Inverse example: find the constant velocity required for a
cube to reach p after seconds.
t
Advanced Computer Graphics
7
Dynamics
Dynamics (cloth, water, fracture simulation):
• Considers the physical laws (e.g. Newtonian mechanics,
•
•
6/11/2015
Navier-Stokes equations) governing kinematics.
Forward example: a cube has mass of m grams. Gravity
acts on the cube.
Inverse example: find the force required for a cube to reach
p after seconds.
t
Advanced Computer Graphics
8
Exercise: Figure Animation
A Virtual Actor is the CG representation of a character’s motion and
appearance.
Question: Why would we want to replace real with CG actors?
Solution:
1. Actor must react in real time (e.g. computer games)
2. Actor’s physical form is difficult to realize in reality (e.g. Jar-Jar
3.
4.
5.
6.
6/11/2015
Binks)
Actor must perform impossible or dangerous actions.
Actor is to be placed in a computer generated set (avoids
green-screening)
Actor is a member of a crowd scene (cheap rent-a-crowd).
The real actor is unavailable (e.g. Marilyn Monroe in
“Rendezvous A Montreal”).
Advanced Computer Graphics
9
Skeletal Representation
Skeleton:
•
•
•
•
Encodes the degrees of motion freedom.
A set of rigid bones linked by ball (3DOF) and hinge (1DOF) joints
Shoulder blade cannot be represented by a single joint because of sliding action.
Spine has 33 vertebrae (96 DOF) which is unwieldy but, due to movement
constraints, can be approximated by 2-3 ball joints.
The skeleton can be realized as a scene graph.
Total Degrees of Freedom
 15  3  4 1  49
6/11/2015
Advanced Computer Graphics
10
Skeletal Transformations
Kinematics:
•
From a particular joint configuration calculate the relative position and
orientation of any point on the skeleton.
Terminology:
•
Kinematic link (bone), Kinematic chain (sequence of bones and joints)
and End-effector (last link, e.g. hand or foot).
Solution:
•
•
•
Each link has a local co-ordinate system and is
embedded in a space provided by the previous link.
Each joint i provides a local rotation R i and
each bone a local translation Ti .
Concatenating R i and Ti gives a local
transform M .
i
The transformation of a point x on link j is
found by concatenating all previous transforms
in the hierarchy:
x  Mx  M jM j1 ...M 0 x
6/11/2015
Advanced Computer Graphics
11
Inverse Kinematics
Specifying pose using joint angles is difficult.
Animators would prefer to position end-effectors directly.
Problem:
•
•
•
•
R
Given the position T and orientation
of an end-effector
e
e
Find all R i such that M translates by Te and rotates by R e.
Underdetermined non-linear system with many solutions.
Example: a hand has 6 constraints ( R e and Te ) and 10 unknowns
(clavicle 3 , shoulder 3 , elbow 1 , wrist 3 ).
Solutions:
•
•
6/11/2015
Iterative methods: use small changes in joint angles to iteratively
converge on a correct solution.
Closed form algebraic solutions: only exist for particular simplified
cases.
Advanced Computer Graphics
12
Reducing Kinematic Freedom
The degrees of kinematic freedom can be reduced by enforcing
“realistic” motion.
Realism rules for human motion:
1. Motion tends to be energy minimal (but this doesn’t
account for expressive gestures).
2. Collisions must not occur (muscles and skin surrounding
the kinematic bones cannot intersect).
3. Joint limits must be maintained (e.g. elbows don’t bend
backwards)
4. Feet in contact with the floor maintain their position
unless lifted.
Solutions which obey these realism rules are often even more
difficult to find.
6/11/2015
Advanced Computer Graphics
13
Animation Summary
Computer Time
(Machine Hours)
Human Time
(Man Hours)
Expressive Power
Realism
6/11/2015
Parameter-based
Motion Capture
Physically-based
Low
Medium
High
(low level control)
(marker tracking)
(complex simulation)
Very High
Medium
Low
(painstaking)
(acting the scene)
(specify constraints and
external forces)
High
High
Low
(animator imparted)
(expressive acting)
(human emotion not
considered)
Medium
High
Med
(realism difficult to
recreate)
(data captured from
reality)
(only approximate)
Advanced Computer Graphics
14
Euler Angles
Historically popular but flawed parametrization
of orientation.
A general rotation is constructed as a sequence of
rotations about 3 mutually orthogonal axes:
rolls about ,
and .
The order of the rolls is significant.
Arbitrarily choose the ordering
. A roll
about
by θ x , followed with a roll about y
by θ y , and finally a roll about
by θ .
xy
x
y
z
xyz
z z
E (θ x , θ y , θ z )  R( z, θ z )  R( y, θ y )  R( x, θ x )
Euler angle interpolation is not very stable. Especially with a small
rotation in one axis and large rotation in another – multiplying large
values by those close to zero tends to introduce numerical error.
6/11/2015
Advanced Computer Graphics
15
Gimbal Lock
A gimbal mechanism consists of three concentric rings on pivots
which support a compass or gyroscope.
Gimbal lock occurs when two of the rings are accidentally
aligned.
Euler angles are also susceptible. If one axis is rolled into
alignment with another then a degree of rotation freedom is
lost.
Unlike translations, rotations relative to separate axes are not
independent.
Example: a y -roll of θ y  π2 rotates the -axis onto the -axis
so that rolls about and are indistinguishable.
x
z
z
x
E (θ , , θ z )  R( z, θ x  θ z )  R( y, )
π
x 2
6/11/2015
π
2
Advanced Computer Graphics
16
Lerping Euler Angles
Two Euler rotations E (θ , θ , θ ) and E (θ , θ , θ ) can be
F
Fx
Fy
Fz
S
Sx
Sy
Sz
linearly interpolated to obtain inbetween rotations:
E P (θ Px , θ Py , θ Pz )
 (1  t )  E S (θ Sx , θ Sy , θ Sz )  t  E F (θ Fx , θ Fy , θ Fz )
 E ((1  t )  θ Sx  t  θ Fx , (1  t )  θ Sy  t  θ Fy , (1  t )  θ Sz  t  θ Fz )
Problems:
1. This does not produce a ‘natural’ steady rotation about a single vector
but may instead cause weird oscillations. Reason: the rolls about
are not independent.
2. The resulting interpolation differs depending on the ordering of the
Euler angles. Reason: the rolls about
are not commutative.
x, y, z
x, y, z
6/11/2015
Advanced Computer Graphics
17
Example: Poor Euler Interp
The interpolations E (0,0,0).....E (t  π ,0,0).....E (π ,0,0)
and E (0,0,0).....E (0,t  π ,t  π ).....E (0,π ,π ) have the same
start and end orientations but different intermediate orientations.
6/11/2015
Advanced Computer Graphics
18
Quaternions
Aim to:
•
•
Guarantee a direct and steady rotation between any two key
orientations.
Define moves that are independent of any particular co-ordinate system.
Quaternions were invented by Sir William Hamilton, after 10 years
of work, on 16 October 1843. In his elation he carved the formulae
into the nearby Broome Bridge in Dublin.
They represent an orientation by a counter-clockwise rotation
angle (θ ) about an arbitrary vector (V ).
Advantages:
•
•
6/11/2015
combining quaternions more efficient than matrix multiplication.
simple to convert between angle-axis, quaternion and transformation
matrix representations of rotation.
Advanced Computer Graphics
19
Form of a Quaternion
Q(a, b, c, d )  a  1  b  i  c  j  d  k




a  cos 2 ; b  sin( 2 )  Vi ; b  sin( 2 )  V j ; b  sin( 2 )  Vk
such that
a  b  c 2 d 2  1 2
2
2
2
2
are ‘imaginary’ axes ( i  j  k  1 are imaginary numbers)
and 1 is a ‘real’ axis.
a, b, c and are co-ordinates relative to these four axes.
In 3D a point P  xX  yY  zZ s.t. x 2  y 2  z 2  1 with coordinates ( x, y, z ) and axes ( X , Y , Z ) lies on a sphere of radius 1.
Similarly, for quaternions the rotation with a 2  b 2  c 2  d 2  1 lies on
a 4D hypersphere of radius 1.
i, j, k
d
6/11/2015
Advanced Computer Graphics
20
Lerping vs. Slerping Quaternions
Inbetweening key Quaternions Q1 and
Q2 by linearly interpolating their
components does not:
1. Produce equal changes in the
t
quaternion for equal steps in . They
speed up in the middle.
2. Ensure vectors remain on the
hypersphere.
Rather use spherical linear interpolation
(Slerping) which step through a
constant angle.
6/11/2015
Advanced Computer Graphics
21
Evaluating Quaternions
Advantages:
•
•
•
•
Flexible.
No parametrization singularities.
Smooth consistent interpolation of orientations.
Simple and efficient composition of rotations.
Disadvantages:
•
•
•
Each orientation is represented by two quaternions.
Represent orientations not rotations ( 0  about V is the same
quaternion as 360  about V ).
Complex!
References:
•
6/11/2015
Computer Graphics: Principles and Practice, sec. 21.1.3
Advanced Computer Graphics
22