This class represents an Axis-Aligned Bounding Box.
All operations provided for this box will maintain the axis-aligned property.
The validity of the axis-aligned bounding box can be verified with IsValid.
#include <scenetree/YiAABB.h>
Public Member Functions | |
| CYIAABB () | |
| CYIAABB (const glm::vec3 &rMinimumExtent, const glm::vec3 &rMaximumExtent) | |
| void | Enlarge (const CYIAABB &box) |
| glm::vec3 | GetCentroid () const |
| glm::vec3 | GetHalfDimensions () const |
| float | GetWidth () const |
| float | GetHeight () const |
| float | GetDepth () const |
| const glm::vec3 & | GetTopLeft () const |
| const glm::vec3 & | GetBottomRight () const |
| bool | Intersects (const CYIRay &rRay, glm::vec3 *pCollision=nullptr) const |
| bool | Intersects (const CYIAABB &rOther) const |
| void | SetCorners (const glm::vec3 &rMinimumExtent, const glm::vec3 &rMaximumExtent) |
| CYIAABB | Intersection (const CYIAABB &rOther) const |
| bool | IsValid () const |
| void | Transform (const glm::mat4 &transform) |
| bool | operator== (const CYIAABB &other) const |
| bool | operator!= (const CYIAABB &other) const |
| CYIAABB::CYIAABB | ( | ) |
Constructs a zero-sized bounding box. Such a bounding box is, by definition, invalid until it is enlarged using CYIAABB::Enlarge() or using CYIAABB::SetCorners().
| CYIAABB::CYIAABB | ( | const glm::vec3 & | rMinimumExtent, |
| const glm::vec3 & | rMaximumExtent | ||
| ) |
Constructs an AABB using the minimum extent rMinimumExtent (representing the top-left corner) and the maximum extent rMaximumExtent (representing the bottom-right corner).
The bounding box will axis align if the provided vectors are not valid.
| void CYIAABB::Enlarge | ( | const CYIAABB & | box | ) |
Enlarges the bounding box to encapsulate the provided box.
If box is already within the bounds of this bounding box, there will be no effect.
| const glm::vec3& CYIAABB::GetBottomRight | ( | ) | const |
Returns a point (x,y,z) representing the maximum extents of the bounding box on all three axes.
Any other point within the bounding box is guaranteed to be less than or equal to this point in one or more of the three dimensions.
| glm::vec3 CYIAABB::GetCentroid | ( | ) | const |
Returns a point (x,y,z) representing the center of the bounding box.
| float CYIAABB::GetDepth | ( | ) | const |
| glm::vec3 CYIAABB::GetHalfDimensions | ( | ) | const |
Returns a vector (x,y,z) representing half the width, height, and depth respectively.
| float CYIAABB::GetHeight | ( | ) | const |
| const glm::vec3& CYIAABB::GetTopLeft | ( | ) | const |
Returns a point (x,y,z) representing the minimum extents of the bounding box on all three axes.
Any other point within the bounding box is guaranteed to be greater than or equal to this point in one or more of the three dimensions.
| float CYIAABB::GetWidth | ( | ) | const |
Returns the intersection of rOther with this bounding box.
| bool CYIAABB::Intersects | ( | const CYIRay & | rRay, |
| glm::vec3 * | pCollision = nullptr |
||
| ) | const |
Given a rRay and a pointer to a vector pCollision, populates pCollision with the point of intersection between the ray and this bounding box.
The return value represents whether the collision point is within the bounding box.
| bool CYIAABB::Intersects | ( | const CYIAABB & | rOther | ) | const |
Returns true if the AABB rOther intersects with this one, false otherwise.
| bool CYIAABB::IsValid | ( | ) | const |
A bounding box is valid if all dimensions are greater than 0.
| bool CYIAABB::operator!= | ( | const CYIAABB & | other | ) | const |
| bool CYIAABB::operator== | ( | const CYIAABB & | other | ) | const |
| void CYIAABB::SetCorners | ( | const glm::vec3 & | rMinimumExtent, |
| const glm::vec3 & | rMaximumExtent | ||
| ) |
Sets corners of the object/box, here MinimumExtent refers to TopLeft corner and MaximumExtent refers to BottomRight corner.
The bounding box will axis align if the provided vectors are not valid.
| void CYIAABB::Transform | ( | const glm::mat4 & | transform | ) |
Transforms the bounding box by the given 3D transformation matrix, and axis aligns the result.