Game Development Reference
In-Depth Information
If you are working with a force-based engine, especially one that calculates the
reaction forces for all contacts, then friction can become another force in the calcu-
lation, and the equations we have seen can be applied directly. Although this sounds
simpler, there are consequences that make it even more difficult to calculate the re-
quired forces. I'll return to friction-specific force calculation in chapter 17. At this
stage it is simply worth noting that, despite the modifications we'll have to make to
convert friction into impulses, if we had gone through the force-only route initially,
it wouldn't have made friction any easier.
15.4.1
F RICTION AS I MPULSES
To handle friction in our simulation we must first understand what friction is doing
in terms of impulses and velocity.
Static friction stops a body from moving when a force is applied to it. It acts to
keep the velocity of the object at zero in the contact plane.
In our simulation we allow velocity to build up, and then we remove it with a
micro-collision. We can simulate static friction by removing sliding velocity along
with collision velocity. We already adjust the velocity of the object in the direction of
the contact normal. We could do something similar in the other two contact direc-
tions (i.e., the directions that are in the plane of the contact). If we went through the
same process for each direction as we did for the contact normal, we could ensure that
the velocity in these directions was zero. This would give the effect of static friction.
Rather than having a single value for the change in velocity, we now have a vector,
expressed in contact coordinates:
real deltaVelocity; // ... Calculate this as before ...
Vector3 deltaVelocityVector(deltaVelocity,
-contactVelocity.y,
-contactVelocity.z);
I'll come back later to the changes needed in the resolution algorithm to cope with
this.
This approach would remove all sliding. But static friction has a limit: it can only
prevent objects from sliding up to a maximum force. When dealing with the collision,
we don't have any forces, only velocities. How do we decide the maximum amount of
velocity that can be removed?
Recall that velocity is related to impulse:
m 1 g
˙
=
p
˙
where g is impulse, m is mass, and
p is velocity. So, if we know the amount of velocity
we need to remove, we can calculate the impulse required to remove it.
Search Nedrilad ::




Custom Search