alienizer at January 6th, 2014 19:45 — #1
For my airplane game, my drones are shooting some magical boxed towards the enemy planes. The boxes rotates in all directions as they approach an airplane. Once it hit an airplane, it should resize itself so the airplane fit inside the box and is them trapped. The problem is, the box is not axis aligned. Is there an algo somewhere that allow to fit a set of triangles in it and the box grows as you add triangles in it? like AABB does?
reedbeta at January 6th, 2014 21:35 — #2
Do you want to grow the box while maintaining a fixed orientation? If so, you can just transform the plane vertices into the box's coordinate system. The box is axis-aligned in its own coordinate system so you can treat it like an AABB and just take min/max of everything.
alienizer at January 6th, 2014 22:05 — #3
Yes, I want to grow it in whatever orientation it is. I'm not sure what you mean tho. An AABB doesn't have 8 points to define its bounding box (like a frustum do), an AABB only has a (float3) min and max. So I'm lost here Reed!!!
reedbeta at January 6th, 2014 23:26 — #4
They're still boxes, right? Set up a coordinate system that's aligned with the box, in whatever orientation it's in. Then the box is axis-aligned in that coordinate system, by definition. If you transform the vertices into that coordinate system, you can calculate the min and max. Then generate the 8 corners from the min and max, and transform them back into world coordinates.
alienizer at January 7th, 2014 00:41 — #5
oh I see, I get it. Thanks again Reed for your help.