CUGL 2.0
Cornell University Game Library
Public Types | Public Member Functions | Static Public Attributes | List of all members
cugl::Frustum Class Reference

#include <CUFrustum.h>

Public Types

enum  Region { Region::INSIDE, Region::OUTSIDE, Region::INTERSECT }
 
enum  Side : unsigned int {
  Side::CLOSE = 0, Side::AWAY = 1, Side::LEFT = 2, Side::RIGHT = 3,
  Side::TOP = 4, Side::BOTTOM = 5
}
 

Public Member Functions

 Frustum ()
 
 Frustum (const Mat4 &inverseView)
 
 Frustum (const Frustum &frustum)
 
 ~Frustum ()
 
Frustumoperator= (const Mat4 &inverseView)
 
Frustumoperator= (const Frustum &frustum)
 
Frustumset (const Mat4 &inverseView)
 
Frustumset (const Frustum &frustum)
 
const PlanegetPlane (Side side)
 
const Vec3 getCorner (unsigned int index)
 
Region find (const Vec3 point)
 
Region find (float x, float y, float z)
 
Region findSphere (const Vec3 center, float radius)
 
Region findSphere (float x, float y, float z, float radius)
 
Region findSphereWithoutNearFar (const Vec3 center, float radius)
 
Region findSphereWithoutNearFar (float x, float y, float z, float radius)
 
Region findBox (const Vec3 center, const Vec3 dimension)
 
Region findBox (float x, float y, float z, float halfWidth, float halfHeight, float halfDepth)
 

Static Public Attributes

static const int PLANE_COUNT = 6
 
static const int CORNER_COUNT = 8
 

Detailed Description

This class is a truncated rectangular pyramid.

A frustum is used to define the viewable region and its projection onto the screen. Normally, we would embed this into a camera class. However, we do not want our cameras any more heavy weight than they are, so we pull them out.

Member Enumeration Documentation

◆ Region

enum cugl::Frustum::Region
strong

The three frustum locations

Enumerator
INSIDE 

The shape is fully inside the frustum

OUTSIDE 

The shape is fully outside the frustum

INTERSECT 

The shape intersects the frustum

◆ Side

enum cugl::Frustum::Side : unsigned int
strong

This enum is used to index the six clipping planes

Enumerator
CLOSE 

The near clipping plane

AWAY 

The far clipping plane

LEFT 

The left clipping plane

RIGHT 

The right clipping plane

TOP 

The top clipping plane

BOTTOM 

The bottom clipping plane

Constructor & Destructor Documentation

◆ Frustum() [1/3]

cugl::Frustum::Frustum ( )
inline

Creates a frustum for the identity matrix.

◆ Frustum() [2/3]

cugl::Frustum::Frustum ( const Mat4 inverseView)
inline

Creates a frustum for the inverse projection view matrix.

Parameters
inverseViewThe inverse projection view matrix.

◆ Frustum() [3/3]

cugl::Frustum::Frustum ( const Frustum frustum)
inline

Creates a copy of the given frustum.

Parameters
frustumThe frustum to copy.

◆ ~Frustum()

cugl::Frustum::~Frustum ( )
inline

Destroys this frustum, releasing all resources

Member Function Documentation

◆ find() [1/2]

Region cugl::Frustum::find ( const Vec3  point)

Returns the location of the point with respect to the frustum.

Parameters
pointThe point to check.
Returns
the location of the point with respect to the frustum.

◆ find() [2/2]

Region cugl::Frustum::find ( float  x,
float  y,
float  z 
)
inline

Returns the location of the point with respect to the frustum.

Parameters
xThe x-coordinate of the point
yThe y-coordinate of the point
zThe z-coordinate of the point
Returns
the location of the point with respect to the frustum.

◆ findBox() [1/2]

Region cugl::Frustum::findBox ( const Vec3  center,
const Vec3  dimension 
)
inline

Returns the location of the bounding box with respect to the frustum.

The bounding box is a cube, defined by its center and dimenion along each axis.

Parameters
centerThe center of the bounding box
dimensionThe dimensions of the bounding box
Returns
the location of the bounding box with respect to the frustum.

◆ findBox() [2/2]

Region cugl::Frustum::findBox ( float  x,
float  y,
float  z,
float  halfWidth,
float  halfHeight,
float  halfDepth 
)

Returns the location of the bounding box with respect to the frustum.

The bounding box is a cube, defined by its center and dimenion along each axis.

Parameters
xThe x-coordinate of the center of the bounding box
yThe y-coordinate of the center of the bounding box
zThe z-coordinate of the center of the bounding box
halfWidthHalf of the width (x-axis) of the bounding box
halfHeightHalf of the height (y-axis) of the bounding box
halfDepthHalf of the depth (z-axis) of the bounding box
Returns
the location of the bounding box with respect to the frustum.

◆ findSphere() [1/2]

Region cugl::Frustum::findSphere ( const Vec3  center,
float  radius 
)

Returns the location of the sphere with respect to the frustum.

Parameters
centerThe center of the sphere
radiusThe radius of the sphere
Returns
the location of the sphere with respect to the frustum.

◆ findSphere() [2/2]

Region cugl::Frustum::findSphere ( float  x,
float  y,
float  z,
float  radius 
)
inline

Returns the location of the sphere with respect to the frustum.

Parameters
xThe x-coordinate of the center of the sphere
yThe y-coordinate of the center of the sphere
zThe z-coordinate of the center of the sphere
radiusThe radius of the sphere
Returns
the containment type of the sphere.

◆ findSphereWithoutNearFar() [1/2]

Region cugl::Frustum::findSphereWithoutNearFar ( const Vec3  center,
float  radius 
)

Returns the location of the sphere with respect to the frustum.

This method does not check whether is the behind the near or far clipping planes.

Parameters
centerThe center of the sphere
radiusThe radius of the sphere
Returns
the location of the sphere with respect to the frustum.

◆ findSphereWithoutNearFar() [2/2]

Region cugl::Frustum::findSphereWithoutNearFar ( float  x,
float  y,
float  z,
float  radius 
)
inline

Returns the location of the sphere with respect to the frustum.

This method does not check whether is the behind the near or far clipping planes.

Parameters
xThe x-coordinate of the center of the sphere
yThe y-coordinate of the center of the sphere
zThe z-coordinate of the center of the sphere
radiusThe radius of the sphere
Returns
the location of the sphere with respect to the frustum.

◆ getCorner()

const Vec3 cugl::Frustum::getCorner ( unsigned int  index)
inline

Returns the frustum corner for the given index.

The order is counter clockwise, starting at bottom left

Returns
the frustum corner for the given index.

◆ getPlane()

const Plane& cugl::Frustum::getPlane ( Side  side)
inline

Returns the clipping plane for the given side.

See the enum Side for the available options.

Parameters
sideThe clipping plane side.
Returns
the clipping plane for the given side.

◆ operator=() [1/2]

Frustum& cugl::Frustum::operator= ( const Frustum frustum)
inline

Sets this frustum to be a copy of the given frustum.

Parameters
frustumThe frustum to copy,
Returns
A reference to this (modified) Frustum for chaining.

◆ operator=() [2/2]

Frustum& cugl::Frustum::operator= ( const Mat4 inverseView)
inline

Sets this frustum's clipping planes to the given inverse projection view matrix.

Parameters
inverseViewThe inverse projection view matrix.
Returns
A reference to this (modified) Frustum for chaining.

◆ set() [1/2]

Frustum& cugl::Frustum::set ( const Frustum frustum)

Sets this frustum to be a copy of the given frustum.

Parameters
frustumThe frustum to copy,
Returns
A reference to this (modified) Frustum for chaining.

◆ set() [2/2]

Frustum& cugl::Frustum::set ( const Mat4 inverseView)

Sets this frustum's clipping planes to the given inverse projection view matrix.

Parameters
inverseViewThe inverse projection view matrix.
Returns
A reference to this (modified) Frustum for chaining.

Member Data Documentation

◆ CORNER_COUNT

const int cugl::Frustum::CORNER_COUNT = 8
static

The number of corners in a frustum

◆ PLANE_COUNT

const int cugl::Frustum::PLANE_COUNT = 6
static

The number of planes in a frustum


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