Title: Chap 7 Physically Based Animation
1Chap 7Physically Based Animation
2Physically Based Animation
- Forces are typically used to maintain
relationships among geometric elements - Accuracy vs. physical realism
- Animators is not necessarily concerned with being
accurate but rather with believabibity - Some forces may not relate to physics at all
- They may model constraints that an animator may
wish to enforce on the motion
3Physically Based Animation
- When modeling motion using physics principles, we
need to decide the level at which to model the
process - Procedure
- Computationally less expensive, easier to program
- Lacks flexibility
- Purely physics
- Computationally expensive
- More flexible
4Physically Based Animation
- When physical models are used, animator
- is relieved of lower level specification of
motions - Needs to be concerned with specifying high-level
relationships or qualities of the motion
5Outline
- Basic physics
- Spring meshes
- Particle systems
- Rigid body simulation
- Enforcing soft and hard constraints
- A Good reference
- Read Witkin and Baraffs SIGGRAPH01 course
notes Physics-based modeling at
http//www.pixar.com/companyinfo/research/pbm2001/
index.html
6Basic physics
7Basic physics
8Basic physics
9Spring meshes
- Flexible objects
- Flexibility is modeled by a spring-mass-damper
simulation simulating the reaction of the body to
external forces. - Each vertex a point mass
- Assigned by animators
- Evenly distributed among objects vertices
- Each edge a spring
- Rest length is original edge length
- Spring constants
- Arbitrary, assigned uniformly throughout the
object
10Spring meshes
- Spring-mass-damper simulation
- As external forces are applied to specific
vertices - Vertices will be displaced relative to other
vertices - The displacement induces spring forces, which
will impart forces to the adjacent vertices and
reactive forces back to initial vertices. - Force propagation one time step at a time
11Spring meshesA simple example
Instant force F applied to V2. Length of springs
E12 and E23 changes. Spring forces impart
restoring forces to V1 and V2, and V2 and
V3 Since external force is wrongly assumed
constant throughout the time step, a spring
simulation may numerically explode (the motions
get larger and larger). A smaller time step, or
smaller spring constant, or larger masses can be
used but slow down the simulation. A common
method add dampers.
12Spring meshesDampers
- A damper introduces an additional force in the
spring that works against the velocity of the
spring length, thus helping to limit the speed at
which a spring changes length. - Help to control the change in length and keep it
within some range that does not allow the
simulation to explode.
13Spring meshes
- Modeling with only object edges with spring
dampers can result in a model that has more than
one stable configuration. - Additional spring dampers can help to stabilize
the shape.
If a cubes edges are modeled with spring
dampers, during applications of extreme
external force is applied, the cube can turn
Inside out.
14Spring meshesAngular spring dampers
- angular spring resists deviation to the rest
angle between faces and imparts a torque along
the edge that attempts to restore the rest angle.
15Spring meshesVirtual springs
- Virtual springs introduce forces into the system
that do not directly model physical elements. For
example, - Example on the last page
- Virtual springs with zero rest lengths can be
used to constrained one object to lie on the
other - Virtual springs with non-zero rest lengths can be
used to maintain separation between moving
objects.
16Particle systems
- Particles have been used to animate many
behaviors, such as gases, water, fire, rubber,
clothes, flocking, hair.
17Particle systemsAssumptions
- Particles do not collide with other particles
- Particles do not cast shadow on each other,
except in an aggregate sense - Particles only cast shadow on the rest of
environment - Particles do not reflect light
- Particles often have a finite life span
18Particle systemsSteps in a frame
- Generate any new particles
- Each new particle is assigned attributes
- Any particles that have exceeded their life span
are terminated - The remaining particles are animated and their
shading parameters changes according to the
controlling process - The particles are rendered
19Particle generation
- For each frame, particles are generated according
to a controlled stochastic process - User-specified distribution centered at the
desired average number of particle per frame - Can be function of time
20Particle attributes
- Particle properties
- mass
- position
- velocity
- force accumulator
- age, lifespan
- rendering properties (shape parameters, color,
transparency) - Each of the attributes is initialized when the
particle is created.
21Particle life span
At each new frame, each particles lifetime is
decremented by one When the attribute reaches
zero, the particle is removed from the system.
22Particle animation
- Each particle is animated throughout its life.
- Includes position, velocity, and rendering
attributes - Position and velocity
- Users consider forces and compute the resultant
particle acceleration, update its velocity, and
update the position. - Color and transparency can be a function of time,
its own life span remaining, its height, and so
on. Shape can be a function of its velocity
23Particle animation Forces on particles
- Forces can be unary, particle pair, or
environmental. - Unary forces
- Gravity, viscous drag
- Particle pair forces
- Can be represented by springs and dampers, if
desired. - Environmental forces
- Arise from a particles relationship to the
environment
24Forces on particles
- Particles respond to forces
- We represent this using differential equations
2nd order ODE
1st order ODEs
25Unary Forces
- Forces that only depend on one particle
fdrag
v
Viscous Drag
Gravity
Wind Fields
f mg
f kvwind
f -kdv
26n-ary Forces
- Forces that depend on n particles
- Example binary forces between two particles -
spring and damper
Springs
27n-ary Forces Spring Force
- If particle is located farther than the rest
position, the spring force needs to pull it back - If the particle is located nearer than the rest
position, the spring force needs to push it away - Combine two cases
28n-ary Forces Damping Forces
- According to the law of energy conservation, a
particle system consists of only masses and
springs keep bouncing from each other after
external forces disappear - Damping/viscous drag force resist motion, making
a particle system gradually come to rest in the
absence of external forces
29n-ary Forces Damping Forces (cont.)
- It is highly recommended that at least a small
amount of damping is applied to each particle - Excessive damping, however, makes a particle
appear that floating in molasses (energy
dissipates out too quickly, not responsive)
30n-ary Forces Damper Force
- If two particles are departing, the damper force
needs to pull them back - If two particles are approaching, the damper
force needs to push them away - Combine two cases
31Spatial Forces
- Forces that depend on nearby particles within a
local region
Gravity, Lennard-Jones and electric potentials
32Particle rendering
- Several methods
- Model each particle as a point light source
- Each particle is rendered to a small graphical
primitive (blob). - Particles that map to the same pixels in the
image are additive - the color of a pixel is
simply the sum of the color values of all the
particles that map to it - Model each particle as a textured billboard
- Polygon facing the viewer, texture
- Rendered as Metaballs in off-line rendering
isosurfaces computed from particle-metaballs make
quite convincing liquids.
33Particle renderingParticle
34Particle renderingParticle
35Particle rendering Billboard texture
36Particle rendering Billboard texture
37Particle rendering Billboard texture
From Mark Harriss work http//www.markmark.net/cl
ouds/
38Particle renderingBillboard texture
- An impostor replaces a cloud with a billboard
textured with an image of the cloud from a
certain viewpoint. - Image is updated only when translation of the
viewpoint introduces enough error in the image - Impostors can be reused for many frames.
- By using impostors, we are able to render cloudy
scenes of hundreds of clouds and hundreds of
thousands of particles at very high frame rates.
39Particle renderingBillboard texture
Figure 6 Impostor generation and translation
error metric.
Impostor generation and translation error metric
40Particle rendering
Video Cloud rendering by Niniane
Wang http//www.ofb.net/niniane/clouds/
41Particle renderingMetaballs and isosurface
From Screen Space Fluid Rendering with Curvature
Flow http//industrialarithmetic.blogspot.com/20
09/01/ our-paper-screen-space-fluid-rendering.html
42Collision Detection
- Determine when a particle has collided an object
- Particle has collided if and only if
Objects surface
43Collision Response
- What should we do when a particle has collided?
- The correct thing to do is rollback the
simulation to the exact point of contact - Easier to just modify positions and velocities
After the collision
44Contact Forces
- When the particle is on the collision surface a
contact force resists penetration - Contact forces do not resist leaving the surface
- Simple friction can be modeled
45Structure of Particle Systems
- Separate the data structures and integration
state
Particle System
Solver
send data as 6n vectors
time
particles
state
derivatives
state/derivatives
Particle
x v f m
x v f m
x v f m
x v f m
46Structure of Particle SystemsImplementation
Solver
System
GetDim
6
Get/Set State
x v f m
x v
v f/m
Deriv Eval
47Structure of Particle SystemsImplementation
Solver
System
GetDim
6n
particles
Get/Set State
x1 v1
x2 v2
xn vn
n
time
v1 f1/m1
v2 f2/m2
vn fn/mn
Deriv Eval
48Physics Engines for Dynamics Simulation
- Open Dynamics Engine (ODE)
- Free software http//www.ode.org/
- high performance library for simulating rigid
body dynamics. - It is fully featured, stable, mature and platform
independent with an easy to use C/C API. - It has advanced joint types and integrated
collision detection with friction. - ODE is useful for simulating vehicles, objects in
virtual reality environments and virtual
creatures.
49Physics Engines for Dynamics Simulation
- Havok
- Commercial software
- Reactor in 3ds MAX
- State-of-the-art game physics solution, for use
with in-house game animation systems - Havok Destruction is the cross-platform tool for
simulation of rigid body destruction.
50Physics Engines for Dynamics Simulation
- NVIDIA PhysX
- A powerful physics engine which enables real-time
physics in leading edge PC and console games. - Is widely adopted by over 150 games, is used by
more than 10,000 registered users. - Designed specifically for hardware acceleration
by powerful processors with hundreds of cores.
Combined with the tremendous parallel processing
capability of the GPU, PhysX will provide an
exponential increase in physics processing power
51Physics Engines for Dynamics Simulation
- AGEIA PhysX accelerator
- The worlds first dedicated physics processor
designed to support extreme physical gaming
interactions. - Its highly parallel, interactive PhysX cores are
optimized for dynamic, large-scale, physics
processing to accelerate physical motion and
interaction at a scale and quality far beyond
that of general purpose processors.
52Rigid Body Simulation
- Various forces to be simulated are modeled.
- When the forces are applied to objects, they
induce - linear acceleration (based on objects mass)
- angular acceleration (based on masss
distribution) - These accelerations are integrated over a delta
time step to get changes of objects velocities,
which in turns integrated over a delta time step
to produce changes in position and orientation.
53Rigid Body Simulation
- Various forces to be simulated are modeled.
- When the forces are applied to objects, they
induce - linear acceleration (based on objects mass)
- angular acceleration (based on masss
distribution) - Read Witkin and Baraffs SIGGRAPH01 course
notes Physics-based modeling - http//www.pixar.com/companyinfo/research/pbm2001/
index.html
54Rigid Body SimulationUpdate cycle
55Rigid Body Simulation
- Continuous process vs. discrete time simulation
- Assume acceleration is constant over the delta
time step - These accelerations are integrated over a delta
time step to get changes of objects velocities,
which in turns integrated over a delta time step
to produce changes in position and orientation. - How to update?
- Euler integration method
- Runge Kutta method Second-order in magnitude
of error term
56Physics-based Simulation
- A procedure that generates a sequence of the
states of a system based on physics laws
xi
Newtonian laws elastic forces wind gravity frictio
n
xi
xi1
xi1 xi ?x
?x
57Differential Equations
- Differential equation describes the relation
between an unknown function and its derivatives - Solving a differential equation is to find a
function that satisfies the relation - Numerical solution of differential equations is
based on finite-dimensional approximation
58Ordinary Differential Equations
- Ordinary differential equation (ODE)
- All derivatives are with respect to single
independent variable, usually representing time
Known function
Unknown function that evaluates the state given
time
Time derivative of the unknown function
Well show that a higher ODE can be transformed
into this 1st order system soon!
59Higher-Order ODEs
- Order of ODE determined by highest-order
derivative of solution function appearing in ODE - Equations with higher derivatives can be
transformed into equivalent first-order system
60Higher-Order ODEs (cont.)
- Given k-th order ODE
- Define
- Original ODE equivalent to first order system
61Visualizing Solution of ODE
62Vector Field
- The complete set of all solutions to the
differential equation
defines a vector field over (x, t) plane.
Think of this vector field as the sea, and the
velocity of current at different places and time
is defined by f(x,t)
63Initial Value Problem
- For a particular initial value, the solution is a
curve. - Given the starting point, follow the integral
curve
Release a ball at any starting point and let it
drift following the current. The trajectory swept
out by the ball is an integral curve.
64Numerical Solution of ODEs
- Instead of true integral curve, numerical
solution follow a polygonal path - Each leg is obtained by evaluating the derivative
at discrete time steps - Bigger steps, bigger errors
65Issue I Inaccuracy
- Error turns x(t) from a circle into the spiral of
your choice! - May jump to other circles
66Issue II Instability
to Neptune!
67Eulers Method
- Simplest numerical solution method
- Bigger time steps, bigger errors
68Eulers Method (cont.)
- Solves ODE using one-term Taylor-series
O(h2) 2nd order accurate
69Eulers Method (cont.)
- Truncation error in s single step O(h2)
- The error in a complete solution is an
accumulation of all the single step errors
70Rigid Body Simulation Euler integration method
(Book)
- Explicit Euler integration method
71Drawbacks of Eulers Method
- Too inaccurate to be used in practice
- Inefficiency
- Need to use small time-steps to avoid divergence
- Example http//www.cse.uiuc.edu/iem/ode/eulrmthd/
- Improvement using the midpoint method
- Slope at midpoint is used
72Runge-Kutta methodThe Midpoint Method
- a. Compute an Euler step
- b. Evaluate f at the midpoint
- c. Take a step using the midpoint value
Assume f depends on t only indirectly through x
x2
x1
73Runge-Kutta method The Midpoint Method (cont.)
- Solves ODE using two-term Taylor-series
- Approximating f by Taylor-series
74Runge-Kutta method The Midpoint Method (cont.)
Turning O(h2) to O(h3)
75Runge-Kutta method The Midpoint Method (Book)
- Runge Kutta method
- Symmetric w.r.t. the time interval
- Second-order in magnitude of error term
76Runge-Kutta 4th Order Method
- Using a weighted average of slopes obtained at
four points
77Runge-Kutta 4th Order Method (Book)
- Fourth-order Runge Kutta method
78(No Transcript)
79Adaptive Step Size
- Ideally, we want to choose h as large as
possible, but not so large as to cause big error
or instability - We can vary h as we march forward in time
80Adaptive Step Size for Eulers Method
- Estimate xa by taking a full Euler step
- Estimate xb by taking two half Euler steps
- xa and xb differ from the true value of x(tah)
by O(h2) - e xa - xb is bounded by O(h2), giving us
convenient estimate to the error in taking an
Euler step of size h - How to do adaptive steping ?
81Adaptive Step Size for Eulers Method
- What is optimal h if we want to have an error of
as much as e, and the current error is e?
82Take Home Message
- Dont use Eulers method
- Inaccuracy
- Inefficiency (or unstable)
- Do use adaptive step size
- Read Witkin and Baraffs SIGGRAPH01 course
notes Physics-based modeling - http//www.pixar.com/companyinfo/research/pbm2001/
index.html
83Motion equation for a rigid body
- To develop the equations of motion for a rigid
body, we need to discuss - Linear force vs. rotational force
- Torque
- Linear momentum vs. angular momentum
- Inertia tensor
- Equations
84Orientation and rotational movement angular
velocity
- Angular velocity w(t)
- Direction Axis of rotation,
- Speed of orientation in revolutions per unit of
time - For linear motion, x(t) and v(t) are related by
- How are R(t) and w(t) related?
- We need to find how the derivative of a vector in
a rigid body is related to w(t)
85Orientation and rotational movement angular
velocity of a particle
- Angular velocity of a point
p
86Orientation and rotational movement angular
velocity of a particle
87Orientation and rotational movement angular
velocity of a particle
88Orientation and rotational movement angular
velocity of a rigid body
- Angular velocity of a rigid body
- Position and orientation of a rigid body are
represented by x(t), and R(t) - x(t), and R(t) are used to transform the
body-space description into world space
89Orientation and rotational movement angular
velocity of a rigid body
- R(t) specifies a rotation of the body about the
center of mass - It is a matrix of 3 orthogonal column vectors
- At time t,
- represents the x-axis of body space in world
space - Each column vector represents a vector from the
origin - A point Q on the rigid body with local coordinate
q
90Orientation and rotational movement angular
velocity of a rigid body
91Orientation and rotational movement angular
velocity of a rigid body
- At time t, the derivative of the first column of
R(t) is the rate of change of this vector. So
92Orientation and rotational movement angular
velocity of a rigid body
- A point Q on the rigid body with body-space
coordinate q. - Then the world-space location of q(t) is the
result of first rotating q about the origin and
then translating it
This separates the velocity of a point on a
rigid body into two components A linear
component v(t) A angular component w x (q(t)-x(t))
93Orientation and rotational movementCenter of mass
- Integration of the differential mass times its
global position in the object
94Orientation and rotational movementForces and
torque
- Linear force vs. rotational force
95Orientation and rotational movementLinear
momentum
- Linear momentum p of a particle with mass m and
velocity v - Linear momentum of a rigid body
Total linear momentum of a rigid body is the same
as if the body is simply a particle with mass m
and velocity v(t).
96Orientation and rotational movement Linear
momentum
- Derivative of linear momentum and force
- Instead of v(t), we use P(t) as a state variable
for the rigid body. - Be more consistent with the way we deal with
angular velocity and acceleration.
97Orientation and rotational movementAngular
momentum (book)_
- Angular momentum of a particle
98Orientation and rotational movement Angular
momentum (book)
- Angular momentum of an object
99Orientation and rotational movementAngular
momentum
- Angular momentum of a rigid body
- Similar to linear momentum
- where I(t) (called inertia tensor) is a 3x3
matrix that describe how the mass in the body
is distributed relative to the bodys center of
mass. - I(t) depends on orientation of the body but does
not depend on the bodys translation
100Orientation and rotational movementInertia tensor
- At a given time t, let be the
displacement of particle i from bodys mass
center x(t) by - .
- I(t) is expressed in terms of ri as the
symmetric matrix
101Orientation and rotational movementInertia tensor
- How to compute I(t) for a rotated dody?
- Compute at run-time? Too expensive!
- Pre-computed I(t) in body-space coordinates and
then compute it at run time after rotation.
102Orientation and rotational movementInertia tensor
103Orientation and rotational movementInertia tensor
104Orientation and rotational movementInertia tensor
Constant over the simulation
Let
We have
105Orientation and rotational movementInertia tensor
106Orientation and rotational movementInertia tensor
- Linear momentum and linear velocity
- Angular momentum and angular velocity
- I(t) inertia tensor, describes how the mass is
distributed about the center of mass in space - For an un-transformed object Iobject
- For a transformed object (depends only on
orientation)
107Motion Equation
- The state of a rigid body
- Spatial information
- Position
- Orientation
- Velocity information
- Linear momentum
- Angular momentum
- Known information
- Mass
- Body-space inertia
108Motion Equation
109Bodies in collision
- Objects moving in a dynamic scene
- Objects in collision need to do the detection
- Objects sliding against on other object
- Objects resting on each other
- Need to calculate forces for computing accurate
reaction
110Bodies in collision
- Ultimate goal in VR
- Real and virtual objects need to behave like real
ones. - At a minimum
- Objects should not pass through each other, and
things should move as expected when pushed,
pulled, or grasped. - Overall
- Physical simulation in VR must run reliably,
seamlessly, automatically, and in real time.
111Collision detectionComputer Animation
112Collision detectionHaptic Interaction
From J.C. Latombes notes
113Collision detectionMotion/Path Planning
From J.C. Latombe
From James Kuffner
114Collision detectionCrowd Simulation
From J.C. Latombes notes
115Bodies in collision
- To prevent interpenetration
- Collisions must be detected.
- Velocities must be adjusted in response to
collisions. - Collision response must be computed.
- If the collision response does not cause the
objects to separate immediately, contact forces
must be calculated and applied until separation
finally occurs.
116Problems of Collision Detection
- A naive collision detection has
- Fixed-timestamp weakness
- All-pair weakness
- Pair-processing weakness
- Features that current methods have
- Interactive rate
- Handle polygon soaps
- Models can undergo rigid-body motion
- Provide well-fit bounding volume
- Collision detection only occurs at discrete times.
117Performance of a naive method
- All-pair weakness
- If the scenario contains n moving objects and m
static objects, total object test for each frame
is - Pair processing weakness
- Note
- Performance evaluations for collision detection
are extremely difficult since algorithms are
sensitive to the actual scenarios, and there is
no algorithm that performs best in all cases.
118Speed Up Methods
- Bounding volume for object level and polygon
level. - Pure bounding volume
- Hierarchical bounding volumes
- Support progressive collision detection.
- Spatial coherence
- Usually large regions of the space are occupied
by only one object or none at all. If some
objects share the same region, they are likely
intersecting. - Time coherence
- Moving objects usually move on a continuous path.
Results of earlier collision query can be
exploited.
119Two-level Collision Detection
- Two-level Collision Detection
- Globally searching pairs of objects that have
potential collision - Spatial partition
- Dimension reduction and sorting (Sweep-and-Prune)
- Collision detection on a pair of objects
- Hierarchical CD based on OBBTree, AABBTree,
- Polygon-polygon overlap test
119
120Two-level CD system
Pruning Multi- Body pairs (Sweep/Prune)
Exact collision Detection (OBB tree)
Simulation
Collision response
121Space Partition
- Spatial coherence is usually exploited by
partitioning the space. - All-pair weakness can be resolved by the use of
spatial coherence. - Space partition methods differ in fast
neighbor-finding (for static environments) and
fast updating for moving objects. - Grid (uniform partition)
- Octree
- Binary space partition
122Temporal Coherence One or Two-Dimension Sweep
and Prune
- Sorting objects in 3-D space by dimension
reduction - If two objects collide in a 3D space, their
orthogonal projections onto the xy, yz, and
xz-planes and x, y, and z-axes must overlap. - Project bounding volume of objects.
- Based on Axis-aligned bounding boxes (AABB).
- Fixed-size bounding cube large enough to contain
the object at any orientation. - Dynamically-resized rectangular bounding boxes
123One or Two-Dimension Sweep and Prune
- Project each 3D box onto x, y, and z axes.
- Construct 3 lists, one for each dimension.
- Each list contains the values of the endpoints of
the projected interval corresponding to that
dimension. - Determine which intervals overlap by sorting
these lists. - Utilize temporal or frame coherence by changing
only the values of the interval endpoints. - Bubble sort or insertion sort work well for
previously sorted lists.
124One or Two-Dimension Sweep and Prune
Implementation issues - -1
- Fixed-sized cubes are preferred over
dynamically-resized boxes, except for the class
of oblong objects. - Which sorting method is better?
- Bubble sort works better for environments where
only a few objects move, such as walkthrough - Insertion sort works better for environments
where large number of objects move. - Overlap status consists of a Boolean flag for
each dimension. Whenever all three of these flags
are set, the bb of objects pair overlap.
125Bounding Volumes
- Bounding volume is used to do a pre-check before
doing any further collision detection. - Bounding sphere (BS)
Fast overlapping check, not a
tight fit. - Axis-aligned bounding box (AABB)
Fast overlapping check, a better tight fit. - Oriented bounding box (OBB) Tight
fit, but with relatively expensive overlapping
test. - K-DOPS (direct oriented polytopes)
OBB more cutting axes
126Bounding Volumes
127Hierarchical Bounding Volumes
- Hierarchical bounding volume is useful
- For efficiently resolving the pair-processing
weakness, and - Providing a basis for the hierarchical or
time-critical scheme for collision detection. - Three types
- Hierarchical Axis-aligned bounding box
- Hierarchical Oriented bounding box
- Hierarchical Bounding sphere
128General Hierarchical Collision Detection Scheme
- Common denominators of these schemes
- A hierarchical bounding volume is built for each
object. - High-level code for a collision query is similar,
regardless of the BV type used. - BV-BV overlapping tests and primitive-primitive
overlapping tests are different depending on what
BVs and primitives are used. - A simple cost function can be used to trim,
evaluate, and compare performance.
129Hierarchical Collision Detection Hierarchy
Building
- Common hierarchy used
- K-ary tree, where each node may at most have k
children. - At each internal node, there is a BV enclosing
all its children. - At each leaf, there are one or more primitives.
- Three ways of building a hierarchy
- Bottom-up
- Incremental tree insertion
- Top-down
130Hierarchical Collision Detection Bottom-up
Hierarchy Building
- Start
- Starts by combining a number of primitives and
finding a BV for them. - Grouping
- This BV is grouped with one or more BVs
constructed in a similar way, thus yielding a
new, larger parent BV. - Recursive grouping
- Repeat the grouping until only one BV exists,
which becomes the root of the hierarchy.
131Hierarchical Collision Detection Hierarchy
Building by Incremental tree-insertion
- Start with an empty tree
- All other primitives and their BVs are added one
at a time to the tree. - To make an efficient tree, an insertion point
should be selected so that the total tree volume
increase is minimized. - Little is known about this scheme in the context
of collision detection.
132Hierarchical Collision Detection Top-Down
Hierarchy Building
- Start
- Find a BV for all primitives of the object, which
is then acts as the root of the hierarchy. - Recursively apply a divide-and-conquer strategy
- First to split the BV into k or fewer parts and
find all included primitives for each such part.
A BV is then created for each part. - Potential advantage
- A hierarchy can be created on an as-needed basis,
i.e., we can construct the hierarchy for those
parts of the object where it is actually needed. - Used by majority of hierarchical CD.
133Hierarchical Collision Detection
- K-ary tree
- K 2 minimizes the work to be done when
traversing a path from root to the worst-case
leaf, and it is easier to compute the hierarchy
than the case of higher k. - Higher k gives a tree with lower height, but it
requires more work at each node.
134Hierarchical Collision Detection
- Challenges
- Find tight-fitting bounding volume.
- Find hierarchy construction that creat balanced
and efficient tree. - Efficient BV-BV overlapping test.
- Efficient primitive-primitive overlapping test.
- Notes
- Balanced trees are expected to perform best in
all cases, since the time of CD query will not
vary. - But, it does not mean that it is best for all
inputs, e.g., those parts that seldom or never be
queried for a collision can be located deep in
the hierarchy.
135Hierarchical Collision DetectionCollision
testing between Hierarchies -1
- Collision detection
- Test whether or not two objects collide, and may
terminate whenever a pair of triangles has been
found to be overlapping. - Collision determination
- In some cases, all pairs of overlapping triangles
might be wanted. - Can be solved with small alterations of the code
for collision detection.
136Hierarchical Collision DetectionCollision
testing between Hierarchies -2
- FindFirstHitCD(A, B)
- return(TRUE, FALSE)
- if (not-overlap(ABV, BBV) return FALSE
- else if(isLeaf(A)) / try to reduce tested
pairs / - if(isLeaf(B))
- for each triangle pair TA in
AC and TB in BC - if(overlap(TA, TB))
return TRUE - else for each child CB in BC
-
FindFirstHitCD(A, CB) - else for each child CA in AC
- FindFirstHitCD(CA,
B) - return FALSE
137Hierarchical Collision DetectionCost function -1
138Hierarchical Collision DetectionCost function -2
- Conflicting goals
- Creating a better hierarchical representation
results in lower values of nv, np, and nu. - Creating better methods for BV-BV or
primitive-primitive tests would lower cv, cp. - Bounding volume examples
- Sphere, AABB, OBB
- K-DOPS (direct oriented polytopes)
- Pie slices
- Spherical shells good fits for Bezier surfaces
139Hierarchical OBBTree
- Why OBBTree?
- Sphere tree and AABBTree do very well in
performing rejection tests, whenever two objects
are far apart but do poorly for objects in close
proximity and having multiple contacts. - OBBTree was designed to perform especially well
if parallel close proximity is found during
collision detection. - Parallel close proximity Two surfaces are very
close and nearly parallel. - A fast overlapping test for OBB-OBB is provided.
140Hierarchical OBBTree
- Collision detection based on OBBTree
- Preprocessing
- Building an OBBTree for each object.
- Top-down
- Bottom-up
- Detection computation
- Perform recursively the separating-plane test for
each pair of objects.
141Building an OBBTreeTop-down approach
- Split the polygon soap along the longest axis of
the OBB. - Pass through the OBBs center
- OBBTree may not balanced.
- If the split fails, the next longest axis can be
used. - Pass the point that corresponding to the median
of the projection of all triangle centroids onto
this axis. - OBBTree can be balanced.
- Partition the polygons into two sub-groups based
on their centroids. - After split, an OBB is found for each sub-group.
142Building an OBBTreeTop-down approach
143Building an OBBTreeDerive a good-fit OBB -1
- For a given triangle soap, compute an orientation
of the triangles vertices (via the first and
second order statistics) - ? average of all vertices
- C the covariance matrix
- Based on C
- The normalized orthogonal eigenvectors of C are
used as a basis - axes of the OBB. - External vertices along each axis yields sizes of
the OBB.
144Building an OBBTreeDerive a good-fit OBB -2
- OBB for a polygon soap can also be found by
computing an orientation of the triangles of the
convex hull - The OBB will be less dependent on the
distribution of polygons. - The convex hull of an object is computed.
- Can be done by, e.g., Quickhull algorithm.
- In return, we have n triangles, and based on
which a covariance matrix is derived. - Centroid of the convex hull
- Covariance matrix
- Normalized eigenvectors of C as the OBBs axes.
- Min-max extent on each axis.
145Building an OBBTreeDerive a good-fit OBB -3
146Fast Overlap Test for OBBsHandling Rigid-Body
Motions
- In OBBTree, each OBB is stored with a rigid-body
transformation (a rotation R and a translation
vector t ) matrix MA. - When testing CD of OBBs A and B,
- The overlap test should be done in the coordinate
system of one of OBBs, say A. - So A is now a AABB.
- Transform B into As coordinate system with
147Fast Overlap Test for OBBsSeparating Axis Theorem
- A naïve algorithm requires 144 edge-face test
(12 edges x 6 faces x 2 boxes) - Separating axis theorem
- For any two arbitrary, convex, disjoint
polyhedra, A and B, there exists a separating
axis where the projections of A and B are also
disjoint. - Checking for disjoint OBBS involves searching for
a separating axis. - If A and B are disjoint, then they can be
separated by a separating axis that is orthogonal
to either - A face of A, or
- A face of B, or
- An edge from each polyhedron.
148Fast Overlap Test for OBBsSeparating Axis Theorem
Axes p and q are orthogonal to faces of A. Axes s
and t are orthogonal to faces of B. It is
sufficient to find one axis that separates the
projection in order to know that the OBBs do not
overlap. Here, q is the only axis that separates
the projections.
149Fast Overlap Test for OBBsSeparating Axis Theorem
- General separating-plane test 15 tests
- Three axes of A,
- Three axes of B, then
- Nine axes from A and B (9 axes).
- Sequentially test for each axis candidate
- Do axis projection and form the interval on the
axis. - Two objects are disjoint if their intervals don't
overlap. - If the intervals overlap, boxes may or may not be
disjoint. Further tests on other axes may be
needed. - More efficient way?
- What are the axes and in which order?
150Fast Overlap Test for OBBs A fast separation
test -1
- Assume that a potential separating axis is l.
- Radii of the OBBs A and B on the axis l
151Fast Overlap Test for OBBsA fast separation test
-2
- Done in the coordinate system of A
- Formed by As center and axes
- ac, axes au, av , aw
- B is assumed to be relative to A
- By separating axis theorem
- It is sufficient to find one axis that separates
A and B to be sure that they are disjoint. - Fifteen axes have to be tested
- 3 from the faces of A (axes of A au, av , aw)
- 3 from the faces of B (axes of B bu, bv , bw)
- 3x39 from combinations of edges from A and B
- (cij ai x bj, i,ju,v,w)
152Fast Overlap Test for OBBs A fast separation
test -3
Simplify the expression by working in
the coordinate system of A Case 1
153Fast Overlap Test for OBBs A fast separation
test -4
Simplify the expression by working in
the coordinate system of A Case 2
154Fast Overlap Test for OBBs A fast separation
test -5
Case 3
155Fast Overlap Test for OBBs A fast separation
test -6
- If any of these 15 tests is positive, the OBBs
are disjoint. - Number of operations
- Maximum 180, or 240 if transformation of B into
As coordinate system in included. - Order of axes
- Has an impact on performance.
- First test three axes of A
- They are orthogonal and thus reject the overlap
faster, and the simplest tests. - Then three axes of B, followed by the axes formed
by axes of A and B.
156Fast Overlap Test for OBBs Another fast
separation test -7
- Simply skip the last 9 axis tests can speed up
the overlapping test, - Geometrically, this is amount to doing two
AABB-AABB tests. - But sometimes report two disjoint OBBs as
overlapping. - In these cases, the recursion in the OBBTree will
go deeper than necessary. -
157Two-level CD system
- Globally searching pairs of objects that have
potential collision. - Spatial subdivision
- Sweep-and-Prune
- Collision detection on a pair of objects
- Hierarchical CD based on OBBTree, AABBTree,
- Polygon-polygon overlap test
158Two-level CD system
Pruning Multi- Body pairs (Sweep/Prune)
Exact collision Detection (OBB tree)
Simulation
Collision response
159Time-critical collision detection
- Time critical computing needs to consider all
computations involved in each frame update. - Two major computations
- Rendering and Collision detection
- Time-critical collision detection
- Progressive refinement on the discrete-time
collision detection using hierarchical
representations, such as - Sphere tree, box tree (axis-aligned or oriented).
- Hard to estimate the allocated time.