Direct-BT v3.3.0-1-gc2d430c
Direct-BT - Direct Bluetooth Programming.
Classes | Public Types | Public Member Functions | Static Public Attributes | List of all members
jau::math::geom::Frustum Class Reference

Providing frustum planes derived by different inputs (P*MV, ..) used to classify objects. More...

#include <frustum.hpp>

Collaboration diagram for jau::math::geom::Frustum:

Classes

class  FovDesc
 Frustum description by fovhv and zNear, zFar. More...
 
class  Plane
 Plane equation := dot(n, x - p) = 0 -> Ax + By + Cz + d == 0. More...
 

Public Types

enum class  location_t { OUTSIDE , INSIDE , INTERSECT }
 

Public Member Functions

constexpr Frustum () noexcept=default
 Creates an undefined instance w/o calculating the frustum. More...
 
constexpr Frustum (const Frustum &o) noexcept=default
 
constexpr Frustum (Frustum &&o) noexcept=default
 
location_t classifyPoint (const Vec3f &p) const noexcept
 Classifies the given Vec3f point whether it is outside, inside or on a plane of this frustum. More...
 
location_t classifySphere (const Vec3f &p, const float radius) const noexcept
 Classifies the given sphere whether it is is outside, intersecting or inside of this frustum. More...
 
constexpr PlanegetPlanes () noexcept
 Planes are ordered in the returned array as follows: More...
 
constexpr void getPlanes (float out[]) const noexcept
 Sets the given [float[off]..float[off+4*6]) out to ( n, d ). More...
 
constexpr jau::math::Vec4fgetPlanes (jau::math::Vec4f out[]) const noexcept
 Sets each of the given Vec4f[6] out to Plane#toVec4f(Vec4f) in the order LEFT, RIGHT, BOTTOM, TOP, NEAR, FAR. More...
 
bool isOutside (const AABBox3f &&box) const noexcept
 Returns whether the given AABBox is completely outside of this frustum. More...
 
bool isOutside (const Vec3f &p) const noexcept
 Returns whether the given Vec3f point is completely outside of this frustum. More...
 
bool isSphereOutside (const Vec3f &p, const float radius) const noexcept
 Returns whether the given sphere is completely outside of this frustum. More...
 
constexpr Frustumoperator= (const Frustum &) noexcept=default
 
constexpr Frustumoperator= (Frustum &&) noexcept=default
 
FrustumsetFromMat (const jau::math::Mat4f &m) noexcept
 Calculate the frustum planes in world coordinates using the given column major order matrix, usually a projection (P) or premultiplied P*MV matrix. More...
 
std::string toString ()
 
Mat4fupdateByFovDesc (jau::math::Mat4f &m, const FovDesc &fovDesc) noexcept
 Calculate the frustum planes in world coordinates using the passed FovDesc. More...
 
constexpr void updateByPlanes (const Plane src[]) noexcept
 Copy the given src planes into this this instance's planes. More...
 

Static Public Attributes

static constexpr const int BOTTOM = 2
 Index for bottom plane: {@value}. More...
 
static constexpr const int FAR = 5
 Index for far plane: {@value}. More...
 
static constexpr const int LEFT = 0
 Index for left plane: {@value}. More...
 
static constexpr const int NEAR = 4
 Index for near plane: {@value}. More...
 
static constexpr const int RIGHT = 1
 Index for right plane: {@value}. More...
 
static constexpr const int TOP = 3
 Index for top plane: {@value}. More...
 

Detailed Description

Providing frustum planes derived by different inputs (P*MV, ..) used to classify objects.

and to test whether they are outside

Extracting the world-frustum planes from the P*Mv:

Fast Extraction of Viewing Frustum Planes from the World-View-Projection Matrix
  Gil Gribb ggrib.nosp@m.b@ra.nosp@m.venso.nosp@m.ft.c.nosp@m.om
  Klaus Hartmann k_har.nosp@m.tman.nosp@m.n@osn.nosp@m.abru.nosp@m.eck.n.nosp@m.etsu.nosp@m.rf.de
  http://graphics.cs.ucf.edu/cap4720/fall2008/plane_extraction.pdf

Classifying Point, Sphere and AABBox:

Efficient View Frustum Culling
  Daniel Sýkora sykor.nosp@m.ad@f.nosp@m.el.cv.nosp@m.ut.c.nosp@m.z
  Josef Jelínek jelin.nosp@m.ej1@.nosp@m.fel.c.nosp@m.vut..nosp@m.cz
  http://www.cg.tuwien.ac.at/hostings/cescg/CESCG-2002/DSykoraJJelinek/index.html
Lighthouse3d.com
http://www.lighthouse3d.com/tutorials/view-frustum-culling/

Fundamentals about Planes, Half-Spaces and Frustum-Culling:

Planes and Half-Spaces,  Max Wagner mwagn.nosp@m.er@d.nosp@m.igipe.nosp@m.n.ed.nosp@m.u
http://www.emeyex.com/site/tuts/PlanesHalfSpaces.pdf
Frustum Culling,  Max Wagner mwagn.nosp@m.er@d.nosp@m.igipe.nosp@m.n.ed.nosp@m.u
http://www.emeyex.com/site/tuts/FrustumCulling.pdf

Definition at line 94 of file frustum.hpp.

Member Enumeration Documentation

◆ location_t

Enumerator
OUTSIDE 
INSIDE 
INTERSECT 

Definition at line 472 of file frustum.hpp.

Constructor & Destructor Documentation

◆ Frustum() [1/3]

constexpr jau::math::geom::Frustum::Frustum ( )
constexprdefaultnoexcept

Creates an undefined instance w/o calculating the frustum.

Use one of the update(..) methods to set the planes.

See also
updateByPlanes(Plane[])
#updateFrustumPlanes(float[], int)

◆ Frustum() [2/3]

constexpr jau::math::geom::Frustum::Frustum ( const Frustum o)
constexprdefaultnoexcept

◆ Frustum() [3/3]

constexpr jau::math::geom::Frustum::Frustum ( Frustum &&  o)
constexprdefaultnoexcept

Member Function Documentation

◆ operator=() [1/2]

constexpr Frustum & jau::math::geom::Frustum::operator= ( const Frustum )
constexprdefaultnoexcept

◆ operator=() [2/2]

constexpr Frustum & jau::math::geom::Frustum::operator= ( Frustum &&  )
constexprdefaultnoexcept

◆ getPlanes() [1/3]

constexpr jau::math::Vec4f * jau::math::geom::Frustum::getPlanes ( jau::math::Vec4f  out[]) const
inlineconstexprnoexcept

Sets each of the given Vec4f[6] out to Plane#toVec4f(Vec4f) in the order LEFT, RIGHT, BOTTOM, TOP, NEAR, FAR.

Parameters
outthe jau::math::vec4f[6] output array
Returns
out for chaining

Definition at line 270 of file frustum.hpp.

◆ getPlanes() [2/3]

constexpr void jau::math::geom::Frustum::getPlanes ( float  out[]) const
inlineconstexprnoexcept

Sets the given [float[off]..float[off+4*6]) out to ( n, d ).

Sets each of the given [float[off]..float[off+4*6]) out to Plane#toFloats(float[], int), i.e. [n.x, n.y, n.z, d, ...].

Plane order is as follows: LEFT, RIGHT, BOTTOM, TOP, NEAR, FAR.

Parameters
outthe float[off+4*6] output array
Returns
out for chaining

Definition at line 290 of file frustum.hpp.

◆ updateByPlanes()

constexpr void jau::math::geom::Frustum::updateByPlanes ( const Plane  src[])
inlineconstexprnoexcept

Copy the given src planes into this this instance's planes.

Parameters
srcthe 6 source planes

Definition at line 303 of file frustum.hpp.

◆ getPlanes() [3/3]

constexpr Plane * jau::math::geom::Frustum::getPlanes ( )
inlineconstexprnoexcept

Planes are ordered in the returned array as follows:

Plane's normals are pointing to the inside of the frustum in order to work w/ isOutside(..) methods.

Returns
array of normalized Planes, order see above.

Definition at line 329 of file frustum.hpp.

◆ updateByFovDesc()

Mat4f & jau::math::geom::Frustum::updateByFovDesc ( jau::math::Mat4f m,
const FovDesc fovDesc 
)
inlinenoexcept

Calculate the frustum planes in world coordinates using the passed FovDesc.

Operation Details:

Frustum plane's normals will point to the inside of the viewing frustum, as required by this class.

Parameters
m4x4 matrix in column-major order (also result)
fovDescFrustum FovDesc
Returns
given matrix for chaining
See also
Matrix4f::setToPerspective(FovHVHalves, float, float)
Matrix4f::updateFrustumPlanes(Frustum)
Matrix4f::getFrustum(Frustum, FovDesc)

Definition at line 355 of file frustum.hpp.

◆ setFromMat()

Frustum & jau::math::geom::Frustum::setFromMat ( const jau::math::Mat4f m)
inlinenoexcept

Calculate the frustum planes in world coordinates using the given column major order matrix, usually a projection (P) or premultiplied P*MV matrix.

Frustum plane's normals will point to the inside of the viewing frustum, as required by this class.

Definition at line 369 of file frustum.hpp.

Here is the caller graph for this function:

◆ isOutside() [1/2]

bool jau::math::geom::Frustum::isOutside ( const AABBox3f &&  box) const
inlinenoexcept

Returns whether the given AABBox is completely outside of this frustum.

Note: If method returns false, the box may only be partially inside, i.e. intersects with this frustum

Definition at line 463 of file frustum.hpp.

◆ classifyPoint()

location_t jau::math::geom::Frustum::classifyPoint ( const Vec3f p) const
inlinenoexcept

Classifies the given Vec3f point whether it is outside, inside or on a plane of this frustum.

Parameters
pthe point
Returns
Location of point related to frustum planes

Definition at line 480 of file frustum.hpp.

◆ isOutside() [2/2]

bool jau::math::geom::Frustum::isOutside ( const Vec3f p) const
inlinenoexcept

Returns whether the given Vec3f point is completely outside of this frustum.

Parameters
pthe point
Returns
true if outside of the frustum, otherwise inside or on a plane

Definition at line 500 of file frustum.hpp.

◆ classifySphere()

location_t jau::math::geom::Frustum::classifySphere ( const Vec3f p,
const float  radius 
) const
inlinenoexcept

Classifies the given sphere whether it is is outside, intersecting or inside of this frustum.

Parameters
pcenter of the sphere
radiusradius of the sphere
Returns
Location of point related to frustum planes

Definition at line 516 of file frustum.hpp.

Here is the caller graph for this function:

◆ isSphereOutside()

bool jau::math::geom::Frustum::isSphereOutside ( const Vec3f p,
const float  radius 
) const
inlinenoexcept

Returns whether the given sphere is completely outside of this frustum.

Parameters
pcenter of the sphere
radiusradius of the sphere
Returns
true if outside of the frustum, otherwise inside or intersecting

Definition at line 539 of file frustum.hpp.

◆ toString()

std::string jau::math::geom::Frustum::toString ( )
inline

Definition at line 543 of file frustum.hpp.

Here is the caller graph for this function:

Member Data Documentation

◆ LEFT

constexpr const int jau::math::geom::Frustum::LEFT = 0
staticconstexpr

Index for left plane: {@value}.

Definition at line 97 of file frustum.hpp.

◆ RIGHT

constexpr const int jau::math::geom::Frustum::RIGHT = 1
staticconstexpr

Index for right plane: {@value}.

Definition at line 99 of file frustum.hpp.

◆ BOTTOM

constexpr const int jau::math::geom::Frustum::BOTTOM = 2
staticconstexpr

Index for bottom plane: {@value}.

Definition at line 101 of file frustum.hpp.

◆ TOP

constexpr const int jau::math::geom::Frustum::TOP = 3
staticconstexpr

Index for top plane: {@value}.

Definition at line 103 of file frustum.hpp.

◆ NEAR

constexpr const int jau::math::geom::Frustum::NEAR = 4
staticconstexpr

Index for near plane: {@value}.

Definition at line 105 of file frustum.hpp.

◆ FAR

constexpr const int jau::math::geom::Frustum::FAR = 5
staticconstexpr

Index for far plane: {@value}.

Definition at line 107 of file frustum.hpp.


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