Game Development Reference
In-Depth Information
of each hovercraft. The calculation is the same as that shown in the earlier version of
CheckForCollision :
vCollisionNormal = body1->vPosition −
The third and final calculation is aimed at determining the relative velocity between the
points of impact. This is an important distinction from the earlier version, since the
velocities of the points of impact on each body are functions of the linear and angular
velocities of the hovercraft:
v1 = body1->vVelocityBody +
v2 = body2->vVelocityBody +
v1 = VRotate2D(body1->fOrientation, v1);
v2 = VRotate2D(body2->fOrientation, v2);
vRelativeVelocity = v1 - v2;
Vrn = vRelativeVelocity * vCollisionNormal;
Here, v1 and v2 represent the velocities of the points of collision relative to each hov‐
ercraft in local coordinates, which are then converted to global coordinates. Once we've
obtained the relative velocity, vRelativeVelocity , we obtain the relative normal ve‐
locity, Vrn , by taking the dot product of the relative velocity with the collision normal
If there is no vertex-vertex collision, CheckForCollision proceeds to check for vertex-
edge collisions:
// Check for vertex-edge collision
for(i=0; i<4 && !haveNodeEdge; i++)
for(j=0; j<3 && !haveNodeEdge; j++)
edge = vList2[0] - vList2[j];
edge = vList2[j+1] - vList2[j];
u = edge;
p = vList1[i] - vList2[j];
proj = (p * u) * u;
d = p^u;
Search Nedrilad ::

Custom Search