Rendu
A lightweight rendering engine for experimentations
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Types | Private Attributes | List of all members
Frustum Class Reference

Represent a 3D frustum, volume defined by the intersection of six planes. More...

#include <Bounds.hpp>

Public Member Functions

 Frustum (const glm::mat4 &vp)
 
bool intersects (const BoundingBox &box) const
 

Static Public Member Functions

static glm::mat4 perspective (float fov, float ratio, float near, float far)
 
static glm::mat4 ortho (float left, float right, float bottom, float top, float near, float far)
 

Private Types

enum  FrustumPlane : uint {
  LEFT = 0 , RIGHT = 1 , TOP = 2 , BOTTOM = 3 ,
  NEAR = 4 , FAR = 5 , COUNT = 6
}
 

Private Attributes

std::array< glm::vec4, FrustumPlane::COUNT > _planes
 Frustum hyperplane coefficients.
 
std::array< glm::vec3, 8 > _corners
 Frustum corners.
 

Detailed Description

Represent a 3D frustum, volume defined by the intersection of six planes.

Member Enumeration Documentation

◆ FrustumPlane

enum Frustum::FrustumPlane : uint
private

Helper enum for the frustum plane locations.

Constructor & Destructor Documentation

◆ Frustum()

Frustum::Frustum ( const glm::mat4 &  vp)

Create a frustum from a view-projection matrix.

Parameters
vpthe matrix defining the frustum

Member Function Documentation

◆ intersects()

bool Frustum::intersects ( const BoundingBox box) const

Indicate if a bounding box intersect this frustum.

Parameters
boxthe bounding box to test
Returns
true if the bounding box intersects the frustum.
Todo:
Implement frustum corner checks to weed out more false positives.

◆ ortho()

glm::mat4 Frustum::ortho ( float  left,
float  right,
float  bottom,
float  top,
float  near,
float  far 
)
static

Generate an orthographic projection matrix, correctly oriented for the rendering API.

Parameters
leftleft plane distance from the center
rightright plane distance from the center
bottombottom plane distance from the center
toptop plane distance from the center
nearthe near plane distance
farthe far plane distance
Returns
the projection matrix

◆ perspective()

glm::mat4 Frustum::perspective ( float  fov,
float  ratio,
float  near,
float  far 
)
static

Generate a perspective projection matrix, correctly oriented for the rendering API.

Parameters
fovvertical field of view in radians
ratioaspect ratio
nearthe near plane distance
farthe far plane distance
Returns
the projection matrix

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