Archived

This topic is now archived and is closed to further replies.

flashlaser

BBox rotation

Recommended Posts

For my collision detection I worked out four vertices around my car using the D3DXComputeBoundingBox() function form the D3DX library. Now I want to rotate and translate the vertices so they are always the tightest fit around the car. Basically its a OBB. Any ideas on how to do this. I could cos/sin or use some matrix stuff but I need more info.

Share this post


Link to post
Share on other sites
One more question.

How would I work out if a bounding box hit a triangle plane or triangle and also work out the intersection point.

Ok no more questions.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
if you really want to rotate rectangle (change coordinates of points):
for rotate you must define center for your rectangle in point 0,0. for example your rectangle:

--------x 10,10
| |
| 0,0 |
| |
x--------
-10,-10

and rotation:

...
float fWorkAngleCos, fWorkAngleSin, fWorkAngleMinusSin, nx, nz, negVecRx;

negVecRx=-vecR.x;
fWorkAngleCos=cos(negVecRx);
fWorkAngleSin=sin(negVecRx);
fWorkAngleMinusSin=-sin(negVecRx);

//-- for first point ---
nx=ObjectRectangle[i*4].x;
nz=ObjectRectangle[i*4].z;
ObjectRectangle[i*4].x=nx*fWorkAngleCos+nz*fWorkAngleSin;
ObjectRectangle[i*4].z=nx*fWorkAngleMinusSin+nz*fWorkAngleCos;

//-- for second ---
...
and so on for last three points.

Share this post


Link to post
Share on other sites