Magnum::Trade::CameraData class

Camera data.

Constructors, destructors, conversion operators

CameraData(CameraType type, Rad fov, Float aspectRatio, Float near, Float far, const void* importerState = nullptr) explicit noexcept
Construct a camera using a field of view.
CameraData(CameraType type, const Vector2& size, Float near, Float far, const void* importerState = nullptr) explicit noexcept
Construct a camera using a projection size.
CameraData(Rad fov, Float near, Float far, const void* importerState = nullptr) deprecated explicit noexcept
Construct a camera using a field of view.
CameraData(const CameraData&) deleted
Copying is not allowed.
CameraData(CameraData&&) noexcept defaulted
Move constructor.

Public functions

auto operator=(const CameraData&) -> CameraData& deleted
Copying is not allowed.
auto operator=(CameraData&&) noexcept -> CameraData& defaulted
Move assignment.
auto type() const -> CameraType
Camera type.
auto size() const -> Vector2
Size of the near clipping plane.
auto fov() const -> Rad
Field-of-view angle.
auto aspectRatio() const -> Float
Aspect ratio.
auto near() const -> Float
Near clipping plane.
auto far() const -> Float
Far clipping plane.
auto importerState() const -> const void*
Importer-specific state.

Function documentation

Magnum::Trade::CameraData::CameraData(CameraType type, Rad fov, Float aspectRatio, Float near, Float far, const void* importerState = nullptr) explicit noexcept

Construct a camera using a field of view.

Parameters
type Camera type
fov Horizontal field-of-view angle $ \theta $
aspectRatio Horizontal:vertical aspect ratio $ a $
near Near clipping plane $ n $
far Far clipping plane $ f $ . Set to Constants::inf() for an infinite far plane.
importerState Importer-specific state

The constructor converts the fov and aspectRatio to near plane size using the following formula and stores that:

\[ \boldsymbol{s} = 2n \tan \left(\tfrac{\theta}{2} \right) \begin{pmatrix} 1 \\ \frac{1}{a} \end{pmatrix} \]

The type parameter has to be CameraType::Perspective3D, use CameraData(CameraType, const Vector2&, Float, Float, const void*) for orthographic and 2D cameras instead.

Magnum::Trade::CameraData::CameraData(CameraType type, const Vector2& size, Float near, Float far, const void* importerState = nullptr) explicit noexcept

Construct a camera using a projection size.

Parameters
type Camera type
size Size of the near clipping plane
near Near clipping plane
far Far clipping plane. Set to Constants::inf() for an infinite far plane.
importerState Importer-specific state

For CameraType::Orthographic2D, near and far is expected to be 0.0f.

Magnum::Trade::CameraData::CameraData(Rad fov, Float near, Float far, const void* importerState = nullptr) explicit noexcept

Construct a camera using a field of view.

Vector2 Magnum::Trade::CameraData::size() const

Size of the near clipping plane.

For CameraType::Perspective3D, this property is also available through fov() and aspectRatio().

Rad Magnum::Trade::CameraData::fov() const

Field-of-view angle.

Expects that type() is CameraType::Perspective3D. The value is calculated from size() using the following formula:

\[ \theta = 2 \arctan \left( \frac{s_x}{2n} \right) \]

Float Magnum::Trade::CameraData::aspectRatio() const

Aspect ratio.

Similarly to fov(), the value is calculated from size().

Float Magnum::Trade::CameraData::far() const

Far clipping plane.

Can be set to infinity, in which case it denotes a lack of far clipping plane.

const void* Magnum::Trade::CameraData::importerState() const

Importer-specific state.

See AbstractImporter::importerState() for more information.