19
Week 4 Lecture 3: Character Animation Based on Interactive Computer Graphics (Angel) - Chapter 10 1 Angel: Interactive Computer Graphics 5E © Addison- Wesley 2009

Week 4 Lecture 3: Character Animation Based on Interactive Computer Graphics (Angel) - Chapter 10 1 Angel: Interactive Computer Graphics 5E © Addison-Wesley

  • View
    220

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Week 4 Lecture 3: Character Animation Based on Interactive Computer Graphics (Angel) - Chapter 10 1 Angel: Interactive Computer Graphics 5E © Addison-Wesley

Week 4 Lecture 3: Character Animation

Based on Interactive Computer Graphics (Angel) - Chapter 10

1Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009

Page 2: Week 4 Lecture 3: Character Animation Based on Interactive Computer Graphics (Angel) - Chapter 10 1 Angel: Interactive Computer Graphics 5E © Addison-Wesley

2Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009

Objectives

•Standard Hierarchical models not good enough for realistic characters

Skeletal animation

Skinning

Introduce Cal3d

Page 3: Week 4 Lecture 3: Character Animation Based on Interactive Computer Graphics (Angel) - Chapter 10 1 Angel: Interactive Computer Graphics 5E © Addison-Wesley

Humanoid

•Recall our humanoid: Each section separate

geometry.

Some movements reveal gaps / overlaps in geometry.

Geometry stays the same shape during transformation.

Fine for a basic robot…

Page 4: Week 4 Lecture 3: Character Animation Based on Interactive Computer Graphics (Angel) - Chapter 10 1 Angel: Interactive Computer Graphics 5E © Addison-Wesley

Human Motion

•Humans… Continuous Geometry

No Gaps or Overlaps during movement

Geometry deforms

How to do this for computer characters?

Page 5: Week 4 Lecture 3: Character Animation Based on Interactive Computer Graphics (Angel) - Chapter 10 1 Angel: Interactive Computer Graphics 5E © Addison-Wesley

Human Anatomy

•Humans are made up of skeleton, muscles and skin.

•We only care about the cumulative effect of internal mechanism i.e. the skin.

•Can we simulate the effect of muscles and skeleton?

Page 6: Week 4 Lecture 3: Character Animation Based on Interactive Computer Graphics (Angel) - Chapter 10 1 Angel: Interactive Computer Graphics 5E © Addison-Wesley

Skeletal Animation

•One answer is to use a skeletal animation system, which means we manipulate a skeleton (a series of bones), and this produces a desired effect on the skin (a polygon mesh).

•Some more advanced systems also simulate muscle structure.

•We will just cover bones and skinning.

Page 7: Week 4 Lecture 3: Character Animation Based on Interactive Computer Graphics (Angel) - Chapter 10 1 Angel: Interactive Computer Graphics 5E © Addison-Wesley

Bones Basics

• Bones in 3D mimic joints, rather than actual bones .

• Bones are in a tree hierarchy. There is one root bone, and all bones are children of that bone, or children of it's children.

• Assuming the hip is the root bone, you might then have three children, left thigh, right thigh, midsection etc.

• Many modelling packages such as 3d studio have a standard set of bones.

• Bone movements are controlled by rotations.

Page 8: Week 4 Lecture 3: Character Animation Based on Interactive Computer Graphics (Angel) - Chapter 10 1 Angel: Interactive Computer Graphics 5E © Addison-Wesley

Forward Kinematics

•Recall our Robot arm.•The position of the arm can be determined from a series of rotations.

Rotation at the “base” Rotation at the “shoulder” Rotation at the “elbow”

•Forward kinematics means determining the position of a vertex after the chain of rotations.

Page 9: Week 4 Lecture 3: Character Animation Based on Interactive Computer Graphics (Angel) - Chapter 10 1 Angel: Interactive Computer Graphics 5E © Addison-Wesley

Inverse Kinematics

•The opposite of forward kinematics.•The final position and orientation is known, but the series of rotations to get there must be calculated.

•Can lead to multiple possible solutions, some of which are physically impossible.

•Some solutions make no sense for human skeleton, and human behaviour.

•Required often in games, when hand, foot etc. need to be in correct place (e.g. fighting games, sports games).

Page 10: Week 4 Lecture 3: Character Animation Based on Interactive Computer Graphics (Angel) - Chapter 10 1 Angel: Interactive Computer Graphics 5E © Addison-Wesley

Skinning

•The skin is represented as a polygon mesh, e.g. a set of vertices.

•Each vertex is associated with a bone in the skeleton, and moves relative to that bone.

•Vertices near joints are connected to multiple bones with a weighting system, e.g. at the elbow a vertex may move 60% in proportion to upper arm and 40% with lower arm.

Page 11: Week 4 Lecture 3: Character Animation Based on Interactive Computer Graphics (Angel) - Chapter 10 1 Angel: Interactive Computer Graphics 5E © Addison-Wesley

3d Studio Skinning

• Blue = vertex “groups”.

• Inner White = geometry.

• Outer White = Bounding boxes.

• Red / Yellow = Bones.

• Green points = vertices affected by current (red) bone.

Page 12: Week 4 Lecture 3: Character Animation Based on Interactive Computer Graphics (Angel) - Chapter 10 1 Angel: Interactive Computer Graphics 5E © Addison-Wesley

Why Use Skeletal Animation?

•Minimises work needed to do an animation:

Due to hierarchy, child bones move when parent bones are moved.

Animations stored as a series of joint rotations (in quaternions) , more efficient storage than whole vertex sets.

•Produces smoother more realistic animation.

Quaternions produce smooth animation when interpolated, without gimbal lock.

Page 13: Week 4 Lecture 3: Character Animation Based on Interactive Computer Graphics (Angel) - Chapter 10 1 Angel: Interactive Computer Graphics 5E © Addison-Wesley

3d studio example

http://uk.youtube.com/watch?v=r4H_LKV6NJA&feature=related

Page 14: Week 4 Lecture 3: Character Animation Based on Interactive Computer Graphics (Angel) - Chapter 10 1 Angel: Interactive Computer Graphics 5E © Addison-Wesley

Quaternions

•Another way to represent rotations rather than a matrix.

•Uses complex number mathematics to represent axis.

•A quaternion is represented as a scalar value and a vector value:

q = w + ai + bj + ck

= cos(ang/2) + sin(ang/2)u

Page 15: Week 4 Lecture 3: Character Animation Based on Interactive Computer Graphics (Angel) - Chapter 10 1 Angel: Interactive Computer Graphics 5E © Addison-Wesley

Using Quaternions

•The conjugate or inverse of a quaternion:

q-1 = q->scalar + -(q->vector)•Magnitude of a quaternion:

|q| = sqrt(q*q-1)•To normalise a quaternion:

q->scalar/|q| + (q->vector)/|q|•To rotate a point v around unit axis u, apply the quaternion multiplication:

qvq-1

Page 16: Week 4 Lecture 3: Character Animation Based on Interactive Computer Graphics (Angel) - Chapter 10 1 Angel: Interactive Computer Graphics 5E © Addison-Wesley

Using Quaternions Cont.

•To convert an axis and angle (ang) to a quaternion (q) – should normalise afterwards.

sin_a = sin(ang/2)

cos_a = cos(ang/2)

q->x = axis->x * sin_a

q->y = axis->y * sin_a

q->z = axis->z * sin_a

q->w = cos_a

Page 17: Week 4 Lecture 3: Character Animation Based on Interactive Computer Graphics (Angel) - Chapter 10 1 Angel: Interactive Computer Graphics 5E © Addison-Wesley

Animation Blending

•Animations stored as series of rotations applied to specific joints.

•Animations that work on different joints (including children) can run simultaneously without interference e.g. walk and wave.

•Animations that affect the same joints can run simultaneously, but will interfere.

•Use a normalised weighting system to tell joints how much of each animation to apply.

Page 18: Week 4 Lecture 3: Character Animation Based on Interactive Computer Graphics (Angel) - Chapter 10 1 Angel: Interactive Computer Graphics 5E © Addison-Wesley

Cal3d

•C++ Library for character animation.•Exports from 3d studio, maya, (blender?) etc.

•Supports model loading, texturing, animation blending etc.

•http://uk.youtube.com/watch?v=LLzU23xJrhg&feature=related

Page 19: Week 4 Lecture 3: Character Animation Based on Interactive Computer Graphics (Angel) - Chapter 10 1 Angel: Interactive Computer Graphics 5E © Addison-Wesley

Practical?

•Have a play around with cal3d:

http://home.gna.org/cal3d/