Jump to content
  • Advertisement

Archived

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

flashlaser

BBox rotation

This topic is 6059 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!