jaulib v1.3.6
Jau Support Library (C++, Java, ..)
Loading...
Searching...
No Matches
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.
 
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.
 
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.
 
constexpr PlanegetPlanes () noexcept
 Planes are ordered in the returned array as follows:
 
constexpr void getPlanes (float out[]) const noexcept
 Sets the given [float[off]..float[off+4*6]) out to ( n, d ).
 
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.
 
bool isOutside (const AABBox3f &&box) const noexcept
 Returns whether the given AABBox is completely outside of this frustum.
 
bool isOutside (const Vec3f &p) const noexcept
 Returns whether the given Vec3f point is completely outside of this frustum.
 
bool isSphereOutside (const Vec3f &p, const float radius) const noexcept
 Returns whether the given sphere is completely outside of this frustum.
 
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.
 
std::string toString ()
 
Mat4fupdateByFovDesc (jau::math::Mat4f &m, const FovDesc &fovDesc)
 Calculate the frustum planes in world coordinates using the passed FovDesc.
 
constexpr void updateByPlanes (const Plane src[]) noexcept
 Copy the given src planes into this this instance's planes.
 

Static Public Attributes

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

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 91 of file frustum.hpp.

Member Enumeration Documentation

◆ location_t

Enumerator
OUTSIDE 
INSIDE 
INTERSECT 

Definition at line 469 of file frustum.hpp.

Constructor & Destructor Documentation

◆ Frustum() [1/3]

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)
Here is the caller graph for this function:

◆ Frustum() [2/3]

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

◆ Frustum() [3/3]

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

Member Function Documentation

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ getPlanes() [1/3]

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 267 of file frustum.hpp.

Here is the caller graph for this function:

◆ getPlanes() [2/3]

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 287 of file frustum.hpp.

◆ updateByPlanes()

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 300 of file frustum.hpp.

◆ getPlanes() [3/3]

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 326 of file frustum.hpp.

◆ updateByFovDesc()

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

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 352 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 366 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 460 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 477 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 497 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 513 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 536 of file frustum.hpp.

◆ toString()

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

Definition at line 540 of file frustum.hpp.

Here is the caller graph for this function:

Member Data Documentation

◆ LEFT

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

Index for left plane: {@value}.

Definition at line 94 of file frustum.hpp.

◆ RIGHT

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

Index for right plane: {@value}.

Definition at line 96 of file frustum.hpp.

◆ BOTTOM

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

Index for bottom plane: {@value}.

Definition at line 98 of file frustum.hpp.

◆ TOP

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

Index for top plane: {@value}.

Definition at line 100 of file frustum.hpp.

◆ NEAR

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

Index for near plane: {@value}.

Definition at line 102 of file frustum.hpp.

◆ FAR

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

Index for far plane: {@value}.

Definition at line 104 of file frustum.hpp.


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