[Plib-users] RE: ssgIsect question ... whack ... answered ???
Brought to you by:
sjbaker
|
From: McEvoy, N. <nic...@ds...> - 2002-01-23 23:50:23
|
Sorry I just had another head slapping moment !!! :-)
I think I have solved my ssgIsect problem (but I have been known to be
wrong).
If I comment out the part where I set the inverse matrix (invmat) to my
player position and change the sphere to be my player position then the
returned ssgHit plane (h->plane) equation is correct !!!! And my ODE
physics engine works fantastic ... my sphere tumbles down the mountain side,
coming to a rest at the bottom (before it bounced off the screen).
sgMat4 invmat;
sgMakeIdentMat4(invmat);
sgSphere sphere;
//invmat[3][0] = -player_pos[SG_X];
//invmat[3][1] = -player_pos[SG_Y];
//invmat[3][2] = -player_pos[SG_Z];
//sphere.setCenter(0.0, 0.0, 0.0);
sphere.setCenter(player_pos[SG_X], player_pos[SG_Y], player_pos[SG_Z]);
sphere.setRadius(10.0);
ssgHit *results ;
int num_hits = ssgIsect(&mWorld, &sphere, invmat, &results);
for (int i = 0; i < num_hits; i++)
{
ssgHit *h = &results[i];
printf("pos <%.1f:%.1f:%.1f> plane <%.1f:%.1f:%.1f:%.1f>\n",
player_pos[0], player_pos[1], player_pos[2],
h->plane[0], h->plane[1], h->plane[2], h->plane[3]);
}
Is the PLIB documentation misleading on the use of ssgIsect where it states:
"In each case, the search for a collision starts at 'root', and the database
is transformed by the matrix 'm' before the test is evaluated - hence, 'm'
is usually the inverse of the matrix describing the test object's location."
In my case 'm' was not "the inverse matrix describing the test object's
location", 'm' was the identity matrix and the sphere described the test
object's location.
Any comments ?
Nick
http://members.ozemail.com.au/~ndmcevoy/
|