|
|
I'm working on some collision detection routines for a physics module I am
writing for POV. Right now I'm writing a coarse collision detection routine
that basicall finds the bounding box for the objects, and sees if the
bounding boxes are intersecting. ie.
#local bounding_box1 = phylib_get_bounding_box(obj1)
#local bounding_box2 = phylib_get_bounding_box(obj2)
#local overlap = intersection{ object{bounding_box1}
object{bounding_box2} }
When the boxes are overlaping, I get an object returned, otherwise there is
shouldn't be an object. How can I check if the variable 'overlap' actually
contains an object or not. If I find the bounding_box for the 'overlap'
object when the boxes don't intersect, I get a box with corners at:
<-10000000000.0, -10000000000.0, -10000000000.0> and <10000000000.0,
10000000000.0, 10000000000.0>, otherwise I get a much smaller bounding box.
Will this be true for all objects that don't intersect? Or is there another
way for me to check if the boxes are intersecting. I could always write a
my own macro that took in the bounding boxes and checked to see if they were
intersecting instead of relying on the object returned by the intersection.
Post a reply to this message
|
|
|
|
Wasn't it Andrew McKay who wrote:
>I'm working on some collision detection routines for a physics module I am
>writing for POV. Right now I'm writing a coarse collision detection routine
>that basicall finds the bounding box for the objects, and sees if the
>bounding boxes are intersecting. ie.
> #local bounding_box1 = phylib_get_bounding_box(obj1)
> #local bounding_box2 = phylib_get_bounding_box(obj2)
> #local overlap = intersection{ object{bounding_box1}
>object{bounding_box2} }
>
>When the boxes are overlaping, I get an object returned, otherwise there is
>shouldn't be an object. How can I check if the variable 'overlap' actually
>contains an object or not. If I find the bounding_box for the 'overlap'
>object when the boxes don't intersect, I get a box with corners at:
><-10000000000.0, -10000000000.0, -10000000000.0> and <10000000000.0,
>10000000000.0, 10000000000.0>, otherwise I get a much smaller bounding box.
>
>Will this be true for all objects that don't intersect? Or is there another
>way for me to check if the boxes are intersecting. I could always write a
>my own macro that took in the bounding boxes and checked to see if they were
>intersecting instead of relying on the object returned by the intersection.
To check for overlap of two bounding boxes you can do this:
#macro Collision(A,B)
(#if (min_extent(A).x <= max_extent(B).x
& min_extent(B).x <= max_extent(A).x
& min_extent(A).y <= max_extent(B).y
& min_extent(B).y <= max_extent(A).y
& min_extent(A).z <= max_extent(B).z
& min_extent(B).z <= max_extent(A).z)
1
#else
0
#end)
#end
--
Mike Williams
Gentleman of Leisure
Post a reply to this message
|
|