04-05-2017 1 Keyframing Lecture 10 Slide 2 6.837 Fall 2003 Keyframing Motion of objects is described as a function of time from a set of key object positions (keyframes). • Keyframes are drawn by skilled animator. • Computer generates in-betweens using interpolation. () st
32
Embed
CSE 381: Advanced Game Programming - Bullet3D Lecture
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
04-05-2017
1
Keyframing
Lecture 10 Slide 2 6.837 Fall 2003
Keyframing
Motion of objects is described as a function of time from a set of key object positions (keyframes).
• Keyframes are drawn by skilled animator.
• Computer generates in-betweens using interpolation.
( )s t
04-05-2017
2
Keyframing
Complex movements may require multiple keys.
Slide 4
Interpolating Positions
Given positions:
find curve such that
( , , ), 0, ,i i ix y t i n
( )( )
( )
x tt
y tC
( ) ii
i
xt
yC
0u0 0 0( , , )x y t
1 1 1( , , )x y t
2 2 2( , , )x y t
( )tC
04-05-2017
3
Lecture 10 Slide 5 6.837 Fall 2003
Linear Interpolation
Simple problem:
Any ti:
0 0 0( , , )x y t
1 1 1( , , )x y t
2 2 2( , , )x y t
010 1 0 1
1 0 1 0
2 11 2 1 2
2 1 2 1
, ,
( )
, ,
t tt tx x t t t
t t t tx t
t t t tx x t t t
t t t t
0 1=0 and =1t t 0 1( ) 1x t x t x t
Lecture 10 Slide 6 6.837 Fall 2003
Polynomial Interpolation
An n-degree polynomial can interpolate any n+1 points.
The n+1 coefficients of an n-degree polynomial can be obtained from the n+1 points.
0 0 0( , , )x y t
1 1 1( , , )x y t
2 2 2( , , )x y t
parabola
04-05-2017
4
Lecture 10 Slide 7
Spline Interpolation
For large number of points (N), many polynomials of small degree can be used. Polynomials of small degree are faster and easier to control.
x t
t t t
8-degree polynomial
spline spline vs. polynomial
Lecture 10
Spline Interpolation
A cubic polynomial between each pair of points:
4 parameters (degrees of freedom) for each spline segment.
Input parameters:
4 points
2 points + 2 directions
2 30 1 2 3( )x t c c t c t c t
04-05-2017
5
Lecture 10 Slide 12 6.837 Fall 2003
Interpolating Key Frames
• Interpolation is not fool proof.
• The splines may undershoot and cause interpenetration.
• The animator must solve these types of side-effects.
Keyframing
Keyframe animation can be applied to different parameters
Parameter to interpolate:
position,
orientation,
deformation,
lights,
camera,
opacity?
04-05-2017
6
Physics Simulation
04-05-2017
7
Physics Simulation
Particles
Rigid bodies
Deformable bodies
Fluid dynamics
Vehicle dynamics
Characters
Definitions
Kinematics: The study of motion without consideration of the underlying forces
Dynamics: Study of physical motion (or more abstractly, the study of change in physical systems)
Forward Dynamics: Computing motion resulting from applied forces
Inverse Dynamics: Computing forces required to generate desired motion
Mechanics, Statics, Kinetics
04-05-2017
8
Particles
Particula
p(t)
p(t+t)
zyx ppp ,,p
04-05-2017
9
Kinematics of Particles
Position : x
Velocity: v = dx/dt
Acceleration: a = dv/dt = d2x/dt2
dtvx
Aproximações númericas
Exato se v0 não varia em [0, t]
Exato se v(t) não varia em t
tvxtx 00)(
ttvttxtx )()()(
04-05-2017
10
Aceleração
Acceleration a=a0
Velocity
Position 00
2
0
00
xva2
1vx
vaav
ttdt
tdt
Aproximações númericas
Exato se a não varia em [0, t]
Exato se a(t) não varia em t
2)(2
1)()()( ttattvttxtx
2
002
1)( tatvxtx o
04-05-2017
11
Forces
Multiple forces can add up to a single total force:
Forces cause change in momentum (accelerations)
M/total
itotal
fa
ff
Gravity
Gravity near Earth’s surface is constant:
f=m.g (g = -9.8 m/s2)
Gravity for distant objects:
f=Gm1m2/r2 (G=6.673×10-11 m3/kg·s2)
04-05-2017
12
Spring-Damper
Spring: f = -kx
k=spring constant
x=distance from rest state
Damper: f=-cv
c=damping factor
v=velocity along spring axis
Spring-damper: f=-kx-cv
Aerodynamic Drag
Drag force: f=(1/2)ρaccdv2
ρ=fluid density
ac=cross sectional area
cd=coefficient of drag (geometric constant based on shape of object, usually between 0 and 1, but can be higher)
v=velocity of the object relative to velocity of the fluid
Note: for simple cases, (1/2)ρaccd is constant
04-05-2017
13
Friction
Static friction: f ≤ fnμs
Dynamic friction: f = fnμd
fn=normal force
μs=coefficient of static friction
μd=coefficient of dynamic friction
Force Fields
Generic force fields can be created that use arbitrary rules to define a force at some location: f=f(x)
Examples: vortex, attractors, turbulence, torus…
04-05-2017
14
Collisions: Impulse
Momentum: p = m.v
Impulse: J=Δp
An impulse is a finite change in momentum
Impulses are essentially large forces acting over a small time
Modified momentum update:
p=p0+fΔt+J p/m = p0/m+fΔt/m+J/m
v = v0+aΔt+J/m
[kg.m.s-1] or [N.s]
Particle Simulation 1
Particle struct {
Vector3d Velocity;
Vector3d Position;
float Mass;
}
UpdateParticle(float dtime) {
Force = ComputeTotalForce();
Acel = Force/Mass;
Velocity = Velocity + Acel * dtime;
Position = Position + Velocity * dtime;
}
04-05-2017
15
Particle Simulation 2
Particle struct {
Vector3d Momentum;
Vector3d Position;
float Mass;
}
UpdateParticle(float dtime) {
Impulse = ComputeTotalImpulse(dtime);
Momentum = Momentum + Impulse;
Velocity = Momentum / Mass;
Position = Position + Velocity * dtime;
}
Integration
Explicit Euler method:
v=v0+aΔt
x=x0+vΔt
Other methods: Implicit Euler
Runge-Kutta
Crank-Nicholson
Multipoint
Leapfrog
DuFort-Frankel
Adams, Adams-Moulton, Adams-Bashforth
Optimize for:
• Stability
• Accuracy
• Convergence
• Performance
04-05-2017
16
Rigid Bodies
Angular Speed
lim
0 t
d
t dt
• The average angular speed, ωavg, of a rotating rigid object is the ratio of the angular displacement to the time interval
• The instantaneous angular speed is defined as the limit of the average speed as the time interval approaches zero
• SI unit: radian per second (rad/s)
• Angular speed positive if rotating in counterclockwise
• Angular speed will be negative if rotating in clockwise
f iavg
f it t t
04-05-2017
17
Instantaneous Angular Acceleration
lim
0 t
d
t dt
• The instantaneous angular acceleration is defined as the limit of the average angular acceleration as the time goes to 0
• SI Units of angular acceleration: rad/s²
Torque
• Torque, t , is tendency of a force to rotate object about some axis
•
• Torque is vector: Direction determined by axis of twist
t Fd F is the force
d is the lever arm (or moment arm)
Units are Newton m
Φ is the angle between F and r t Fr sin
t Fd
04-05-2017
18
Offset Forces
Torque resulting from offset force: τ=r×f
Total force:
Total torque:
iff res
)fr( ii rest
Rotational Inertia
• Rotational inertia or moment of inertia I is the resistance of an object to changes in its rotational motion.
• Rotational inertia I is the rotational equal of mass M.
• Rotational inertia depends on:
• Mass
• Distribution of that mass around the axis of rotation.
Units: kg·m2
I = ⌠
⌡ r2 dm
04-05-2017
19
Moments of Inertia
Rotational Inertia
zzzyzx
yzyyyx
xzxyxx
III
III
III
I
dmxy
dmzy
xy
xx
)(I
)(I 22
zz
yy
xx
I00
0I0
00I
I0
TAIAI 0
For arbitrary axis:
A=3x3 orientation matrix
04-05-2017
20
Torque and Rotational Inertia
• Torque T is the application of a force which changes the angular acceleration of the object.