EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
EBGeometry::Render::Camera< T > Struct Template Reference

A camera orbiting a target point. More...

#include <EBGeometry_Render.hpp>

Public Member Functions

Vec3T< T > eye () const noexcept
 Where the eye is.
 
void frame (Vec3T< T > &a_forward, Vec3T< T > &a_right, Vec3T< T > &a_up) const noexcept
 The camera's frame: unit vectors forward (towards the target), right and up on the screen.
 
void horizontal (Vec3T< T > &a_first, Vec3T< T > &a_second) const noexcept
 Two unit vectors that span the plane perpendicular to the up axis: yaw 90 looks from the first, yaw 0 from the second.
 

Static Public Member Functions

static Camera fit (const BoundingVolumes::AABBT< T > &a_box, const Vec3T< T > &a_up=Vec3T< T >(T(0), T(1), T(0)))
 A camera that sees the whole of a box, from the default direction.
 
static Camera fit (const BoundingVolumes::AABBT< T > &a_box, View a_view, const Vec3T< T > &a_up=Vec3T< T >(T(0), T(1), T(0)))
 A camera that sees the whole of a box, from a given direction.
 
static Camera lookAt (const Vec3T< T > &a_eye, const Vec3T< T > &a_target, const Vec3T< T > &a_up=Vec3T< T >(T(0), T(1), T(0)), const T a_fieldOfView=T(40))
 A camera at a given eye, looking at a given point.
 

Public Attributes

Vec3T< T > m_target = Vec3T<T>::zeros()
 The point the camera looks at.
 
T m_yaw = T(35)
 Degrees about the up axis.
 
T m_pitch = T(25)
 Degrees above the plane perpendicular to the up axis, from -90 to 90.
 
T m_distance = T(4)
 Distance from the eye to the target.
 
T m_fieldOfView = T(40)
 Vertical field of view, in degrees.
 
Vec3T< T > m_up = Vec3T<T>(T(0), T(1), T(0))
 The up axis (need not be of unit length).
 
bool m_orthographic = false
 Parallel rays instead of rays from the eye: no perspective, so sizes do not shrink with distance.
 
T m_nearClip = T(0)
 How far along each camera ray it starts (0: at the eye): anything nearer is not seen.
 

Detailed Description

template<class T>
struct EBGeometry::Render::Camera< T >

A camera orbiting a target point.

The eye sits m_distance from m_target, in the direction given by m_yaw (degrees about the up axis) and m_pitch (degrees above the plane perpendicular to it). With the default up axis +y, yaw 0 looks from +z and yaw 90 from +x. fit() aims it at a box, lookAt() places it directly. The image's right follows the yaw alone, so the camera may look straight along the up axis (pitch 90 or -90).

Template Parameters
TFloating-point precision.

Member Function Documentation

◆ eye()

template<class T >
Vec3T< T > EBGeometry::Render::Camera< T >::eye ( ) const
inlinenoexcept

Where the eye is.

Returns
The eye.

◆ fit() [1/2]

template<class T >
static Camera EBGeometry::Render::Camera< T >::fit ( const BoundingVolumes::AABBT< T > &  a_box,
const Vec3T< T > &  a_up = Vec3T< T >(T(0), T(1), T(0)) 
)
inlinestatic

A camera that sees the whole of a box, from the default direction.

Aims at the box's center, from far enough that the sphere around the box fits the view. The box must be bounded and not empty.

Parameters
[in]a_boxBox.
[in]a_upUp axis.
Returns
The camera.

◆ fit() [2/2]

template<class T >
static Camera EBGeometry::Render::Camera< T >::fit ( const BoundingVolumes::AABBT< T > &  a_box,
View  a_view,
const Vec3T< T > &  a_up = Vec3T< T >(T(0), T(1), T(0)) 
)
inlinestatic

A camera that sees the whole of a box, from a given direction.

As fit(const BoundingVolumes::AABBT<T>&, const Vec3T<T>&), from a_view.

Parameters
[in]a_boxBox.
[in]a_viewDirection to look from.
[in]a_upUp axis.
Returns
The camera.

◆ frame()

template<class T >
void EBGeometry::Render::Camera< T >::frame ( Vec3T< T > &  a_forward,
Vec3T< T > &  a_right,
Vec3T< T > &  a_up 
) const
inlinenoexcept

The camera's frame: unit vectors forward (towards the target), right and up on the screen.

Parameters
[out]a_forwardForward.
[out]a_rightRight.
[out]a_upUp.

◆ horizontal()

template<class T >
void EBGeometry::Render::Camera< T >::horizontal ( Vec3T< T > &  a_first,
Vec3T< T > &  a_second 
) const
inlinenoexcept

Two unit vectors that span the plane perpendicular to the up axis: yaw 90 looks from the first, yaw 0 from the second.

Parameters
[out]a_firstFirst.
[out]a_secondSecond.

◆ lookAt()

template<class T >
static Camera EBGeometry::Render::Camera< T >::lookAt ( const Vec3T< T > &  a_eye,
const Vec3T< T > &  a_target,
const Vec3T< T > &  a_up = Vec3T< T >(T(0), T(1), T(0)),
const T  a_fieldOfView = T(40) 
)
inlinestatic

A camera at a given eye, looking at a given point.

Parameters
[in]a_eyeEye.
[in]a_targetPoint to look at.
[in]a_upUp axis.
[in]a_fieldOfViewVertical field of view, in degrees.
Returns
The camera.

Member Data Documentation

◆ m_orthographic

template<class T >
bool EBGeometry::Render::Camera< T >::m_orthographic = false

Parallel rays instead of rays from the eye: no perspective, so sizes do not shrink with distance.

The view is as tall as the perspective view is at the target (2 m_distance tan(m_fieldOfView / 2)), so switching keeps the target's size, and zooming (a shorter m_distance) narrows it. The rays start behind the shape's box, so that the whole shape is seen however close the eye is; m_nearClip is measured from the plane through the eye.


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