physical modeling for games structured methods in physical modeling for games pros and cons the...

43
Physical Modeling for Games Structured Methods in Physical Modeling for Games Pros and Cons The Basics: Spatial Vectors & Coordinate Frames Inertia, F = Ia, Gravity, Contact Forces Numerical integration Articulated Bodies, Joints & Joint Limits Forward Dynamics via Structural Recursion Kinematic Loop Constraints - Mechanisms Hybrid Dynamics & Controllers Game Engines & Performance Issues Àëeêcaíäp Peøeòoâ & Michael Shantz - Intel Corporation

Post on 22-Dec-2015

224 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Physical Modeling for Games Structured Methods in Physical Modeling for Games Pros and Cons The Basics: –Spatial Vectors & Coordinate Frames –Inertia,

Physical Modeling for Games

Structured Methods in Physical Modeling for Games

• Pros and Cons• The Basics:

– Spatial Vectors & Coordinate Frames– Inertia, F = Ia, Gravity, Contact Forces– Numerical integration

• Articulated Bodies, Joints & Joint Limits• Forward Dynamics via Structural Recursion• Kinematic Loop Constraints - Mechanisms• Hybrid Dynamics & Controllers• Game Engines & Performance Issues

Àëeêcaíäp Peøeòoâ & Michael Shantz - Intel Corporation

Page 2: Physical Modeling for Games Structured Methods in Physical Modeling for Games Pros and Cons The Basics: –Spatial Vectors & Coordinate Frames –Inertia,

Physical Modeling for Games

Physical Modeling Pros & Cons

• Difficult - steep learning curve• Compute Intensive: collisions, dynamics

– floating point limited– cache miss sensitive!

• Controllers are difficult– cars are ok but try walking

• Long term potential - this is gonna be great!

• Incremental design - start modestly• There are many ways to cheat

Page 3: Physical Modeling for Games Structured Methods in Physical Modeling for Games Pros and Cons The Basics: –Spatial Vectors & Coordinate Frames –Inertia,

Physical Modeling for Games

Forward Dynamics• Given joint torques and external forces

compute the resulting joint accelerations– Reduced or Generalized coordinate methods

O(n) Structural Recursion (Featherstone, Brandl)joint space 1..3 DOF versus motion space 6DOFmost efficient in flops, eliminates “drift”

• Solve a system of constraints– Maximal coordinate methods

O(n) Lagrange Multipliers (Baraff)most efficient in memory access?Handles general constraints. Serious drift

problems.

Page 4: Physical Modeling for Games Structured Methods in Physical Modeling for Games Pros and Cons The Basics: –Spatial Vectors & Coordinate Frames –Inertia,

Physical Modeling for Games

Articulated Body Treeframe 0, body 0

6 DOF joint

The bodies form a tree with the bodies numbered such that the predecessor number p(i) is less than the body’s number. Structural recursion operates on this tree.

body 1

9

54

3

2

8

76

ip(i)

Page 5: Physical Modeling for Games Structured Methods in Physical Modeling for Games Pros and Cons The Basics: –Spatial Vectors & Coordinate Frames –Inertia,

Physical Modeling for Games

Basics: Rigid body i “link”

Bodyi has coordinate framei fixed in the body. The body may experience angular and linear velocity and acceleration. These spatial vectors may be expressed in framei or in other frames. s is a vector to bodyi’s center of mass expressed in framei

x

y

z

r

framei

P

Center of Mass

s

Bodyi

Page 6: Physical Modeling for Games Structured Methods in Physical Modeling for Games Pros and Cons The Basics: –Spatial Vectors & Coordinate Frames –Inertia,

Physical Modeling for Games

Articulated Body Joint Frames

frame 0, “inertial frame”, world coordinates

x

z

body 2

y

x

y

zframe 1

x

y

zframe 2’ inner joint frame

x

y

z frame 2 outer joint frame

body 1

6 DOF joint

The joint variables q are zero when the inner frame and outer frame are coincident. Frame 1 is fixed in body 1, frame 2’ is fixed in body 1 but is associated with body 2. Joint action moves frame 2 wrt frame 2’ (by rotation matrix A, translation vector z).

2’R1 , c1

2A2’ , z2 q

Page 7: Physical Modeling for Games Structured Methods in Physical Modeling for Games Pros and Cons The Basics: –Spatial Vectors & Coordinate Frames –Inertia,

Physical Modeling for Games

Basics: Spatial Vectors - Velocity

jVelocityi =

xyz

xyz

vector specifies axis of rotation.Length of is radians per second

Angular Velocity

Linear Velocity

vector specifies directionLength of is meters per second

The spatial velocity jvi of body i expressed in coordinate frame j includes both angular and linear components. Notation is critical.

Page 8: Physical Modeling for Games Structured Methods in Physical Modeling for Games Pros and Cons The Basics: –Spatial Vectors & Coordinate Frames –Inertia,

Physical Modeling for Games

Basics: Spatial Vectors - Acceleration

jAccelerationi =

xyz

axayaz

vector specifies axis of rotational acceleration.Length of is radians per second2.

Angular Acceleration

Linear Accelerationa a vector specifies

direction.Length of a is meters per second2.

The spatial acceleration jai of body i expressed in coordinate frame j includes both angular and linear components.

Page 9: Physical Modeling for Games Structured Methods in Physical Modeling for Games Pros and Cons The Basics: –Spatial Vectors & Coordinate Frames –Inertia,

Physical Modeling for Games

Basics: The Cross Operator ~

Vector Cross Product: a b = a x b

The cross operator gives a matrix algebra representation of the vector cross product. Note that its transpose is its negation.

~

a = ~ -ay

az ay

-ax -az

ax 0

0 0

= - a T

~

For 6-vector

b

a = s let

a~b

~0a~~ =s

Page 10: Physical Modeling for Games Structured Methods in Physical Modeling for Games Pros and Cons The Basics: –Spatial Vectors & Coordinate Frames –Inertia,

Physical Modeling for Games

Basics: Spatial Vectors - Force

jForcei =

xyz

fxfyfz

vector specifies axis of torque.Length of is newton meters: kilogram meters2 per second2.

Torque: Moment of Force

Linear Forcef

f vector specifies direction.Length of f is newtons: kilogram meters per second2.

The spatial force jfi on body i expressed in coordinate frame j includes both torque and linear force components.

Page 11: Physical Modeling for Games Structured Methods in Physical Modeling for Games Pros and Cons The Basics: –Spatial Vectors & Coordinate Frames –Inertia,

Physical Modeling for Games

Basics: Force applied at a point

iforcei =

f

The spatial force ifi on body i expressed in coordinate framei resulting from a linear force f applied at point P (line of force) in

framei where r is the vector to P, has a torque = r x f (right hand rule) and a linear component f.

~

x

y

z

f

r

frame i

rf

f=

P

Page 12: Physical Modeling for Games Structured Methods in Physical Modeling for Games Pros and Cons The Basics: –Spatial Vectors & Coordinate Frames –Inertia,

Physical Modeling for Games

Basics: Gravitational Force on Body i

The acceleration of gravity 0g in frame 0 (world coordinates) is a 3x1 vector eg. [0, -g, 0]T. iR0 is the 3x3 rotation matrix that transforms it to frame i. si is the vector in frame i to the center of mass of body i. ifg is the spatial force expressed in frame i which is exerted on body i due to gravity. Cheap trick: just give frame0 a fake acceleration -0g.

~

x

y

z

ig = iR0 0g

si

frame i

siig

igifg = m

Center of Mass

0g = [0,-9.8 meters/sec2,0]T

igTrick: 0a0 = -0g

Page 13: Physical Modeling for Games Structured Methods in Physical Modeling for Games Pros and Cons The Basics: –Spatial Vectors & Coordinate Frames –Inertia,

Physical Modeling for Games

Basics: Transforming Spatial Vectors

kfi =f

A spatial vector jfi expressed in coordinate frame j may be expressed in frame k by transforming the spatial vector by the 6x6 matrix kCj where R is the 3x3 rotation matrix st. kv = kRj jv transforms a 3 vector expressed in frame j into a vector expressed in frame k. r is a 3 vector from the origin of frame j to frame k expressed in frame j.

R 0

R

kfi = kCj jfi

-Rr~

x

y

z

xy

zr

R

frame j

frame k

Page 14: Physical Modeling for Games Structured Methods in Physical Modeling for Games Pros and Cons The Basics: –Spatial Vectors & Coordinate Frames –Inertia,

Physical Modeling for Games

Basics: Inertia Matrix Ii , F = Ia

a

The force ifi on body i expressed in frame i is equal to the inertia matrix of body i times the spatial acceleration of body i. mi is the mass of body i in kilograms, s is the vector in frame i to the center of mass of body i. Use the Lien/Kajiya method to get I, m, s.

Ii hi

Mi-hi

~

ifi = Ii iai

~

Mi =00

0 0

0

0 mi mi

mi

hi = mi

~

-sy

sz sy

-sx -sz

sx 0

0

0

f

=

dv)y2

x2

(dv(yz)dv(xz)

dv(yz)dv)z2

x2

(dv(xy)

dv(xz)dv(xy)dv)z2

y2

(

I

i

Page 15: Physical Modeling for Games Structured Methods in Physical Modeling for Games Pros and Cons The Basics: –Spatial Vectors & Coordinate Frames –Inertia,

Physical Modeling for Games

• Spring damperif = -kdx - ksx

• Nonlinear spring/damperif = -kdxnx - ksxn

Basics: Contact Forces from Collisions

The contact force on body i due to a collision at point P which is penetrating another object by a depth of x can be modeled as a spring. The 3x1 vector if has direction based on normal to the surface and the velocity of body i (to simulate friction) . See Marhefka and Orin

x

y

zri

frame i

P

if

x

body i

riif

if

~ifc

=

Page 16: Physical Modeling for Games Structured Methods in Physical Modeling for Games Pros and Cons The Basics: –Spatial Vectors & Coordinate Frames –Inertia,

Physical Modeling for Games

• If time step is too large, collision may cause integrator instability.

•Delayed reaction for articulated body

Basics: Contact Forces kill Integrators

x

y

zri

frame i

P

if

x

body i

Page 17: Physical Modeling for Games Structured Methods in Physical Modeling for Games Pros and Cons The Basics: –Spatial Vectors & Coordinate Frames –Inertia,

Physical Modeling for Games

• Euler or Verlet: qi += qi t; qi += qi t;

• Runge-Kutta Fehlberg (adaptive step size)

Basics: Numerical Integration....

ti-1

q

t

.

ti

.

.Estimate 1

Estimate 2

t

If the error computed from the pair of estimates is too large, reduce t.

qi-1

. qi

.

The exact solution (white curve) is estimated at t time steps. See Numerical Recipes in C and excellent survey by Enright et al.

Page 18: Physical Modeling for Games Structured Methods in Physical Modeling for Games Pros and Cons The Basics: –Spatial Vectors & Coordinate Frames –Inertia,

Physical Modeling for Games

More about Joints

frame 0, “inertial frame”, world coordinates

x

z

body 2

y

x

y

zframe 1

x

y

zframe 2’ inner joint frame

x

y

z frame 2 outer joint frame

body 1

6 DOF joint

If the joint variables q are zero then the inner frame and outer frame are coincident. Frame 1 is fixed in body 1, frame 2’ is fixed in body 1 but is associated with body 2. Joint action moves frame 2 wrt frame 2’ (by rotation matrix A, translation vector z).

2’R1 , c1

2A2’ , z2

Page 19: Physical Modeling for Games Structured Methods in Physical Modeling for Games Pros and Cons The Basics: –Spatial Vectors & Coordinate Frames –Inertia,

Physical Modeling for Games

The Joint Transform iCi-1

l i n k b o d y i

i ’ C i - 1

l i n k b o d y i - 1

i C i ’

j o i n t i - 1

f r a m e i - 1

f r a m e i ’

f r a m e i

z i

j o i n t i

z

q 1 = yz

y

i

ii

ii

i

iT

iT

iT

iT

1 1C C CA 0

0 A1 0

z 1R 0

0 R1 0

c 1

A R 0A z R + A R c A R

''

'~ ~

~ ~c i

x

x

o u t e r j o i n t i f r a m e

i n n e r j o i n t i f r a m e

I f z i e x p r e s s e d i n f r a m e i - 1 ( i n t e r n a l ) t h e n

ii

iT

iT

1C

A R 00 A R

1 0z c 1~ ~

I f z i e x p r e s s e d i n f r a m e i ’ ( i n A P I ) t h e n

Rigid bodies connected by joints.

iCi-1 transforms spatial vectors from framei-1 to framei. R is a rotation matrix that rotates vectors from framei-1 to framei’. A is the matrix associated with joint rotation, zi is for sliding (prismatic) joints.

iCi-1 transform

Page 20: Physical Modeling for Games Structured Methods in Physical Modeling for Games Pros and Cons The Basics: –Spatial Vectors & Coordinate Frames –Inertia,

Physical Modeling for Games

Revolute (Hinge) JointJoint space parameter q0 = radians about z axis

x

y

zframe i’ inner joint frame

x

y

z frame i outer joint frame

iAi’ , zi

Rotation matrix iAi’ =

0

-sin(q0)

0 0

sin(q0)

0 1

cos(q0)

cos(q0

)

Translation zi = 0

Project Joint space into Motion space:

i q0 =

0 0 1 0 0 0

q0

Page 21: Physical Modeling for Games Structured Methods in Physical Modeling for Games Pros and Cons The Basics: –Spatial Vectors & Coordinate Frames –Inertia,

Physical Modeling for Games

Prismatic (Sliding) JointJoint space parameter q0 = meters along z axis

x

y

zframe i’ inner joint frame

x

y

z frame i outer joint frame

iAi’ , zi

Rotation matrix iAi’ =

0

0 0 0

0

0 1

1

1

Translation zi = <0 0

q0>Project Joint space into Motion space:

i q0 =

0 0 0 0 0 1

q0

Page 22: Physical Modeling for Games Structured Methods in Physical Modeling for Games Pros and Cons The Basics: –Spatial Vectors & Coordinate Frames –Inertia,

Physical Modeling for Games

Spherical Joint“Joint space parameters” qe0 qe1 qe2 qe3 = quaternion rotation

x

y

zframe i’ inner joint frame

x

y

zframe i outer joint frame

iAi’ , zi

Rotation matrix iAi’ = 1 + 2(qe qe - qe3 qe); where qe = <qe0 qe1 qe2> and 1 is identity. Normalized Euler: | qe0 qe1 qe2 qe3| = 1.

Translation zi = 0

Project Joint space into Motion space:

i q =

1 0 0 0 0 0

q1

~ ~ ~

0 1 0 0 0 0

0 0 1 0 0 0

q0

q2

0 =

qe = 0.5 t for qe(0) = 0

Page 23: Physical Modeling for Games Structured Methods in Physical Modeling for Games Pros and Cons The Basics: –Spatial Vectors & Coordinate Frames –Inertia,

Physical Modeling for Games

• Use counteracting torques to limit joints.

Articulated Body Joint Limits

Given joint position q and limits qmin qmax, compute limit torques to prevent joint from exceeding its range.

r = ks(q-qmax) - kdq

qmin

qmax

r = ks(q-qmin) - kdq

r = 0

q

Page 24: Physical Modeling for Games Structured Methods in Physical Modeling for Games Pros and Cons The Basics: –Spatial Vectors & Coordinate Frames –Inertia,

Physical Modeling for Games

Articulated Body Forward Dynamics

External forces: collisions, gravity

fE

Controller generated joint torques

i

Joint parameters, mass, inertia

Ii...

Structurally Recursive Forward Dynamics

Joint space accelerations

qi

..Integrator

O(n) computational complexity

qi

Body Transforms

Page 25: Physical Modeling for Games Structured Methods in Physical Modeling for Games Pros and Cons The Basics: –Spatial Vectors & Coordinate Frames –Inertia,

Physical Modeling for Games

Articulated Body Treeframe 0, body 0

6 DOF joint

The bodies form a tree with the bodies numbered st. the predecessor number p(i) is less than the body’s number.

body 1

9

54

3

2

8

76

ip(i)

Page 26: Physical Modeling for Games Structured Methods in Physical Modeling for Games Pros and Cons The Basics: –Spatial Vectors & Coordinate Frames –Inertia,

Physical Modeling for Games

Articulated Body Recursion

vi = iCi-1 vi-1 + vrel vrel = i qi = rel

rel

ai = iCi-1 ai-1 + i qi + i.. i =

AR(i-1rel)

AR(i-1 (i-1 ri + 2rel))~~

~

.

The velocity of bodyi is just the velocity of bodyi-1 expressed in framei plus the relative velocity due to joint motion. Acceleration is similar except for the centripetal acceleration term i. Force is similar except that recursion is from successor bodies s(i), plus bodyi force Ia, minus external, Coriolis, and centrifugal forces i . i is the angular velocity of bodyi , si the vector to center of mass, ri = ci + zi .

fi = jCi fj + Ii ai - ij s(i)

T

i = fEi -i Ii i

mii (i si)~ ~

~_

Page 27: Physical Modeling for Games Structured Methods in Physical Modeling for Games Pros and Cons The Basics: –Spatial Vectors & Coordinate Frames –Inertia,

Physical Modeling for Games

Structurally Recursive Forward Dynamics

i n p u t t q q a l i n k a n d j o i n t p a r a m e t e r so u t p u t q i f d e s i r e dc

: ; ; ; ; ;: ; ( )

0

f o r i = 1 , 2 , . . . , n B / / f o r w a r d k i n e m a t i c s , c o m p u t e :

ii

p i i i i i iv C I I; ; ; ; ;( )* *

e n d f o rf o r i = n B , n B - 1 , . . . , 1 / / b a c k w a r d d y n a m i c s

i iT

i iH I *

i f p ( i ) ! = 0

i i i i i iT

iN I I H I* * * 1

i i i i i i iT

i i i N I H* 1 ( )* *

p ( i )*I C N C

ip i

Ti

ip i( ) ( )

p i

ip i

Ti( )

*( ) C

e n d f o rf o r i = 1 , 2 , . . . , n B / / f o r w a r d a c c e l e r a t i o n s

i i i

Ti

ip i p i i i i

Ti

*( ) ( )

*q H [ I ( C a ) ] 1

ii

p i p i i i ia C a q ( ) ( )

ic

ic T

i i i { }* *I a

e n d f o r

Brandl algorithm for case with no loops.

Structurally recursive O(n) algorithm

Velocity dependent terms

“felt” inertias

accelerations

Page 28: Physical Modeling for Games Structured Methods in Physical Modeling for Games Pros and Cons The Basics: –Spatial Vectors & Coordinate Frames –Inertia,

Physical Modeling for Games

Matrix and Vector info

i n p u t t q q a l i n k a n d j o i n t p a r a m e t e r so u t p u t q i f d e s i r e dc

: ; ; ; ; ;: ; ( )

0

f o r i = 1 , 2 , . . . , n B / / f o r w a r d k i n e m a t i c s , c o m p u t e :

ii

p i i i i i iv C I I; ; ; ; ;( )* *

e n d f o rf o r i = n B , n B - 1 , . . . , 1 / / b a c k w a r d d y n a m i c s

i iT

i iH I *

i f p ( i ) ! = 0

i i i i i iT

iN I I H I* * * 1

i i i i i i iT

i i i N I H* 1 ( )* *

p ( i )*I C N C

ip i

Ti

ip i( ) ( )

p i

ip i

Ti( )

*( ) C

e n d f o rf o r i = 1 , 2 , . . . , n B / / f o r w a r d a c c e l e r a t i o n s

i i i

Ti

ip i p i i i i

Ti

*( ) ( )

*q H [ I ( C a ) ] 1

ii

p i p i i i ia C a q ( ) ( )

ic

ic T

i i i { }* *I a

e n d f o r

Size of matrix variables assuming joints have ni DOF; no kinematic loops

6x1

6x6

nix1

6xni

nixn

i

6x1

6x6

nix1

6-nix1

6-nix6

Rows x Columns

Page 29: Physical Modeling for Games Structured Methods in Physical Modeling for Games Pros and Cons The Basics: –Spatial Vectors & Coordinate Frames –Inertia,

Physical Modeling for Games

Create Dynamic Model from Static

The “Mechanic” toolkit for interactively creating dynamic models from art obtained from modelers such as 3DStudio MAX.

Modeling work by Sonja Jeter, Nola Donato

Page 30: Physical Modeling for Games Structured Methods in Physical Modeling for Games Pros and Cons The Basics: –Spatial Vectors & Coordinate Frames –Inertia,

Physical Modeling for Games

Forward/Inverse Dynamic Walking

The “Mechanic” toolkit for interactively creating dynamic models from art obtained from modelers such as 3DStudio MAX.

Modeling work by Sonja Jeter, Nola Donato

Page 31: Physical Modeling for Games Structured Methods in Physical Modeling for Games Pros and Cons The Basics: –Spatial Vectors & Coordinate Frames –Inertia,

Kinematic Loops

BehavBehav

BaseBody

Joint

Loop Joint

Bod

y

Body

Bo

dy

Body

Body

• BodyJoint & Rigid BodySet Joint TorquesSet External Forces

• BaseBodyCompute Body Accelerations

• Loop Joint

Breaks Cycles

Page 32: Physical Modeling for Games Structured Methods in Physical Modeling for Games Pros and Cons The Basics: –Spatial Vectors & Coordinate Frames –Inertia,

Kinematic Loop Objects

Body : TransformGroupJoint & Rigid BodySet Joint TorquesSet External Forces

BaseBody : BodyCompute Dynamics

Loop : Bodyloop constraint

equations

Body : TransformGroupJoint & Rigid BodySet Joint TorquesSet External Forces

BaseBody : BodyCompute Dynamics

Loop : Bodyloop constraint

equations

G

BehavBehav

Body

BaseBody

Body Body

Loop G

G

Page 33: Physical Modeling for Games Structured Methods in Physical Modeling for Games Pros and Cons The Basics: –Spatial Vectors & Coordinate Frames –Inertia,

Physical Modeling for Games

Mechanisms

Steam engine with 3 kinematic loop constraints. The crankshaft, the rocker arm pivot, the valve and piston cylinders are all fixed to the base.

Modeling by Sonja Jeter, Jill Hunt, Nola Donato

Page 34: Physical Modeling for Games Structured Methods in Physical Modeling for Games Pros and Cons The Basics: –Spatial Vectors & Coordinate Frames –Inertia,

Physical Modeling for Games

Hybrid Dynamics & Controllers 1

(t)

f(t)

Page 35: Physical Modeling for Games Structured Methods in Physical Modeling for Games Pros and Cons The Basics: –Spatial Vectors & Coordinate Frames –Inertia,

Physical Modeling for Games

Hybrid Dynamics & Controllers 2

• Forward Dynamics

• Inverse kinematics

• Hybrid dynamics

)t,x()x(V2x

2

m2

2

h

th i

--

Page 36: Physical Modeling for Games Structured Methods in Physical Modeling for Games Pros and Cons The Basics: –Spatial Vectors & Coordinate Frames –Inertia,

Physical Modeling for Games

Hybrid Dynamics & Controllers 3

])([ aCIHq *i

Tiii)i(p)i(p

i*i

Ti

1ii a = f/m

x = -kdx - ksx

Page 37: Physical Modeling for Games Structured Methods in Physical Modeling for Games Pros and Cons The Basics: –Spatial Vectors & Coordinate Frames –Inertia,

Physical Modeling for Games

Hybrid Dynamics & Controllers 4

opt f(p)

min f(p)

Page 38: Physical Modeling for Games Structured Methods in Physical Modeling for Games Pros and Cons The Basics: –Spatial Vectors & Coordinate Frames –Inertia,

Physical Modeling for Games

Performance EquipmentIntel 400 MHz Pentium II Processor

Dynamic ModelsRaptor:

1500 polygons, 50 DOF,

12 inverse dyn.40K-80K floating ops per frame 25 fps dynamics + render + skin300+ fps dynamics only.

Steam Engine: 1000 polygons, 11 joints, 3 loops70K floating ops per frame 50 frames per second.

Page 39: Physical Modeling for Games Structured Methods in Physical Modeling for Games Pros and Cons The Basics: –Spatial Vectors & Coordinate Frames –Inertia,

Physical Modeling for Games

Optimizations

Behaviors: behavioral culling, stop/start, freeze/resume Collisions: OBB inner loop: Parallel float optimize

Hierarchical Sphere bounds, Collide sets,

kinetic prediction, interval arithmetic Dynamics: Linear Algebra: Parallel float opt. Occlusion: Portals, Visibility map (UNC), Switch, app cull Scaleable: LOD, Billboards, Grid Sort, BSP Render: Threads - Behavior, Cull, Draw, Audio

Property sort, Tri-strips, Flatten

Page 40: Physical Modeling for Games Structured Methods in Physical Modeling for Games Pros and Cons The Basics: –Spatial Vectors & Coordinate Frames –Inertia,

Physical Modeling for Games

Math Library

Templated Matrix Library#define e4(i, j, l, m, n, a, b) \ flm(0, i, j, m, n, a, b) \ flm(1, i, j, m, n, a, b) \ flm(2, i, j, m, n, a, b) \ flm(3, i, j, m, n, a, b) \ __asm faddp st(1), st(0) \ __asm fxch st(2) \ __asm faddp st(1), st(0) \ __asm faddp st(1), st(0) \ __asm fstp dword ptr [eax + mi(l, 0, i, j)]

Resizable Matrix Libraryftable_mmm(Add, operator+);inline ISMXTmpMatrix& __fastcall operator+(const ISMXMatrix& A, const ISMXMatrix& B) { void* pf = AddPool[ISMXMatrix::lutSizes[A.nr]][ISMXMatrix::lutSizes[A.nc]]; pf = ((PVOIDMX2&)pf)(A, B);; (int&)((ISMXTmpMatrix*) pf)->nr = (int&)A.nr; return *(ISMXTmpMatrix*) pf;}

Page 41: Physical Modeling for Games Structured Methods in Physical Modeling for Games Pros and Cons The Basics: –Spatial Vectors & Coordinate Frames –Inertia,

Physical Modeling for Games

Key References 1

Andy Witkin, Dave Baraff, and Michael Kass http://www.cs.cmu.edu/afs/cs/user/baraff/www/pbm/pbm.html B. Mirtich, Multibody Dynamics Package http://www.merl.com/people/mirtich/multibodyDynamics.html Chris Hecker's Rigid Body Dynamics Information http://www.d6.com/users/checker/dynamics.htm This presentation http://www.cgdc.com/1998/vault/wcd00506.doc

Page 42: Physical Modeling for Games Structured Methods in Physical Modeling for Games Pros and Cons The Basics: –Spatial Vectors & Coordinate Frames –Inertia,

Physical Modeling for Games

http://www.merl.com/people/mirtich/multibodyDynamics.html

Key References 2

Brandl et al ‘86, ‘87 Structurally recursive methods Featherstone ‘87 Spatial vectors Lien & Kajiya ‘84 Integral properties of polyhedra Marhefka & Orin ‘96Contact forces Roberson & Schwertassek ‘87 Great reference text Baraff ‘96 Lagrange Multipliers Walker & Orin ‘85 Classic robotics paper Enright et al ‘95 Runge-Kutta Integrators

Page 43: Physical Modeling for Games Structured Methods in Physical Modeling for Games Pros and Cons The Basics: –Spatial Vectors & Coordinate Frames –Inertia,

Physical Modeling for Games

Acknowledgments

Animation&Vision Group @ MGL @IntelBaining GuoDemetri TerzopoulosFeng XieGary BradskiJohn FungeMark HollerRadek GrzeszczukXiaoyuan TuNSTLÀëeêceé Ñóïèêoâ