Flexible Objects (1)
Download
Report
Transcript Flexible Objects (1)
Fundamentals of
Computer Animation
Flexible Objects (1)
Flexible Objects
Elastic and inelastic behavior, viscoelasticity, plasticity, fracture
Elastically Deformable Models
Terzopoulos et al
SIGGRAPH 87
Modeling Inelastic Deformation:
Viscoelasticity, Plasticity, Fracture
Terzopoulos and Fleiseher
SIGGRAPH 88
Graphical Modeling and Animation of Brittle Fracture
O’Brien and Hodgins
SIGGRAPH 99
Simulation of Object and Human Skin Deformations in a Grasping Task
Gourred et al
SIGGRAPH 89
Graphical Modeling and Animation of Ductile Fracture
O’Brien et al
SIGGRAPH 02
http://www.cs.berkeley.edu/~job/Projects/Fracture/fracture.html
Spring-Mass Systems
• Model objects as systems of springs and
masses
• The springs exert forces, and you control them
by changing their rest length
• A reasonable, but simple, physical model for
muscles
• Advantage: Good looking motion when it works
• Disadvantage: Expensive and hard to control
Flexible Objects SPRING-MASS SYSTEMS
The simplest, most common approach
Straightforward strategy:
Point Mass
Spring
(rest length = edge length)
External Forces
(collisions, gravity, wind, …)
Spring mass fish
Due to Xiaoyuan Tu, http://www.dgp.toronto.edu/people/tu
Spring mass fish
http://www.dgp.toronto.edu/~tu/animations.html
Strings
• A whole line of points attached together with springs
• Simple to model, great for making realistic straps of
bullets for chain guns, tails on animals, bungie ropes.
• The springs have a normal length of, say, one unit.
• If the adjacent points move further than one unit of
length apart, they experience a force towards each
other proportional to the extension of the spring that
connects them.
• Likewise, if they move closer than one unit apart,
they experience a force pushing them apart.
Strings
• Two ways to model the force on the points
• With mass If you are creating animations
• Without mass If you are just trying to find
the optimum shape of a string hanging over a
certain object
Forces between Two Springs
Strings without Mass
Forces affect the position of the point
c
vac
i
a
vab vac
f
vab lab vac lac
vab
s1
Normal length
b
f f g
gravity
s2 s1 f
Small amount (0.01 or so):
makes the string move slowly
Strings with Mass
Forces affect the velocity of the point
c
vac
i
a
vab
s1
•
•
b
If you make a string like
this, you will notice that it
is extremely flexible.
To make it stiffer, you can
compare each point with
its 4 or even 6 closest
neighbors, instead of 2.
vab vac
f
v
l
v
l
ab
ab
ac
ac
f f g
v v f
s2 s1 v
Damping (between about 0.95 and 0.99), is
the energy loss from the string. If you set it to
1, then the string will never stop swinging
around, and setting it to more than 1 will make
the string increase its swing by itself and
eventually fly off the screen.
Cloths
• Simply a whole load of interwoven strings!
• We need to add an extra dimension to our
string routine.
• Imagine a cloth to be a sheet of points all
connected together by springs.
• If two points get pulled further apart, then
they experience a force pulling them
together and vice versa.
• This very simple model of a cloth is
reasonably accurate!
Cloth Behavior
If you compare each point with its 4
nearest neighbors a fisherman's net.
If you compare each point with its 8
nearest neighbors a very flexible cloth
If you compare each point with its 24
nearest neighbors a more realistic,
stiffer cloth, though it's much slower to
compute
Massless Cloths
• Every point on the cloth moves at a rate proportional to
the sum of the forces acting on it from the neighboring
points.
• Create a 2-dimensional array of co-ordinates to hold the
x, y and z positions of the cloth in space.
• Initialize the values of cloth(p,q) to (p,q,0).
• We will need two of these arrays. One to hold the current
state of the cloth, and the other to hold the new cloth that
is being calculated.
• When we have finished calculating the cloth, copy all the
values from our second array back to the first.
cloth1 (0 to 31, 0 to 31)
cloth2 (0 to 31, 0 to 31)
Variables:
VECTOR: MovementVector
VECTOR: SpringVector
VECTOR: ForceVector
VECTOR: Gravity (initialised to (0, 0, g) where g is gravity, 0.02 is a good number)
REAL: Length
REAL: ForceScaler
REAL: NormalLength
For every point (p,q) on the cloth:
MovementVector = Gravity
For each of the 24 neighboring points:
SpringVector = (position in space of neighbour) - (position in space of point (p,q))
Length = length of SpringVector
NormalLength = The length SpringVector would be if the cloth were unstretched
ForceScaler = (Length - NormalLength) / NormalLength
SpringVector = SpringVector * (1/Length)
ForceVector = SpringVector * ForceScaler
ForceVector = ForceVector * SmallAmount
add ForceVector to MovementVector
end of loop
Add MovementVector to cloth1(p,q) and store it in cloth2(p,q)
make sure this point does not move inside an object
end of loop
Copy all the values in cloth2 to cloth1
keep doing all this forever
Cloth Interacting with Objects
• We will need some objects for the cloth to
interact with.
• The simplest is a floor.
• Check each point on the cloth to see if it is below
the floor, and if it is, then move it to the surface.
• It is quite easy to make a sphere for the cloth to
fall over!
• Check each point to see if it is inside the sphere.
• If it is, then move it to the nearest point on the
surface of the sphere.
Cloth with Sphere
REAL: Distance
Distance = distance from the point(p,q) to the center of the sphere
if Distance < (radius of sphere) then:
ForceVector = (position of point in space) - (center of sphere)
ForceVector = Forcevector / Distance * radius
point(p,q) = (center of sphere) + ForceVector
end if
Adding Wind
• Adding wind to the cloth allows us to simulate the
fluttering of flags and other cloth+wind kind of situations.
• This model is not totally accurate.
• The wind affects the cloth, but the cloth does not affect
the wind, to do this would require a vast amount of fluid
dynamic calculation.
• However, it produces reasonable looking fluttering
effects.
• For this we will need to be modeling cloth with mass.
Adding Wind
• First the cloth must be broken
down into triangles.
• This is easy to do, since the
cloth is already described as
an array of points.
• The effect of the wind on the
cloth is calculated on each of
these triangles individually.
• At each point of the cloth, the
sum of the effect of the wind
on the surrounding triangles is
calculated.
Adding Wind
• The force acting on a triangle due
to air molecules bouncing off it will
always be in the direction of the
normal vector of that triangle.
• The normal vector for each
triangle will obviously have to be
calculated every frame because it
will be constantly changing.
Adding Wind
• The force will be proportional to
– the surface area of the triangle,
– the angle at which the wind hits
the triangle,
– and the speed of the wind.
• When we use the Cross Product
to calculate the normal vector of
the triangle, the length of that
vector is proportional to the
area of the triangle, which makes
things a little simpler.
VECTOR: force
VECTOR: normal
VECTOR: wind
set force vector to (0,0,0) on all points on cloth
loop through all triangles
force = unitvector(normal) * dotproduct(normal, wind)
add force to all points making up this triangle
end of loop
loop through all points on cloth
add gravity to force
add force to velocity
end of loop
-- rest of cloth routine --