API Documentation
Public Member Functions | List of all members
nkGraphics::BoundingBox Class Referencefinal

A bounding box. Often used to encompass object's bounds in the world. More...

Public Member Functions

 BoundingBox () noexcept
 
 BoundingBox (nkMemory::BufferView< const nkMaths::Vector > points) noexcept
 
 BoundingBox (const nkMaths::Vector &center, float cubeHalfSide) noexcept
 
 BoundingBox (const nkMaths::Vector &center, const nkMaths::Vector &axisAlignedHalfSides) noexcept
 
 ~BoundingBox ()
 
nkMemory::BufferView< const nkMaths::VectorgetPoints () const
 
nkMemory::BufferView< const nkMaths::VectorgetTransformedPoints () const
 
nkMaths::Vector getCenter () const
 
nkMaths::Vector getTransformedCenter () const
 
nkMaths::Vector getAxisAlignedSides () const
 
void setPoints (nkMemory::BufferView< const nkMaths::Vector > points)
 
void setTransformedPoints (nkMemory::BufferView< const nkMaths::Vector > points)
 
void updateTransformation (const nkMaths::Matrix &transform)
 
bool checkAgainst (const Frustum &frustum) const
 

Detailed Description

A bounding box. Often used to encompass object's bounds in the world.

Can be used to check against a frustum and do culling.

Constructor & Destructor Documentation

◆ BoundingBox() [1/4]

nkGraphics::BoundingBox::BoundingBox ( )
noexcept

Default constructor.

◆ BoundingBox() [2/4]

nkGraphics::BoundingBox::BoundingBox ( nkMemory::BufferView< const nkMaths::Vector points)
noexcept

Points constructor.

Parameters
pointsThe points forming the bounds, in no particular order.

◆ BoundingBox() [3/4]

nkGraphics::BoundingBox::BoundingBox ( const nkMaths::Vector center,
float  cubeHalfSide 
)
noexcept

Axis aligned constructor with a constant size on 3 axis.

Parameters
centerThe center of the box to create.
cubeHalfSideThe half extent, uniform along the 3 axis (x, y, z), used to form a cube.

◆ BoundingBox() [4/4]

nkGraphics::BoundingBox::BoundingBox ( const nkMaths::Vector center,
const nkMaths::Vector axisAlignedHalfSides 
)
noexcept

Axis aligned constructor with separated size on 3 axis.

Parameters
centerThe center of the box to create.
axisAlignedHalfSidesThe half extents, for each axis.

◆ ~BoundingBox()

nkGraphics::BoundingBox::~BoundingBox ( )

Destructor.

Member Function Documentation

◆ getPoints()

nkMemory::BufferView<const nkMaths::Vector> nkGraphics::BoundingBox::getPoints ( ) const
Returns
The 8 points forming the box, originally.

◆ getTransformedPoints()

nkMemory::BufferView<const nkMaths::Vector> nkGraphics::BoundingBox::getTransformedPoints ( ) const
Returns
The 8 points forming the box, once transformed by a node transformation.

◆ getCenter()

nkMaths::Vector nkGraphics::BoundingBox::getCenter ( ) const
Returns
The center of the box.

◆ getTransformedCenter()

nkMaths::Vector nkGraphics::BoundingBox::getTransformedCenter ( ) const
Returns
The center of the box, once transformed.

◆ getAxisAlignedSides()

nkMaths::Vector nkGraphics::BoundingBox::getAxisAlignedSides ( ) const
Returns
The half extent on the 3 axis of the box.

◆ setPoints()

void nkGraphics::BoundingBox::setPoints ( nkMemory::BufferView< const nkMaths::Vector points)

Sets new points to use for the box.

Parameters
pointsThe points to use.

◆ setTransformedPoints()

void nkGraphics::BoundingBox::setTransformedPoints ( nkMemory::BufferView< const nkMaths::Vector points)

Sets new transformed points to use for the box.

Parameters
pointsThe points to use.
Remarks
Beware that those points can be updated anytime by linked node transformation, if the bounds are attached to a SubEntity.

◆ updateTransformation()

void nkGraphics::BoundingBox::updateTransformation ( const nkMaths::Matrix transform)

Updates the transformed points with a transformation matrix.

Parameters
transformThe transformation matrix to use.

◆ checkAgainst()

bool nkGraphics::BoundingBox::checkAgainst ( const Frustum frustum) const

Checks the box against a frustum to know if it is inside or not.

Parameters
frustumThe frustum to check against.
Returns
If the box is inside the frustum (true) or not (false).

The documentation for this class was generated from the following file: