HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Frustum< T > Class Template Reference

#include <ImathFrustum.h>

Public Member Functions

Constructors and Assignment
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Frustum () IMATH_NOEXCEPT
 
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Frustum (const Frustum &) IMATH_NOEXCEPT
 Copy constructor. More...
 
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Frustum (T nearPlane, T farPlane, T left, T right, T top, T bottom, bool ortho=false) IMATH_NOEXCEPT
 Initialize to specific values. More...
 
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Frustum (T nearPlane, T farPlane, T fovx, T fovy, T aspect) IMATH_NOEXCEPT
 Initialize with fov and aspect. More...
 
virtual ~Frustum () IMATH_NOEXCEPT
 Destructor. More...
 
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 const
Frustum
operator= (const Frustum &) IMATH_NOEXCEPT
 Component-wise assignment. More...
 
Comparison
IMATH_HOSTDEVICE constexpr bool operator== (const Frustum< T > &src) const IMATH_NOEXCEPT
 Equality. More...
 
IMATH_HOSTDEVICE constexpr bool operator!= (const Frustum< T > &src) const IMATH_NOEXCEPT
 Inequality. More...
 
Query
IMATH_HOSTDEVICE constexpr bool orthographic () const IMATH_NOEXCEPT
 Return true if the frustum is orthographic, false if perspective. More...
 
IMATH_HOSTDEVICE constexpr T nearPlane () const IMATH_NOEXCEPT
 Return the near clipping plane. More...
 
IMATH_HOSTDEVICE constexpr T hither () const IMATH_NOEXCEPT
 Return the near clipping plane. More...
 
IMATH_HOSTDEVICE constexpr T farPlane () const IMATH_NOEXCEPT
 Return the far clipping plane. More...
 
IMATH_HOSTDEVICE constexpr T yon () const IMATH_NOEXCEPT
 Return the far clipping plane. More...
 
IMATH_HOSTDEVICE constexpr T left () const IMATH_NOEXCEPT
 Return the left of the frustum. More...
 
IMATH_HOSTDEVICE constexpr T right () const IMATH_NOEXCEPT
 Return the right of the frustum. More...
 
IMATH_HOSTDEVICE constexpr T bottom () const IMATH_NOEXCEPT
 Return the bottom of the frustum. More...
 
IMATH_HOSTDEVICE constexpr T top () const IMATH_NOEXCEPT
 Return the top of the frustum. More...
 
IMATH_HOSTDEVICE constexpr T fovx () const IMATH_NOEXCEPT
 Return the field of view in X. More...
 
IMATH_HOSTDEVICE constexpr T fovy () const IMATH_NOEXCEPT
 Return the field of view in Y. More...
 
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 T 
aspect () const IMATH_NOEXCEPT
 Return the aspect ratio. More...
 
IMATH_CONSTEXPR14 T aspectExc () const
 
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 Matrix44< T
projectionMatrix () const IMATH_NOEXCEPT
 Return the project matrix that the frustum defines. More...
 
IMATH_CONSTEXPR14 Matrix44< TprojectionMatrixExc () const
 
IMATH_HOSTDEVICE constexpr bool degenerate () const IMATH_NOEXCEPT
 Return true if the frustum is degenerate. More...
 
Set Value
IMATH_HOSTDEVICE void set (T nearPlane, T farPlane, T left, T right, T top, T bottom, bool ortho=false) IMATH_NOEXCEPT
 Set functions change the entire state of the Frustum. More...
 
IMATH_HOSTDEVICE void set (T nearPlane, T farPlane, T fovx, T fovy, T aspect) IMATH_NOEXCEPT
 
void setExc (T nearPlane, T farPlane, T fovx, T fovy, T aspect)
 
IMATH_HOSTDEVICE void modifyNearAndFar (T nearPlane, T farPlane) IMATH_NOEXCEPT
 Set the near and far clipping planes. More...
 
IMATH_HOSTDEVICE void setOrthographic (bool) IMATH_NOEXCEPT
 Set the ortographic state. More...
 
IMATH_HOSTDEVICE void planes (Plane3< T > p[6]) const IMATH_NOEXCEPT
 
IMATH_HOSTDEVICE void planes (Plane3< T > p[6], const Matrix44< T > &M) const IMATH_NOEXCEPT
 
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14
IMATH_HOSTDEVICE Frustum< T
window (T left, T right, T top, T bottom) const IMATH_NOEXCEPT
 
Utility Methods
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 Line3< T
projectScreenToRay (const Vec2< T > &) const IMATH_NOEXCEPT
 Project a point in screen spaced to 3d ray. More...
 
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 Vec2< T
projectPointToScreen (const Vec3< T > &) const IMATH_NOEXCEPT
 Project a 3D point into screen coordinates. More...
 
IMATH_CONSTEXPR14 Vec2< TprojectPointToScreenExc (const Vec3< T > &) const
 
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 T 
ZToDepth (long zval, long min, long max) const IMATH_NOEXCEPT
 Map a z value to its depth in the frustum. More...
 
IMATH_CONSTEXPR14 T ZToDepthExc (long zval, long min, long max) const
 Map a z value to its depth in the frustum. More...
 
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 T 
normalizedZToDepth (T zval) const IMATH_NOEXCEPT
 Map a normalized z value to its depth in the frustum. More...
 
IMATH_CONSTEXPR14 T normalizedZToDepthExc (T zval) const
 
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 long 
DepthToZ (T depth, long zmin, long zmax) const IMATH_NOEXCEPT
 Map depth to z value. More...
 
IMATH_CONSTEXPR14 long DepthToZExc (T depth, long zmin, long zmax) const
 Map depth to z value. Throw an exception on error. More...
 
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 T 
worldRadius (const Vec3< T > &p, T radius) const IMATH_NOEXCEPT
 Compute worldRadius. More...
 
IMATH_CONSTEXPR14 T worldRadiusExc (const Vec3< T > &p, T radius) const
 Compute worldRadius. Throw an exception on error. More...
 
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 T 
screenRadius (const Vec3< T > &p, T radius) const IMATH_NOEXCEPT
 Compute screen radius. More...
 
IMATH_CONSTEXPR14 T screenRadiusExc (const Vec3< T > &p, T radius) const
 Compute screen radius. Throw an exception on error. More...
 

Protected Member Functions

IMATH_HOSTDEVICE constexpr
Vec2< T
screenToLocal (const Vec2< T > &) const IMATH_NOEXCEPT
 Map point from screen space to local space. More...
 
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 Vec2< T
localToScreen (const Vec2< T > &) const IMATH_NOEXCEPT
 Map point from local space to screen space. More...
 
IMATH_CONSTEXPR14 Vec2< TlocalToScreenExc (const Vec2< T > &) const
 

Detailed Description

template<class T>
class Frustum< T >

Template class Frustum<T>

The frustum is always located with the eye point at the origin facing down -Z. This makes the Frustum class compatable with OpenGL (or anything that assumes a camera looks down -Z, hence with a right-handed coordinate system) but not with RenderMan which assumes the camera looks down +Z. Additional functions are provided for conversion from and from various camera coordinate spaces.

nearPlane/farPlane: near/far are keywords used by Microsoft's compiler, so we use nearPlane/farPlane instead to avoid issues.

Definition at line 39 of file ImathFrustum.h.

Constructor & Destructor Documentation

template<class T >
IMATH_CONSTEXPR14 Frustum< T >::Frustum ( )
inline

Initialize with default values: near=0.1, far=1000.0, left=-1.0, right=1.0, top=1.0, bottom=-1.0, ortho=false

Definition at line 254 of file ImathFrustum.h.

template<class T >
IMATH_CONSTEXPR14 Frustum< T >::Frustum ( const Frustum< T > &  f)
inline

Copy constructor.

Definition at line 259 of file ImathFrustum.h.

template<class T >
IMATH_CONSTEXPR14 Frustum< T >::Frustum ( T  nearPlane,
T  farPlane,
T  left,
T  right,
T  top,
T  bottom,
bool  ortho = false 
)
inline

Initialize to specific values.

Definition at line 265 of file ImathFrustum.h.

template<class T >
IMATH_CONSTEXPR14 Frustum< T >::Frustum ( T  nearPlane,
T  farPlane,
T  fovx,
T  fovy,
T  aspect 
)
inline

Initialize with fov and aspect.

Definition at line 271 of file ImathFrustum.h.

template<class T >
Frustum< T >::~Frustum ( )
virtual

Destructor.

Definition at line 276 of file ImathFrustum.h.

Member Function Documentation

template<class T >
IMATH_CONSTEXPR14 T Frustum< T >::aspect ( ) const
inline

Return the aspect ratio.

Definition at line 445 of file ImathFrustum.h.

template<class T >
IMATH_CONSTEXPR14 T Frustum< T >::aspectExc ( ) const
inline

Return the aspect ratio. Throw an exception if the aspect ratio is undefined.

Definition at line 429 of file ImathFrustum.h.

template<class T>
IMATH_HOSTDEVICE constexpr T Frustum< T >::bottom ( ) const
inline

Return the bottom of the frustum.

Definition at line 105 of file ImathFrustum.h.

template<class T >
constexpr bool Frustum< T >::degenerate ( ) const
inline

Return true if the frustum is degenerate.

Definition at line 574 of file ImathFrustum.h.

template<class T >
IMATH_CONSTEXPR14 long Frustum< T >::DepthToZ ( T  depth,
long  zmin,
long  zmax 
) const

Map depth to z value.

Definition at line 788 of file ImathFrustum.h.

template<class T >
IMATH_CONSTEXPR14 long Frustum< T >::DepthToZExc ( T  depth,
long  zmin,
long  zmax 
) const

Map depth to z value. Throw an exception on error.

Definition at line 743 of file ImathFrustum.h.

template<class T>
IMATH_HOSTDEVICE constexpr T Frustum< T >::farPlane ( ) const
inline

Return the far clipping plane.

Definition at line 93 of file ImathFrustum.h.

template<class T >
constexpr T Frustum< T >::fovx ( ) const
inline

Return the field of view in X.

Definition at line 415 of file ImathFrustum.h.

template<class T >
constexpr T Frustum< T >::fovy ( ) const
inline

Return the field of view in Y.

Definition at line 422 of file ImathFrustum.h.

template<class T>
IMATH_HOSTDEVICE constexpr T Frustum< T >::hither ( ) const
inline

Return the near clipping plane.

Definition at line 90 of file ImathFrustum.h.

template<class T>
IMATH_HOSTDEVICE constexpr T Frustum< T >::left ( ) const
inline

Return the left of the frustum.

Definition at line 99 of file ImathFrustum.h.

template<class T >
IMATH_CONSTEXPR14 Vec2< T > Frustum< T >::localToScreen ( const Vec2< T > &  p) const
inlineprotected

Map point from local space to screen space.

Definition at line 622 of file ImathFrustum.h.

template<class T >
IMATH_CONSTEXPR14 Vec2< T > Frustum< T >::localToScreenExc ( const Vec2< T > &  p) const
inlineprotected

Map point from local space to screen space. Throw an exception on error.

Definition at line 601 of file ImathFrustum.h.

template<class T >
void Frustum< T >::modifyNearAndFar ( T  nearPlane,
T  farPlane 
)
inline

Set the near and far clipping planes.

Definition at line 325 of file ImathFrustum.h.

template<class T>
IMATH_HOSTDEVICE constexpr T Frustum< T >::nearPlane ( ) const
inline

Return the near clipping plane.

Definition at line 87 of file ImathFrustum.h.

template<class T >
IMATH_CONSTEXPR14 T Frustum< T >::normalizedZToDepth ( T  zval) const

Map a normalized z value to its depth in the frustum.

Definition at line 724 of file ImathFrustum.h.

template<class T >
IMATH_CONSTEXPR14 T Frustum< T >::normalizedZToDepthExc ( T  zval) const

Map a normalized z value to its depth in the frustum. Throw an exception on error.

Definition at line 698 of file ImathFrustum.h.

template<class T >
constexpr bool Frustum< T >::operator!= ( const Frustum< T > &  src) const
inline

Inequality.

Definition at line 305 of file ImathFrustum.h.

template<class T >
IMATH_CONSTEXPR14 const Frustum< T > & Frustum< T >::operator= ( const Frustum< T > &  f)
inline

Component-wise assignment.

Definition at line 281 of file ImathFrustum.h.

template<class T >
constexpr bool Frustum< T >::operator== ( const Frustum< T > &  src) const
inline

Equality.

Definition at line 296 of file ImathFrustum.h.

template<class T>
IMATH_HOSTDEVICE constexpr bool Frustum< T >::orthographic ( ) const
inline

Return true if the frustum is orthographic, false if perspective.

Definition at line 84 of file ImathFrustum.h.

template<class T >
void Frustum< T >::planes ( Plane3< T p[6]) const

Set the planes in p to be the six bounding planes of the frustum, in the following order: top, right, bottom, left, near, far. Note that the planes have normals that point out of the frustum.

Definition at line 881 of file ImathFrustum.h.

template<class T >
void Frustum< T >::planes ( Plane3< T p[6],
const Matrix44< T > &  M 
) const

Set the planes in p to be the six bounding planes of the frustum, in the following order: top, right, bottom, left, near, far. Note that the planes have normals that point out of the frustum. Apply the given matrix to transform the frustum before setting the planes.

Definition at line 914 of file ImathFrustum.h.

template<class T >
IMATH_CONSTEXPR14 Matrix44< T > Frustum< T >::projectionMatrix ( ) const
inline

Return the project matrix that the frustum defines.

Definition at line 530 of file ImathFrustum.h.

template<class T >
IMATH_CONSTEXPR14 Matrix44< T > Frustum< T >::projectionMatrixExc ( ) const
inline

Return the project matrix that the frustum defines. Throw an exception if the frustum is degenerate.

Definition at line 454 of file ImathFrustum.h.

template<class T >
IMATH_CONSTEXPR14 Vec2< T > Frustum< T >::projectPointToScreen ( const Vec3< T > &  point) const

Project a 3D point into screen coordinates.

Definition at line 656 of file ImathFrustum.h.

template<class T >
IMATH_CONSTEXPR14 Vec2< T > Frustum< T >::projectPointToScreenExc ( const Vec3< T > &  point) const

Project a 3D point into screen coordinates. Throw an exception if the point cannot be projected.

Definition at line 645 of file ImathFrustum.h.

template<class T >
IMATH_CONSTEXPR14 Line3< T > Frustum< T >::projectScreenToRay ( const Vec2< T > &  p) const
inline

Project a point in screen spaced to 3d ray.

Definition at line 634 of file ImathFrustum.h.

template<class T>
IMATH_HOSTDEVICE constexpr T Frustum< T >::right ( ) const
inline

Return the right of the frustum.

Definition at line 102 of file ImathFrustum.h.

template<class T >
IMATH_CONSTEXPR14 T Frustum< T >::screenRadius ( const Vec3< T > &  p,
T  radius 
) const

Compute screen radius.

Definition at line 842 of file ImathFrustum.h.

template<class T >
IMATH_CONSTEXPR14 T Frustum< T >::screenRadiusExc ( const Vec3< T > &  p,
T  radius 
) const

Compute screen radius. Throw an exception on error.

Definition at line 815 of file ImathFrustum.h.

template<class T >
constexpr Vec2< T > Frustum< T >::screenToLocal ( const Vec2< T > &  s) const
inlineprotected

Map point from screen space to local space.

Definition at line 593 of file ImathFrustum.h.

template<class T >
void Frustum< T >::set ( T  nearPlane,
T  farPlane,
T  left,
T  right,
T  top,
T  bottom,
bool  ortho = false 
)
inline

Set functions change the entire state of the Frustum.

Definition at line 312 of file ImathFrustum.h.

template<class T >
void Frustum< T >::set ( T  nearPlane,
T  farPlane,
T  fovx,
T  fovy,
T  aspect 
)
inline

Set functions change the entire state of the Frustum using field of view and aspect ratio

Definition at line 390 of file ImathFrustum.h.

template<class T >
void Frustum< T >::setExc ( T  nearPlane,
T  farPlane,
T  fovx,
T  fovy,
T  aspect 
)
inline

Set functions change the entire state of the Frustum using field of view and aspect ratio. Throw an exception if fovx and/or fovy are invalid.

Definition at line 362 of file ImathFrustum.h.

template<class T >
void Frustum< T >::setOrthographic ( bool  ortho)
inline

Set the ortographic state.

Definition at line 355 of file ImathFrustum.h.

template<class T>
IMATH_HOSTDEVICE constexpr T Frustum< T >::top ( ) const
inline

Return the top of the frustum.

Definition at line 108 of file ImathFrustum.h.

template<class T >
IMATH_CONSTEXPR14 Frustum< T > Frustum< T >::window ( T  left,
T  right,
T  top,
T  bottom 
) const
inline

Takes a rectangle in the screen space (i.e., -1 <= left <= right <= 1 and -1 <= bottom <= top <= 1) of this Frustum, and returns a new Frustum whose near clipping-plane window is that rectangle in local space.

Definition at line 581 of file ImathFrustum.h.

template<class T >
IMATH_CONSTEXPR14 T Frustum< T >::worldRadius ( const Vec3< T > &  p,
T  radius 
) const

Compute worldRadius.

Definition at line 874 of file ImathFrustum.h.

template<class T >
IMATH_CONSTEXPR14 T Frustum< T >::worldRadiusExc ( const Vec3< T > &  p,
T  radius 
) const

Compute worldRadius. Throw an exception on error.

Definition at line 859 of file ImathFrustum.h.

template<class T>
IMATH_HOSTDEVICE constexpr T Frustum< T >::yon ( ) const
inline

Return the far clipping plane.

Definition at line 96 of file ImathFrustum.h.

template<class T >
IMATH_CONSTEXPR14 T Frustum< T >::ZToDepth ( long  zval,
long  min,
long  max 
) const

Map a z value to its depth in the frustum.

Definition at line 685 of file ImathFrustum.h.

template<class T >
IMATH_CONSTEXPR14 T Frustum< T >::ZToDepthExc ( long  zval,
long  min,
long  max 
) const

Map a z value to its depth in the frustum.

Definition at line 667 of file ImathFrustum.h.


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