I have a model. I suround it by an AABB. The model may need to rotate. Rather than recompute the AABB (which would be slow), I'ld rather rotate the AABB with the model. My absolute rotation comes to me as a Quaternion. Here is my working algorithm. Is there a faster way?

My AABB is defined by a center and 3 extent variables (X extent Y extent Z extent). My AABB keeps track of its original center and original extents, but has a "using" center and "using" extent which it uses for culling purposes. They start off equal.

1) Convert Quaternion to a 3x3 rotation matrix2) Rotate the original center by this 3x3 rotation matrix. This is now my new "using" center.3) Make every value in the 3x3 matrix it's absolute value (IE if a value is -32 it becomes 32)4) Multiply this 3x3 matrix by my "original" X,Y,Z extent of the bounding box. This is now my new X/Y/Z extent.

This algorithm works correctly. I'm wondering if there is a faster way.

And to tell the truth - usually it's good enough (it was good enough for Quake3 for example). If you're standing diagonally to your opponent on the grid the hitable area is ~40% bigger than usual (a factor of sqrt(2)), but - as I already said - it doesn't really matter.

If it's not accurate enough you could check for AABB intersection first and in case of a collision you could perform a more accurate check.

By making your AABB non axially aligned your throwing away one of the biggest advantages of using them; dead simple intersection testing .

Quote

This algorithm works correctly. I'm wondering if there is a faster way.

Why? Even if you did this every frame for every (non-culled) object in the scene this code should never be a bottleneck in performance.

Like oNyx said; hierarchical bounding volumes would most closely approximate the principal of least cleverness. (ie check an oversize aabb first, then check bounding spheres or elipses or whatever that more closely approxmate the model.)

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org