Non-world aligned bounding box

chucksspencer
Posts: 35
Joined: Wed Jun 25, 2008 2:52 pm

Non-world aligned bounding box

Post by chucksspencer »

I'd like to get a rough bounding box for any given shape in my scene. I'd like the bounding box aligned to the axes of that object's transformation rather than the world's axes. I'm trying the following:

Code: Select all

  btVector3 aabbMin;
  btVector3 aabbMax;
  btTransform bodyTrans = body->getWorldTransform();
  body->getCollisionShape()->getAabb(bodyTrans, aabbMin, aabbMax);
But that doesn't seem to generate any different result than

Code: Select all

   body->getAabb(abbMin, abbMax);
In either case the method returns bounds that seem to be in the world space rather than the object's local space.

What am I missing, here?

- Chuck
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Non-world aligned bounding box

Post by Erwin Coumans »

Use the identity transform, to compute the local space AABB:

Code: Select all

btVector3 aabbMin;
btVector3 aabbMax;
body->getCollisionShape()->getAabb(btTransform::getIdentity(), aabbMin, aabbMax);
This is the local AABB, in body space.
Once you convert this AABB into world space, you will likely get the same AABB as 'body->getAabb(abbMin, abbMax);'

Hope this helps,
Erwin
chucksspencer
Posts: 35
Joined: Wed Jun 25, 2008 2:52 pm

Re: Non-world aligned bounding box

Post by chucksspencer »

Erwin Coumans wrote:Use the identity transform, to compute the local space AABB:

Code: Select all

btVector3 aabbMin;
btVector3 aabbMax;
body->getCollisionShape()->getAabb(btTransform::getIdentity(), aabbMin, aabbMax);
This is the local AABB, in body space.
Once you convert this AABB into world space, you will likely get the same AABB as 'body->getAabb(abbMin, abbMax);'

Hope this helps,
Erwin
Ah of course. Now I see where I went wrong. Thanks again!