Ocular Engine
|
#include <BoundsOBB.hpp>
Public Member Functions | |
BoundsOBB (Vector3f const ¢er, Vector3f const &extents, Vector3f const &xDir, Vector3f const &yDir, Vector3f const &zDir) | |
Vector3f const & | getCenter () const |
void | setCenter (Vector3f const ¢er) |
Vector3f const & | getExtents () const |
void | setExtents (Vector3f const &extents) |
Vector3f const & | getDirectionX () const |
void | setDirectionX (Vector3f const &dirX) |
Vector3f const & | getDirectionY () const |
void | setDirectionY (Vector3f const &dirY) |
Vector3f const & | getDirectionZ () const |
void | setDirectionZ (Vector3f const &dirZ) |
bool | intersects (Ray const &ray) const |
bool | intersects (BoundsSphere const &bounds) const |
bool | intersects (BoundsAABB const &bounds) const |
bool | intersects (BoundsOBB const &bounds) const |
bool | intersects (Plane const &plane, IntersectionType *result=nullptr) const |
Public Member Functions inherited from Ocular::Math::Bounds | |
BoundsType | getType () const |
bool | isVisible () const |
void | setVisible (bool visible) |
Additional Inherited Members | |
Protected Member Functions inherited from Ocular::Math::Bounds | |
Bounds (BoundsType const type) | |
Protected Attributes inherited from Ocular::Math::Bounds | |
bool | m_Visible |
BoundsType | m_Type |
Implementation of an Oriented Bounding Box.
Essentially an OBB is an AABB that can be arbitrarily rotated. They are more expensive to create and their intersection tests are more complicated, but have the benefit of not needing to be recalculated every time their contents are rotated.
Additionally, in most cases an OBB will also provide a tighter fit than an AABB.
Vector3f const & Ocular::Math::BoundsOBB::getCenter | ( | ) | const |
Returns the center of the bounding box.
Vector3f const & Ocular::Math::BoundsOBB::getDirectionX | ( | ) | const |
Returns the normalized direction of the x-axis of the bounding box.
Vector3f const & Ocular::Math::BoundsOBB::getDirectionY | ( | ) | const |
Returns the normalized direction of the y-axis of the bounding box.
Vector3f const & Ocular::Math::BoundsOBB::getDirectionZ | ( | ) | const |
Returns the normalized direction of the z-axis of the bounding box.
Vector3f const & Ocular::Math::BoundsOBB::getExtents | ( | ) | const |
Returns the positive half-lengths of the box. These are the distances along each local axis to the box edge.
bool Ocular::Math::BoundsOBB::intersects | ( | Ray const & | ray | ) | const |
Performs an intersection test on a ray and OBB.
[in] | ray |
bool Ocular::Math::BoundsOBB::intersects | ( | BoundsSphere const & | bounds | ) | const |
Performs an intersection test on a bounding sphere and OBB.
[in] | bounds |
bool Ocular::Math::BoundsOBB::intersects | ( | BoundsAABB const & | bounds | ) | const |
Performs an intersection test on a AABB and OBB.
[in] | bounds |
bool Ocular::Math::BoundsOBB::intersects | ( | BoundsOBB const & | bounds | ) | const |
Performs an intersection test on two OBBs.
[in] | bounds |
bool Ocular::Math::BoundsOBB::intersects | ( | Plane const & | plane, |
IntersectionType * | result = nullptr |
||
) | const |
Performs an intersection test on a plane and OBB.
If the result is Inside, then the OBB is located entirely within the plane's positive half space.
If the result is Outside, then the OBB is located entirely outside the plane's positive half space.
The positive half space of the plane is the direction that the plane is facing, as described by it's normal.
As an example, say we have the plane defined as:
Point: (0.0, 0.0, 0.0) Normal: (0.0, 1.0, 0.0)
The plane is 'facing up' along the world origin.
If the intersection test returns Outside, then the AABB is entirely in the +y world space.
If the intersection test returns Inside, then the AABB is entirely in the -y world space.
[in] | plane | |
[out] | result | Detailed intersection result. |
void Ocular::Math::BoundsOBB::setCenter | ( | Vector3f const & | center | ) |
/param[in] center
void Ocular::Math::BoundsOBB::setDirectionX | ( | Vector3f const & | dirX | ) |
/param[in] dirX
void Ocular::Math::BoundsOBB::setDirectionY | ( | Vector3f const & | dirY | ) |
/param[in] dirY
void Ocular::Math::BoundsOBB::setDirectionZ | ( | Vector3f const & | dirZ | ) |
/param[in] dirZ
void Ocular::Math::BoundsOBB::setExtents | ( | Vector3f const & | extents | ) |
/param[in] extents