[Closed] SDK bounding box for multiple nodes?
Trying to figure out the best way to create a bounding box (in world space) that encompasses multiple nodes. I know I can get the min/max values from the world bounding boxes of each node, then presumably I take the lowest and highest values for x/y/z respectively? But not entirely sure of the most efficient way to do that.
On a related note, please correct me if I’m wrong, but as far as I can tell, the SDK doesn’t support reading Point3 values as an array, so I would have to explicitly check for the x, y, and z values separately, yeah?
You could add your objects to a group and get bBox of the group head. Then ungroup the objects.
You can store an array of point3 in your pblock2 prams
get it something like this
Point3 face = pblock2->GetPoint3(Faces_Pos, t, FOREVER, FacesPos + j);
Okay, it turns out that the x/y/z values CAN be treated as an array, and all I needed was this:
Box3 bboxA, bboxB;
NodeA->EvalWorldState(0).obj->GetWorldBoundBox(0, NodeA, vpt, bboxA);
NodeB->EvalWorldState(0).obj->GetWorldBoundBox(0, NodeB, vpt, bboxB);
Point3 bbMin, bbMax;
for (int i=0; i<3; i++) {
bbMin[i] = ((bboxA.Min()[i]) < bboxB.Min()[i] ? bboxA.Min()[i] : bboxB.Min()[i]);
bbMax[i] = ((bboxA.Max()[i]) > bboxB.Max()[i] ? bboxA.Max()[i] : bboxB.Max()[i]);
}
Box3 bbox(bbMin, bbMax);
Okay, so next up:
What if instead of a world-space bounding box, I want the bounding box according to a particular matrix?
you can simply add one box3 to another.
from the help:
Box3& operator+= ( const Box3 & b )
Expands this Box3 to include the Box3 b. Parameters:const Box3& b
Specifies the Box3 to expand this box to include.
Thanks Denis, that is a much cleaner solution that what I was doing! I thought something like that might be possible but I didn’t know how to do it