Game Development Reference
In-Depth Information
where v is the desired change in velocity and g is the impulse required.
This stage of the algorithm has two parts. First we need to calculate the current closing
velocity at the contact point. Second we need to calculate the exact change in velocity
we are looking for.
Calculating the Closing Velocity
Before we can calculate the velocity change we need, we have to know what the current
velocity at the contact is.
As we saw earlier, velocity has both a linear and an angular component. To calcu-
late the total velocity of one object at the contact point we need both. We calculate its
linear velocity and the linear velocity of the contact point due to rotation alone.
We can retrieve the linear velocity from an object directly; it is stored in the rigid
body. To retrieve the velocity due to rotation we need to use equation 9.5 again. The
total velocity of the contact point for one object is given by
Vector3 velocity = body->getRotation() % relativeContactPosition;
velocity += body->getVelocity();
If there are two bodies involved in the collision, then the second body's values can be
added to the velocity vector.
This gives us a total closing velocity in world coordinates. We need the value in
contact coordinates because we need to understand how much of this velocity is in
the direction of the contact normal and how much is at a tangent to this. The com-
ponents of the velocity that are not in the direction of the contact normal represent
how fast the objects are sliding past one another: they will become important when
we consider friction.
The conversion uses the basis matrix in the now familiar way:
contactVelocity = contactToWorld.transformTranspose(velocity);
For frictionless collisions we will only use the component of this vector that lies in
the direction of the contact normal. Because the vector is in contact coordinates, this
value is simply the x component of the vector.
Search Nedrilad ::

Custom Search