Game Development Reference
In-Depth Information
for(i=0; i<4 && !haveNodeNode; i++)
{
for(j=0; j<4 && !haveNodeNode; j++)
{
vCollisionPoint = vList1[i];
body1->vCollisionPoint = vCollisionPoint −
body1->vPosition;
body2->vCollisionPoint = vCollisionPoint −
body2->vPosition;
vCollisionNormal = body1->vPosition −
body2->vPosition;
vCollisionNormal.Normalize();
v1 = body1->vVelocityBody +
(body1->vAngularVelocity^body1->vCollisionPoint);
v2 = body2->vVelocityBody +
(body2->vAngularVelocity^body2->vCollisionPoint);
v1 = VRotate2D(body1->fOrientation, v1);
v2 = VRotate2D(body2->fOrientation, v2);
vRelativeVelocity = v1 - v2;
Vrn = vRelativeVelocity * vCollisionNormal;
if( ArePointsEqual(vList1[i],
vList2[j]) &&
(Vrn < 0.0) )
haveNodeNode = true;
}
}
// Check for vertex-edge collision
if(!haveNodeNode)
{
for(i=0; i<4 && !haveNodeEdge; i++)
{
for(j=0; j<3 && !haveNodeEdge; j++)
{
if(j==2)
edge = vList2[0] - vList2[j];
else
edge = vList2[j+1] - vList2[j];
u = edge;
u.Normalize();
p = vList1[i] - vList2[j];
Search Nedrilad ::




Custom Search