Nazara Engine  0.4
A fast, complete, cross-platform API designed for game development
Nz::BoundingVolume< T > Class Template Reference

Math class that represents a bounding volume, a combination of a box and an oriented box. More...

Public Member Functions

 BoundingVolume ()
 Constructs a BoundingVolume object by default. More...
 
 BoundingVolume (Extend Extend)
 Constructs a BoundingVolume object from Extend. More...
 
 BoundingVolume (T X, T Y, T Z, T Width, T Height, T Depth)
 Constructs a BoundingVolume object from its position and sizes. More...
 
 BoundingVolume (const Box< T > &box)
 Constructs a BoundingVolume object from a box. More...
 
 BoundingVolume (const OrientedBox< T > &orientedBox)
 Constructs a BoundingVolume object from an oriented box. More...
 
 BoundingVolume (const Vector3< T > &vec1, const Vector3< T > &vec2)
 Constructs a BoundingVolume object from two vectors representing point of the space (X, Y, Z) will be the components minimum of the two vectors and the (width, height, depth) will be the components maximum - minimum. More...
 
template<typename U >
 BoundingVolume (const BoundingVolume< U > &volume)
 Constructs a BoundingVolume object from another type of BoundingVolume. More...
 
 BoundingVolume (const BoundingVolume &volume)=default
 
BoundingVolumeExtendTo (const BoundingVolume &volume)
 Extends the bounding volume to contain another bounding volume. More...
 
bool IsFinite () const
 Checks whether the volume is finite. More...
 
bool IsInfinite () const
 Checks whether the volume is infinite. More...
 
bool IsNull () const
 Checks whether the volume is null. More...
 
BoundingVolumeMakeInfinite ()
 Makes the bounding volume infinite. More...
 
BoundingVolumeMakeNull ()
 Makes the bounding volume null. More...
 
BoundingVolumeSet (Extend Extend)
 Sets the extend of the bounding volume from Extend. More...
 
BoundingVolumeSet (T X, T Y, T Z, T Width, T Height, T Depth)
 Sets the components of the bounding volume. More...
 
BoundingVolumeSet (const BoundingVolume< T > &volume)
 Sets the components of the bounding volume from another bounding volume. More...
 
BoundingVolumeSet (const Box< T > &box)
 Sets the components of the bounding volume from a box. More...
 
BoundingVolumeSet (const OrientedBox< T > &orientedBox)
 Sets the components of the bounding volume from an oriented box. More...
 
BoundingVolumeSet (const Vector3< T > &vec1, const Vector3< T > &vec2)
 Sets a BoundingVolume object from two vectors representing point of the space (X, Y, Z) will be the components minimum of the two vectors and the (width, height, depth) will be the components maximum - minimum. More...
 
template<typename U >
BoundingVolumeSet (const BoundingVolume< U > &volume)
 
String ToString () const
 Gives a string representation. More...
 
void Update (const Matrix4< T > &transformMatrix)
 Updates the obb and the aabb of the bounding volume. More...
 
void Update (const Vector3< T > &translation)
 Updates the obb and the aabb of the bounding volume. More...
 
BoundingVolume operator* (T scalar) const
 Multiplies the lengths of the obb with the scalar. More...
 
BoundingVolumeoperator= (const BoundingVolume &other)=default
 
BoundingVolumeoperator*= (T scalar)
 Multiplies the lengths of this bounding volume with the scalar. More...
 
bool operator== (const BoundingVolume &volume) const
 Compares the bounding volume to other one. More...
 
bool operator!= (const BoundingVolume &volume) const
 Compares the bounding volume to other one. More...
 
template<typename U >
BoundingVolume< T > & Set (const BoundingVolume< U > &volume)
 Sets the components of the bounding volume from another type of BoundingVolume. More...
 

Static Public Member Functions

static BoundingVolume Infinite ()
 Shorthand for the bounding volume (Extend_Infinite) More...
 
static BoundingVolume Lerp (const BoundingVolume &from, const BoundingVolume &to, T interpolation)
 Interpolates the bounding volume to other one with a factor of interpolation. More...
 
static BoundingVolume Null ()
 Shorthand for the bounding volume (Extend_Null) More...
 

Public Attributes

Extend extend
 
Box< T > aabb
 
OrientedBox< T > obb
 

Detailed Description

template<typename T>
class Nz::BoundingVolume< T >

Math class that represents a bounding volume, a combination of a box and an oriented box.

Remarks
You need to call Update not to have undefined behaviour

Constructor & Destructor Documentation

◆ BoundingVolume() [1/7]

template<typename T >
Nz::BoundingVolume< T >::BoundingVolume ( )

Constructs a BoundingVolume object by default.

Remarks
extend is set to Extend_Null, aabb and obb are uninitialized

◆ BoundingVolume() [2/7]

template<typename T >
Nz::BoundingVolume< T >::BoundingVolume ( Extend  Extend)

Constructs a BoundingVolume object from Extend.

Parameters
ExtendExtend of the volume part of enumeration Extend
Remarks
Aabb and obb are uninitialized

◆ BoundingVolume() [3/7]

template<typename T>
Nz::BoundingVolume< T >::BoundingVolume ( X,
Y,
Z,
Width,
Height,
Depth 
)

Constructs a BoundingVolume object from its position and sizes.

Parameters
XX component of position
YY component of position
ZZ component of position
WidthWidth of the box (following X)
HeightHeight of the box (following Y)
DepthDepth of the box (following Z)
Remarks
Aabb is uninitialized

◆ BoundingVolume() [4/7]

template<typename T>
Nz::BoundingVolume< T >::BoundingVolume ( const Box< T > &  box)

Constructs a BoundingVolume object from a box.

Parameters
boxBox<T> object
Remarks
Aabb is uninitialized

◆ BoundingVolume() [5/7]

template<typename T>
Nz::BoundingVolume< T >::BoundingVolume ( const OrientedBox< T > &  orientedBox)

Constructs a BoundingVolume object from an oriented box.

Parameters
orientedBoxOrientedBox<T> object
Remarks
Aabb is uninitialized

◆ BoundingVolume() [6/7]

template<typename T>
Nz::BoundingVolume< T >::BoundingVolume ( const Vector3< T > &  vec1,
const Vector3< T > &  vec2 
)

Constructs a BoundingVolume object from two vectors representing point of the space (X, Y, Z) will be the components minimum of the two vectors and the (width, height, depth) will be the components maximum - minimum.

Parameters
vec1First point
vec2Second point
Remarks
Aabb is uninitialized

◆ BoundingVolume() [7/7]

template<typename T >
template<typename U >
Nz::BoundingVolume< T >::BoundingVolume ( const BoundingVolume< U > &  volume)
explicit

Constructs a BoundingVolume object from another type of BoundingVolume.

Parameters
volumeBoundingVolume of type U to convert to type T

Member Function Documentation

◆ ExtendTo()

template<typename T >
BoundingVolume< T > & Nz::BoundingVolume< T >::ExtendTo ( const BoundingVolume< T > &  volume)

Extends the bounding volume to contain another bounding volume.

Returns
A reference to the the bounding volume
Parameters
volumeOther volume to contain
Remarks
Extending to a null bounding volume has no effect while extending to a infinite bounding volume will set it as infinite

◆ Infinite()

template<typename T >
BoundingVolume< T > Nz::BoundingVolume< T >::Infinite ( )
static

Shorthand for the bounding volume (Extend_Infinite)

Returns
A bounding volume with Extend_Infinite
See also
MakeInfinite

◆ IsFinite()

template<typename T >
bool Nz::BoundingVolume< T >::IsFinite ( ) const

Checks whether the volume is finite.

Returns
true if extend is Extend_Finite

◆ IsInfinite()

template<typename T >
bool Nz::BoundingVolume< T >::IsInfinite ( ) const

Checks whether the volume is infinite.

Returns
true if extend is Extend_Infinite

◆ IsNull()

template<typename T >
bool Nz::BoundingVolume< T >::IsNull ( ) const

Checks whether the volume is null.

Returns
true if extend is Extend_Null

◆ Lerp()

template<typename T>
BoundingVolume< T > Nz::BoundingVolume< T >::Lerp ( const BoundingVolume< T > &  from,
const BoundingVolume< T > &  to,
interpolation 
)
static

Interpolates the bounding volume to other one with a factor of interpolation.

Returns
A new bounding volume box which is the interpolation of two bounding volumes
Parameters
fromInitial bounding volume
toTarget bounding volume
interpolationFactor of interpolation
Remarks
interpolation is meant to be between 0 and 1, other values are potentially undefined behavior
With NAZARA_DEBUG, a NazaraError is thrown and Null() is returned
If enumeration is not defined in Extend, a NazaraError is thrown and Null() is returned
See also
Lerp

◆ MakeInfinite()

template<typename T >
BoundingVolume< T > & Nz::BoundingVolume< T >::MakeInfinite ( )

Makes the bounding volume infinite.

Returns
A reference to this bounding volume with Extend_Infinite for extend
See also
Infinite

◆ MakeNull()

template<typename T >
BoundingVolume< T > & Nz::BoundingVolume< T >::MakeNull ( )

Makes the bounding volume null.

Returns
A reference to this bounding volume with Extend_Null for extend
See also
Null

◆ Null()

template<typename T >
BoundingVolume< T > Nz::BoundingVolume< T >::Null ( )
static

Shorthand for the bounding volume (Extend_Null)

Returns
A bounding volume with Extend_Null
See also
MakeNull

◆ operator!=()

template<typename T >
bool Nz::BoundingVolume< T >::operator!= ( const BoundingVolume< T > &  volume) const

Compares the bounding volume to other one.

Returns
false if the two bounding volumes are the same
Parameters
volumeOther bounding volume to compare with

◆ operator*()

template<typename T>
BoundingVolume< T > Nz::BoundingVolume< T >::operator* ( scalar) const

Multiplies the lengths of the obb with the scalar.

Returns
A BoundingVolume where the position is the same and width, height and depth are the product of the old width, height and depth and the scalar
Parameters
scaleThe scalar to multiply width, height and depth with

◆ operator*=()

template<typename T>
BoundingVolume< T > & Nz::BoundingVolume< T >::operator*= ( scalar)

Multiplies the lengths of this bounding volume with the scalar.

Returns
A reference to this bounding volume where lengths are the product of these lengths and the scalar
Parameters
scalarThe scalar to multiply width, height and depth with

◆ operator==()

template<typename T >
bool Nz::BoundingVolume< T >::operator== ( const BoundingVolume< T > &  volume) const

Compares the bounding volume to other one.

Returns
true if the two bounding volumes are the same
Parameters
volumeOther bounding volume to compare with

◆ Set() [1/7]

template<typename T >
BoundingVolume< T > & Nz::BoundingVolume< T >::Set ( Extend  Extend)

Sets the extend of the bounding volume from Extend.

Returns
A reference to this bounding volume
Parameters
ExtendNew extend
Remarks
This method is meant to be called with Extend_Infinite or Extend_Null

◆ Set() [2/7]

template<typename T>
BoundingVolume< T > & Nz::BoundingVolume< T >::Set ( X,
Y,
Z,
Width,
Height,
Depth 
)

Sets the components of the bounding volume.

Returns
A reference to this bounding volume
Parameters
XX position
YY position
ZZ position
WidthWidth of the oriented box (following X)
HeightHeight of the oriented box (following Y)
DepthDepth of the oriented box (following Z)

◆ Set() [3/7]

template<typename T>
BoundingVolume< T > & Nz::BoundingVolume< T >::Set ( const BoundingVolume< T > &  volume)

Sets the components of the bounding volume from another bounding volume.

Returns
A reference to this bounding volume
Parameters
volumeThe other bounding volume

◆ Set() [4/7]

template<typename T>
BoundingVolume< T > & Nz::BoundingVolume< T >::Set ( const Box< T > &  box)

Sets the components of the bounding volume from a box.

Returns
A reference to this bounding volume
Parameters
boxBox<T> object

◆ Set() [5/7]

template<typename T>
BoundingVolume< T > & Nz::BoundingVolume< T >::Set ( const OrientedBox< T > &  orientedBox)

Sets the components of the bounding volume from an oriented box.

Returns
A reference to this bounding volume
Parameters
orientedBoxOrientedBox<T> object

◆ Set() [6/7]

template<typename T>
BoundingVolume< T > & Nz::BoundingVolume< T >::Set ( const Vector3< T > &  vec1,
const Vector3< T > &  vec2 
)

Sets a BoundingVolume object from two vectors representing point of the space (X, Y, Z) will be the components minimum of the two vectors and the (width, height, depth) will be the components maximum - minimum.

Parameters
vec1First point
vec2Second point

◆ Set() [7/7]

template<typename T>
template<typename U >
BoundingVolume<T>& Nz::BoundingVolume< T >::Set ( const BoundingVolume< U > &  volume)

Sets the components of the bounding volume from another type of BoundingVolume.

Returns
A reference to this bounding volume
Parameters
volumeBoundingVolume of type U to convert its components

◆ ToString()

template<typename T >
String Nz::BoundingVolume< T >::ToString ( ) const

Gives a string representation.

Returns
A string representation of the object: "BoundingVolume(localBox="")" if finite, or "BoundingVolume(Infinite)" or "BoundingVolume(Null)"
Remarks
If enumeration is not defined in Extend, a NazaraError is thrown and "BoundingVolume(ERROR)" is returned

◆ Update() [1/2]

template<typename T>
void Nz::BoundingVolume< T >::Update ( const Matrix4< T > &  transformMatrix)

Updates the obb and the aabb of the bounding volume.

Parameters
transformMatrixMatrix4 which represents the transformation to apply

◆ Update() [2/2]

template<typename T>
void Nz::BoundingVolume< T >::Update ( const Vector3< T > &  translation)

Updates the obb and the aabb of the bounding volume.

Parameters
translationVector3 which represents the translation to apply

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