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

Math class that represents a frustum in the three dimensional vector space. More...

Public Member Functions

template<typename U >
 Frustum (const Frustum< U > &frustum)
 Constructs a Frustum object from another type of Frustum. More...
 
 Frustum (const Frustum &frustum)=default
 
FrustumBuild (T angle, T ratio, T zNear, T zFar, const Vector3< T > &eye, const Vector3< T > &target, const Vector3< T > &up=Vector3< T >::Up())
 Builds the frustum object. More...
 
bool Contains (const BoundingVolume< T > &volume) const
 Checks whether or not a bounding volume is contained in the frustum. More...
 
bool Contains (const Box< T > &box) const
 Checks whether or not a box is contained in the frustum. More...
 
bool Contains (const OrientedBox< T > &orientedBox) const
 Checks whether or not an oriented box is contained in the frustum. More...
 
bool Contains (const Sphere< T > &sphere) const
 Checks whether or not a sphere is contained in the frustum. More...
 
bool Contains (const Vector3< T > &point) const
 Checks whether or not a Vector3 is contained in the frustum. More...
 
bool Contains (const Vector3< T > *points, unsigned int pointCount) const
 Checks whether or not a set of Vector3 is contained in the frustum. More...
 
FrustumExtract (const Matrix4< T > &clipMatrix)
 Constructs the frustum from a Matrix4. More...
 
FrustumExtract (const Matrix4< T > &view, const Matrix4< T > &projection)
 Constructs the frustum from the view matrix and the projection matrix. More...
 
const Vector3< T > & GetCorner (BoxCorner corner) const
 Gets the Vector3 for the corner. More...
 
const Plane< T > & GetPlane (FrustumPlane plane) const
 Gets the Plane for the face. More...
 
IntersectionSide Intersect (const BoundingVolume< T > &volume) const
 Checks whether or not a bounding volume intersects with the frustum. More...
 
IntersectionSide Intersect (const Box< T > &box) const
 Checks whether or not a box intersects with the frustum. More...
 
IntersectionSide Intersect (const OrientedBox< T > &orientedBox) const
 Checks whether or not an oriented box intersects with the frustum. More...
 
IntersectionSide Intersect (const Sphere< T > &sphere) const
 Checks whether or not a sphere intersects with the frustum. More...
 
IntersectionSide Intersect (const Vector3< T > *points, unsigned int pointCount) const
 Checks whether or not a set of Vector3 intersects with the frustum. More...
 
Frustumoperator= (const Frustum &other)=default
 
FrustumSet (const Frustum &frustum)
 Sets the components of the frustum from another frustum. More...
 
template<typename U >
FrustumSet (const Frustum< U > &frustum)
 
String ToString () const
 Gives a string representation. More...
 
template<typename U >
Frustum< T > & Set (const Frustum< U > &frustum)
 Sets the components of the frustum from another type of Frustum. More...
 

Friends

template<typename U >
bool Serialize (SerializationContext &context, const Frustum< U > &frustum)
 
template<typename U >
bool Unserialize (SerializationContext &context, Frustum< U > *frustum)
 

Detailed Description

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

Math class that represents a frustum in the three dimensional vector space.

Frustums are used to determine what is inside the camera's field of view. They help speed up the rendering process

Constructor & Destructor Documentation

◆ Frustum()

template<typename T >
template<typename U >
Nz::Frustum< T >::Frustum ( const Frustum< U > &  frustum)
explicit

Constructs a Frustum object from another type of Frustum.

Parameters
frustumFrustum of type U to convert to type T

Member Function Documentation

◆ Build()

template<typename T >
Frustum< T > & Nz::Frustum< T >::Build ( angle,
ratio,
zNear,
zFar,
const Vector3< T > &  eye,
const Vector3< T > &  target,
const Vector3< T > &  up = Vector3<T>::Up() 
)

Builds the frustum object.

Returns
A reference to this frustum which is the build up camera's field of view
Parameters
angleUnit depends on NAZARA_MATH_ANGLE_RADIAN
ratioRendering ratio (typically 16/9 or 4/3)
zNearDistance where 'vision' begins
zFarDistance where 'vision' ends
eyePosition of the camera
targetPosition of the target of the camera
upDirection of up vector according to the orientation of camera

◆ Contains() [1/6]

template<typename T >
bool Nz::Frustum< T >::Contains ( const BoundingVolume< T > &  volume) const

Checks whether or not a bounding volume is contained in the frustum.

Returns
true if the bounding volume is entirely in the frustum
Parameters
volumeVolume to check
Remarks
If volume is infinite, true is returned
If volume is null, false is returned
If enumeration of the volume is not defined in Extend, a NazaraError is thrown and false is returned
If enumeration of the intersection is not defined in IntersectionSide, a NazaraError is thrown and false is returned. This should not never happen for a user of the library

◆ Contains() [2/6]

template<typename T >
bool Nz::Frustum< T >::Contains ( const Box< T > &  box) const

Checks whether or not a box is contained in the frustum.

Returns
true if the box is entirely in the frustum
Parameters
boxBox to check

◆ Contains() [3/6]

template<typename T >
bool Nz::Frustum< T >::Contains ( const OrientedBox< T > &  orientedbox) const

Checks whether or not an oriented box is contained in the frustum.

Returns
true if the oriented box is entirely in the frustum
Parameters
orientedboxOriented box to check

◆ Contains() [4/6]

template<typename T >
bool Nz::Frustum< T >::Contains ( const Sphere< T > &  sphere) const

Checks whether or not a sphere is contained in the frustum.

Returns
true if the sphere is entirely in the frustum
Parameters
sphereSphere to check

◆ Contains() [5/6]

template<typename T >
bool Nz::Frustum< T >::Contains ( const Vector3< T > &  point) const

Checks whether or not a Vector3 is contained in the frustum.

Returns
true if the Vector3 is in the frustum
Parameters
pointVector3 which represents a point in the space

◆ Contains() [6/6]

template<typename T >
bool Nz::Frustum< T >::Contains ( const Vector3< T > *  points,
unsigned int  pointCount 
) const

Checks whether or not a set of Vector3 is contained in the frustum.

Returns
true if the set of Vector3 is in the frustum
Parameters
pointsPointer to Vector3 which represents a set of points in the space
pointCountNumber of points to check

◆ Extract() [1/2]

template<typename T >
Frustum< T > & Nz::Frustum< T >::Extract ( const Matrix4< T > &  clipMatrix)

Constructs the frustum from a Matrix4.

Returns
A reference to this frustum which is the build up of projective matrix
Parameters
clipMatrixMatrix which represents the transformation of the frustum
Remarks
A NazaraWarning is produced if clipMatrix is not inversible and corners are unchanged

◆ Extract() [2/2]

template<typename T >
Frustum< T > & Nz::Frustum< T >::Extract ( const Matrix4< T > &  view,
const Matrix4< T > &  projection 
)

Constructs the frustum from the view matrix and the projection matrix.

Returns
A reference to this frustum which is the build up of projective matrix
Parameters
viewMatrix which represents the view
projectionMatrix which represents the projection (the perspective)
Remarks
A NazaraWarning is produced if the product of these matrices is not inversible and corners are unchanged

◆ GetCorner()

template<typename T >
const Vector3< T > & Nz::Frustum< T >::GetCorner ( BoxCorner  corner) const

Gets the Vector3 for the corner.

Returns
The position of the corner of the frustum according to enum BoxCorner
Parameters
cornerEnumeration of type BoxCorner
Remarks
If enumeration is not defined in BoxCorner and NAZARA_DEBUG defined, a NazaraError is thrown and a Vector3 uninitialised is returned

◆ GetPlane()

template<typename T >
const Plane< T > & Nz::Frustum< T >::GetPlane ( FrustumPlane  plane) const

Gets the Plane for the face.

Returns
The face of the frustum according to enum FrustumPlane
Parameters
planeEnumeration of type FrustumPlane
Remarks
If enumeration is not defined in FrustumPlane and NAZARA_DEBUG defined, a NazaraError is thrown and a Plane uninitialised is returned

◆ Intersect() [1/5]

template<typename T >
IntersectionSide Nz::Frustum< T >::Intersect ( const BoundingVolume< T > &  volume) const

Checks whether or not a bounding volume intersects with the frustum.

Returns
IntersectionSide How the bounding volume is intersecting with the frustum
Parameters
volumeVolume to check
Remarks
If volume is infinite, IntersectionSide_Intersecting is returned
If volume is null, IntersectionSide_Outside is returned
If enumeration of the volume is not defined in Extend, a NazaraError is thrown and IntersectionSide_Outside is returned
If enumeration of the intersection is not defined in IntersectionSide, a NazaraError is thrown and IntersectionSide_Outside is returned. This should not never happen for a user of the library

◆ Intersect() [2/5]

template<typename T >
IntersectionSide Nz::Frustum< T >::Intersect ( const Box< T > &  box) const

Checks whether or not a box intersects with the frustum.

Returns
IntersectionSide How the box is intersecting with the frustum
Parameters
boxBox to check

◆ Intersect() [3/5]

template<typename T >
IntersectionSide Nz::Frustum< T >::Intersect ( const OrientedBox< T > &  orientedbox) const

Checks whether or not an oriented box intersects with the frustum.

Returns
IntersectionSide How the oriented box is intersecting with the frustum
Parameters
orientedbox OrientedBox to check

◆ Intersect() [4/5]

template<typename T >
IntersectionSide Nz::Frustum< T >::Intersect ( const Sphere< T > &  sphere) const

Checks whether or not a sphere intersects with the frustum.

Returns
IntersectionSide How the sphere is intersecting with the frustum
Parameters
sphereSphere to check

◆ Intersect() [5/5]

template<typename T >
IntersectionSide Nz::Frustum< T >::Intersect ( const Vector3< T > *  points,
unsigned int  pointCount 
) const

Checks whether or not a set of Vector3 intersects with the frustum.

Returns
IntersectionSide How the set of Vector3 is intersecting with the frustum
Parameters
pointsPointer to Vector3 which represents a set of points in the space
pointCountNumber of points to check

◆ Set() [1/2]

template<typename T >
Frustum< T > & Nz::Frustum< T >::Set ( const Frustum< T > &  frustum)

Sets the components of the frustum from another frustum.

Returns
A reference to this frustum
Parameters
frustumThe other frustum

◆ Set() [2/2]

template<typename T>
template<typename U >
Frustum<T>& Nz::Frustum< T >::Set ( const Frustum< U > &  frustum)

Sets the components of the frustum from another type of Frustum.

Returns
A reference to this frustum
Parameters
frustumFrustum of type U to convert its components

◆ ToString()

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

Gives a string representation.

Returns
A string representation of the object: "Frustum(Plane ...)"

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