No, you can't. It seems like if you translate, rotate the object by certain amounts that you can do that to the bounding box as well and it will work....but it fails miserably. The bounding box ideally should change size to fit the new orientation and the only way to do this correctly is:
1. Translate, rotate, etc., the bounding box by the same values as the object.
2. Re-compute the bounding box based on the new position data.
If you don't recompute it is possible that the bounding box will be much larger or much smaller than the object after the transformation is done.
The only way to understand it is to try it. Create a square and create another square to act as an AABB. Rotate the square and rotate the AABB. Draw both of them - you will soon see what happens. The AABB is no longer an AABB and is now aligned with some other axes. If you want to maintain an AABB but just change its shape and size to fit the object's new orientation - you must recompute left,top,right, and bottom after each transformation.
This is not hard but none of this helps me.
Point I'm making here is that I do not have access to any vertex data. It's all internal to ID3DXSprite so I cannot compute any bounding box once it is translated because I cannot access the new vertex positions.
I can create an initial bounding box by retrieving the width and height from the surface description but that's about it. I guess I will have to store position data for the bounding box and use the D3DX math functions to transform the coords and then re-compute the box after the transformation.
Code:
struct fRECT
{
float left;
float top;
float right;
float bottom;
};
...
...
...
void CStaticSpriteContainer::Update(float _fTimeDelta)
{
...
fRECT tempRect;
tempRect.right=(float)AABB.left;
tempRect.left=(float)AABB.right;
tempRect.top=(float)AABB.bottom;
tempRect.bottom=(float)AABB.top;
for (int i=0;i<4;i++)
{
float x=Vertexes[i].x;
float y=Vertexes[i].y;
if (x<tempRect.left) tempRect.left=x;
if (y<tempRect.top) tempRect.top=y;
if (x>tempRect.right) tempRect.right=x;
if (y>tempRect.bottom) tempRect.bottom=y;
}
AABB=tempRect;
}