Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

57
Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004
  • date post

    21-Dec-2015
  • Category

    Documents

  • view

    223
  • download

    3

Transcript of Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

Page 1: Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

Midterm Review

CSE169: Computer Animation

Instructor: Steve Rotenberg

UCSD, Winter 2004

Page 2: Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

Project 3

Load an .anim file and play back a keyframed animation on a skinned character

Extra Credit: Display the channel curve (1 point) Simple channel editor (2 points)

Page 3: Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

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 …

}

Page 4: Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

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

Page 5: Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

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

Page 6: Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

Linear Algebra Review

Page 7: Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

Key Math Concepts

Vectors (dot & cross products…) Matrices (& systems of equations) Homogeneous vectors & matrices Transformations, inverse transformations Viewing, cameras Euler angles Quaternions Summation (weighted sum, average, convex) Cubic equations Interpolation, splines, radial basis functions

Page 8: Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

Vector Arithmetic

zyx

zyx

zzyyxx

zzyyxx

zyx

zyx

sasasas

aaa

bababa

bababa

bbb

aaa

a

a

ba

ba

b

a

Page 9: Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

Vector Magnitude

The magnitude (length) of a vector is:

Unit vector (magnitude=1.0)

222zyx vvv v

v

v

Page 10: Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

Dot Product

cosbaba

ba

iizzyyxx babababa

Page 11: Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

Example: Angle Between Vectors

How do you find the angle θ between vectors A and B?

a

b θ

Page 12: Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

Example: Angle Between Vectors

ba

ba

ba

ba

baba

1cos

cos

cos

a

b θ

Page 13: Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

Dot Products with Unit Vectors

bθ a

a·b = 00 < a·b < 1

a·b = -1

a·b = 1

-1 < a·b < 0

cos

0.1

ba

baa·b

Page 14: Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

Dot Products with Non-Unit Vectors

If a and b are arbitrary (non-unit) vectors, then the following are still true:

If θ < 90º then a·b > 0 If θ = 90º then a·b = 0 If θ > 90º then a·b < 0

Page 15: Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

Dot Products with One Unit Vector

a

u

a·u

If |u|=1.0 then a·u is the length of the projection of a onto u

Page 16: Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

Example: Distance to Plane

A plane is described by a point p on the plane and a unit normal n. Find the distance from point x to the plane

•p

n

• x

Page 17: Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

Example: Distance to Plane

The distance is the length of the projection of x-p onto n:

•p

n

• x

x-p

npx dist

Page 18: Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

Cross Product

xyyxzxxzyzzy

zyx

zyx

babababababa

bbb

aaa

kji

ba

ba

Page 19: Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

Properties of the Cross Product

ba

ba

ba

baba

0

sin

area of parallelogram ab

is perpendicular to both a and b, in the direction defined by the right hand rule

if a and b are parallel

Page 20: Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

Example: Area of a Triangle

Find the area of the triangle defined by 3D points a, b, and c

ab

c

Page 21: Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

Example: Area of a Triangle

acab 2

1area

b-a

c-a

ab

c

Page 22: Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

Matrices

1

0

0

0

zyx

zyx

zyx

zyx

ddd

ccc

bbb

aaa

M

x

y

z

a

b

c d

Page 23: Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

Example: Alignment to Target

A spaceship with a matrix M must target another ship with matrix N. Find a unit rotation axis u and an angle θ that will rotate M to be facing N

a

b

c d

Ma

b

c

d

N

Page 24: Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

Example: Alignment to Target

As objects are defined looking down the -z axis in their local space, the -c axis of their world matrix will represent the object’s heading

a

b

c d

Ma

b

c

d

N

heading

Page 25: Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

Example: Alignment to Target

Therefore, we want to rotate matrix M so that it’s c axis lines up with the vector going from N to M, or (M.d - N.d)

(M.d-N.d)

a

b

c d

Ma

b

c

d

N

Page 26: Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

Example: Alignment to Target

We will rotate around the axis perpendicular to both M.c and (M.d - N.d)

*

*

* ...

u

uu

dNdMcMu

a

b

c d

Ma

b

c

d

N

(M.d-N.d)

u

Page 27: Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

Example: Alignment to Target

The rotation angle θ is just the angle between M.c and (M.d - N.d)

dNdM

dNdMcM

..

...cos 1

a

b

c d

Ma

b

c

d

N

(M.d-N.d)

u

θ

Page 28: Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

Orthonormality

If all row vectors and all column vectors of a matrix are unit length, that matrix is said to be orthonormal

This also implies that all vectors are perpendicular to each other

Orthonormal matrices have some useful mathematical properties, such as: M-1 = MT

Page 29: Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

Orthonormality

If a 4x4 matrix represents a rigid transformation, then the upper 3x3 portion will be orthonormal

bac

acb

cba

cba

1

Page 30: Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

Matrix Dot Matrix

NML

333231

232221

131211

333231

232221

131211

333231

232221

131211

nnn

nnn

nnn

mmm

mmm

mmm

lll

lll

lll

32132212121112 nmnmnml

Ncc

Nbb

Naa

ML

ML

ML

Page 31: Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

Camera Matrix

Think of the camera just like any other object. Just as a chair model has a matrix W that transforms it into world space, the camera matrix C would transform a camera model into world space.

We don’t want to transform the camera into world space. Instead, we want to transform the world into the camera’s space, so we use the inverse of C.

Page 32: Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

Example: Camera ‘Look At’

Our eye is located at position e and we want to look at a target at position t. Generate an appropriate camera matrix M.

Page 33: Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

Example: Camera ‘Look At’

Our eye is located at position e and we want to look at a target at position t. Generate an appropriate camera matrix M.

Two possible approaches include: Measure angles and rotate matrix into place Construct a,b,c, & d vectors of M directly

Page 34: Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

Example: Camera ‘Look At’ Matrix

The d vector is just the position of the camera, which is e:

The c vector is a unit length vector that points directly behind the viewer:

te

tec

ed

Page 35: Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

Example: Camera ‘Look At’ Matrix

The a vector is a unit length vector that points to the right of the viewer. It is perpendicular to the c axis. To keep the camera from rolling, we also want the a vector to lay flat in the xz-plane, perpendicular to the y-axis.

Note that a cross product with the y-axis can be optimized as follows:

cy

cya

xz cc 0010 c

Page 36: Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

Example: Camera ‘Look At’ Matrix

The b vector is a unit length vector that points up relative to the viewer. It is perpendicular to the both the c and a axes

Note that b does not need to be normalized because it is already unit length. This is because a and c are unit length vectors 90 degrees apart.

acb

1*1*190sin acb

Page 37: Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

Example: Camera ‘Look At’ Matrix

Summary:

acb

te

tec

ed

cy

cya

Page 38: Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

Inversion

If M transforms v into world space, then M-1 transforms v’ back into local space

IMM

Mvv

Mvv

1

1

Page 39: Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

Homogeneous Vectors

Technically, homogeneous vectors are 4D vectors that get projected into the 3D w=1 space

w

z

w

y

w

xwzyx v

v

v

v

v

vvvvv

Page 40: Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

Homogeneous Vectors

Vectors representing a position in 3D space can just be written as:

Vectors representing direction are written:

The only time the w coordinate will be something other than 0 or 1 is in the projection phase of rendering, which is not our problem

1zyx vvv

0zyx vvv

Page 41: Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

Position Vector Dot Matrix

1

1

w

zzzzyzxz

yyzyyyxy

xxzxyxxx

zyx

v

dcvbvavv

dcvbvavv

dcvbvavv

vvv

Mvv

v

dcbav zyx vvv

1

0

0

0

zyx

zyx

zyx

zyx

ddd

ccc

bbb

aaa

M

Page 42: Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

Position Vector Dot Matrix

dcbav zyx vvv

v=(.5,.5,0,1)

x

y

Local Space

(0,0,0)

Page 43: Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

Position Vector Dot Matrix

dcbav zyx vvv

v=(.5,.5,0,1)

x

y

Local Space

(0,0,0)x

y

World Space

(0,0,0)

a

b

d

Matrix M

Page 44: Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

Position Vector Dot Matrix

dcbav zyx vvv

v=(.5,.5,0,1)

x

y

Local Space

(0,0,0)x

y

World Space

(0,0,0)

a

b

d

v’

Page 45: Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

Direction Vector Dot Matrix

0

0

w

zzzyzxz

yzyyyxy

xzxyxxx

zyx

v

cvbvavv

cvbvavv

cvbvavv

vvv

Mvv

v

cbav zyx vvv

1

0

0

0

zyx

zyx

zyx

zyx

ddd

ccc

bbb

aaa

M

Page 46: Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

Matrix Dot Matrix (4x4)

1

0

0

0

zyx

zyx

zyx

zyx

ddd

ccc

bbb

aaa

MNMM

The row vectors of M’ are the row vectors of M transformed by matrix N

Notice that a, b, and c transform as direction vectors and d transforms as a position

Page 47: Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

Quaternions

In computer animation, quaternions are used as an alternative way to store orientations (other than matrices & Euler angles)

One of their biggest advantages is their ability to interpolate between arbitrary orientations nicely

They are also a compact, fast way to store & manipulate orientations

As we generally require matrices at some point, the ability to convert a quaternion to/from a matrix is very important

Once in quaternion format, we can interpolate smoothly using ‘slerp’ (spherical linear interpolation), or construct quaternion curves through several orientations

Page 48: Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

Weighted Blending & Averaging

Weighted sum:

Weighted average:

Convex average:

Additive blend:

10

10

0

i

ii

iii

w

w

xwx

10

1100 1

iii

ii

iii xwxwxxwxx

Page 49: Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

Rigging & Animation Review

Page 50: Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

Rigging & Animation Concepts

Rigging DOF Joint Skeleton Skin Morphing, PSD FFD, SOFFD Rig

Animation Pose Keyframe Channel Animation Clip Player Blender State Machine

Page 51: Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

Rigging and Animation

Animation

SystemPose

Rigging

SystemTriangles

Renderer

Page 52: Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

Rig Data Flow

N ...21Φ

nv ,

RiggingSystem

Page 53: Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

Rigging Equations

*

*

1*

1

21 ,...,,

n

nn

WBnn

WBvv

nnnn

vvvv

WLW

LL

iii

iii

baseiibase

baseiibase

parent

Njnt

w

w

Skeleton

Morphing

Skinning

Page 54: Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

Skeleton, Morph, & Skin Data Flow

parent

mjnt

WLW

LL

,...,, 21

*

*

1*

1

n

nn

WBnn

WBvv

iii

iii

w

w

baseiibase

baseiibase

nnnn

vvvv

M ...21 NMM ...21

nv ,

Page 55: Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

Skeleton Forward Kinematics

Every joint computes a local matrix based on its DOFs and any other constants necessary (joint offsets…)

To find the joint’s world matrix, we compute the dot product of the local matrix with the parent’s world matrix

Normally, we would do this in a depth-first order starting from the root, so that we can be sure that the parent’s world matrix is available when its needed

Njnt ,...,, 21LL

parentWLW

Page 56: Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

Shape Interpolation Algorithm

To compute a blended vertex position:

The blended position is the base position plus a contribution from each target whose DOF value is greater than 0

To blend the normals, we use a similar equation:

We don’t need to normalize them now, as that will happen later in the skinning phase

baseiibase vvvv

baseiibase nnnn

Page 57: Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.

Smooth Skin Algorithm

The deformed vertex position is a weighted average over all of the joints that the vertex is attached to:

W is a joint’s world matrix and B is a joint’s binding matrix that describes where it’s world matrix was when it was attached to the skin model (at skin creation time)

Each joint transforms the vertex as if it were rigidly attached, and then those results are blended based on user specified weights

All of the weights must add up to 1: Blending normals is essentially the same, except we transform them

as directions (x,y,z,0) and then renormalize the results

iiiw WBvv 1

1iw

*

*1* ,

n

nnWBnn

iiiw