Archived

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

chris1234

collision detection w. modified boundingbox

Recommended Posts

Hi, I''m making a 2D game in Directx8 which uses textured rectangles as ''sprites'' but the rectangles rotate so I can''t use plain bounding box collision detection...i think...I thought of the idea of re-computing a bounding box in which the rotated rectangle will fit, but then I''ll often end up with an much to big collision box, so I wondered if anyone else had any suggestion of how to do this? or if anyone knows of an article about a subject like this? Chris

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
If I understand the problem correctly I had a similar problem.

original vesoljc:
if I got this right, what happens when you transform the bounding
box(the corners that is), it is no longer a square

**********
* * then becomes *
* * * *
* * * *
* * * *
********** * *
*
bounding box algorithms work on squares by making four
comparisons, it falls apart when it is no longer a rectangle.

There''s a couple of articles on gamedev.net about pixel-perfect
collision detection.
What you should probably do is go ahead and compute a larger
than necessary bounding box since they are the fastest thing I
know of, and if it''s within the bounding box, then you do the
pixel-perfect stuff cause it''s slower.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I didn''t put the ascii diagram in between the code flags so
it didn''t turn out right, anyways, the rectangle becomes
a parallelogram(diamond-shaped for those who haven''t been in
geometry class for a while).

Share this post


Link to post
Share on other sites
There are 2 types of boxes. Axis aligned bounding box and "generic" bounding box.

The axis aligned cannot be rotated, they must always fit axis, but the generic bounding boxes can be rotated at will.
Obviously, they do not use the same algorithm!

Share this post


Link to post
Share on other sites