Game Development Reference
In-Depth Information
for(i=0; i<4; i++)
VRotate2D(body1->fOrientation, vList1[i]);
vList1[i] = vList1[i] + body1->vPosition;
wd = body2->fWidth;
lg = body2->fLength;
vList2[0].y = wd/2; vList2[0].x = lg/2;
vList2[1].y = -wd/2; vList2[1].x = lg/2;
vList2[2].y = -wd/2; vList2[2].x = -lg/2;
vList2[3].y = wd/2; vList2[3].x = -lg/2;
for(i=0; i<4; i++)
VRotate2D(body2->fOrientation, vList2[i]);
vList2[i] = vList2[i] + body2->vPosition;
The vertex lists are initialized in unrotated body-fixed (local) coordinates based on the
length and width of the hovercraft. The vertices are then rotated to reflect the orientation
of each hovercraft. After that, the position of each hovercraft is added to each vertex to
convert from local coordinates to global coordinates
Checking first for vertex-vertex collisions, the function iterates through each vertex in
one list, comparing it with each vertex in the other list to see if the points are coincident.
// Check for vertex-vertex collision
for(i=0; i<4 && !haveNodeNode; i++)
for(j=0; j<4 && !haveNodeNode; j++)
vCollisionPoint = vList1[i];
body1->vCollisionPoint = vCollisionPoint −
body2->vCollisionPoint = vCollisionPoint −
vCollisionNormal = body1->vPosition −
v1 = body1->vVelocityBody +
v2 = body2->vVelocityBody +
v1 = VRotate2D(body1->fOrientation, v1);
v2 = VRotate2D(body2->fOrientation, v2);
Search Nedrilad ::

Custom Search