[Plib-users] ssgHOT question
Brought to you by:
sjbaker
From: McEvoy, N. <nic...@ds...> - 2002-01-18 03:04:50
|
Can anyone tell me why ssgHOT() returns different results depending on my camera position (ie. 1st person view and external view) ? In 1st person view I get the correct HOT, when I change to an external view the HOT is incorrect. I get 2 hits when in 1st view (looking out over my terrain) and 4 hits when in external view (looking at my player which is sitting just above the terrain). In the method below getHeightAndNormal() my_position is always the player pos (I'm not passing in the camera by mistake !) Note: the same problem happens with ssgIsect(). What am I missing here ??? Is it something to do with the scene matrix ... causing some difference within the ssgHOT() call ??? float getHeightAndNormal(ssgRoot* scene, sgVec3 my_position, sgVec3 normal) { /* Look for the nearest polygon *beneath* my_position */ ssgHit *results; int num_hits; float hot; /* H.O.T == Height Of Terrain */ sgVec3 HOTvec; sgMat4 invmat; sgMakeIdentMat4(invmat); invmat[3][0] = - my_position [0]; invmat[3][1] = - my_position [1]; invmat[3][2] = 0.0; sgSetVec3(HOTvec, 0.0f, 0.0f, HIGHEST_HEAVEN); num_hits = ssgHOT(scene, HOTvec, invmat, &results); hot = DEEPEST_HELL ; for (int i = 0; i < num_hits; i++) { ssgHit *h = &results[i]; float hgt = - h->plane[3] / h->plane[2]; if (hgt >= hot) { hot = hgt; if (normal != NULL) sgCopyVec3(normal, h->plane); } } return hot; } Nick http://members.ozemail.com.au/~ndmcevoy/ |