🔒 Locked
Bounding Boxes
Advertisement
Original Post
Mesh is an array ov Vertexes
now Min and Max define a Bounding Box
(edit) Stupid italics
[edited by - Ximmer on January 27, 2004 3:06:29 AM]
Vertex v;
Vertex Min;
Vertex Max;
Min = Mesh[0];
Max = Mesh[0];
for(j = 1; j < NumVerts; j++)
{
if(Mesh[j].x < Min.x) Min.x = Mesh[j].x;
if(Mesh[j].y < Min.y) Min.y = Mesh[j].y;
if(Mesh[j].z < Min.z) Min.z = Mesh[j].z;
if(Mesh[j].x > Max.x) Max.x = Mesh[j].x;
if(Mesh[j].y > Max.y) Max.y = Mesh[j].y;
if(Mesh[j].z > Max.z) Max.z = Mesh[j].z;
}
now Min and Max define a Bounding Box
(edit) Stupid italics
[edited by - Ximmer on January 27, 2004 3:06:29 AM]
don't worry about convex hulls
a simple box, defined by 2 points, is as simple as it gets. It's something you can use for simple collision detection.
and if you want, you can make boxes for sub parts of the model. The algorithm above builds a box around the list of vertices you supply, so you can supply anything, and it will build a box around it.
[edited by - oliii on January 27, 2004 6:49:26 AM]
a simple box, defined by 2 points, is as simple as it gets. It's something you can use for simple collision detection.
and if you want, you can make boxes for sub parts of the model. The algorithm above builds a box around the list of vertices you supply, so you can supply anything, and it will build a box around it.
[edited by - oliii on January 27, 2004 6:49:26 AM]
I''m not sure I understand the question 
there are only 2 kinds of bounding boxes I know of. Oriented and Axis Aligned (which is a special case of oriented bounding box).
to calculate bounding box distances, and (penetration depths as well), you can use the separation axis algorithm. Well, I never tried to use that algo for distances (when not intersecting), but I use it for interpenetrations, and at the same time calculating the contact points on both boxes.
there are only 2 kinds of bounding boxes I know of. Oriented and Axis Aligned (which is a special case of oriented bounding box).
to calculate bounding box distances, and (penetration depths as well), you can use the separation axis algorithm. Well, I never tried to use that algo for distances (when not intersecting), but I use it for interpenetrations, and at the same time calculating the contact points on both boxes.
an algo for distance calculations is the GJK algorithm. It apply for any convex shape.
and as far as bounding objects go, the tightest convex shape (I think) you can wrap around an object is a convex hull. And even then, there is a lot of space wasted in some occasions. And building a convex hull is not that simple.
you can also try using a simple and very coarse octree, and finding approximations of the distance using the octree.
and as far as bounding objects go, the tightest convex shape (I think) you can wrap around an object is a convex hull. And even then, there is a lot of space wasted in some occasions. And building a convex hull is not that simple.
you can also try using a simple and very coarse octree, and finding approximations of the distance using the octree.
How do you recalculate the bounding box if the object rotates?
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement