Cafu Engine
Camera.hpp
1 /*
2 Cafu Engine, http://www.cafu.de/
3 Copyright (c) Carsten Fuchs and other contributors.
4 This project is licensed under the terms of the MIT license.
5 */
6 
7 #ifndef CAFU_CAMERA_HPP_INCLUDED
8 #define CAFU_CAMERA_HPP_INCLUDED
9 
10 #include "Math3D/Angles.hpp"
11 #include "Math3D/Matrix.hpp"
12 
13 
14 /// This class implements a camera. Cameras are associated with the 3D views and controlled with the Camera tool.
15 /// A camera is represented by an orthogonal, right-handed coordinate system,
16 /// where the x-axis points right, the y-axis points forward (the viewing direction) and the z-axis points up.
17 class CameraT
18 {
19  public:
20 
21  CameraT();
22 
23  Vector3fT GetXAxis() const; ///< Returns the x-axis (pointing right) of the camera space.
24  Vector3fT GetYAxis() const; ///< Returns the y-axis (pointing forward) of the camera space. This is the direction the camera is looking into!
25  Vector3fT GetZAxis() const; ///< Returns the z-axis (pointing up) of the camera space.
26  const MatrixT& GetMatrix() const; ///< Returns the matrix that represents the position and orientation of this camera.
27 
28  void SetLookAtPos(const Vector3fT& LookAtPos); ///< This method automatically computes the orientation of the camera so that it looks at the given point.
29  void LimitAngles(); ///< This method wraps the yaw into the [0°, 360°[ intervall and clamps the pitch to -90° and +90°. Call this method after each manipulation of the angles!
30 
31 
32  // Regular members that define the essential properties of the camera.
33  Vector3fT Pos; ///< The cameras position in the world.
34  cf::math::AnglesfT Angles; ///< The angles that describe the cameras orientation. The pitch value is limited/clamped to the interval from -90° to +90°, and roll is not used at all.
35  float ViewDirLength; ///< This member defines how long the view direction vector (GetYAxis()) is drawn in the 2D views.
36 
37  // Additional members that augment the definition of the cameras view pyramid (frustum).
38  float VerticalFOV; ///< The cameras field-of-view angle, in vertical (up/down) direction.
39  float NearPlaneDist; ///< The distance of the near clip plane to the tip of the view pyramid.
40  float FarPlaneDist; ///< The distance of the far clip plane to the tip of the view pyramid.
41 
42 
43  private:
44 
45  mutable Vector3fT m_MatrixPos; ///< The position with which the m_Matrix was built.
46  mutable cf::math::AnglesfT m_MatrixAngles; ///< The angles with which the m_Matrix was built.
47  mutable MatrixT m_Matrix; ///< The matrix that transforms from world to camera space.
48 };
49 
50 #endif
void LimitAngles()
This method wraps the yaw into the [0°, 360°[ intervall and clamps the pitch to -90° and +90°...
Definition: Camera.cpp:87
void SetLookAtPos(const Vector3fT &LookAtPos)
This method automatically computes the orientation of the camera so that it looks at the given point...
Definition: Camera.cpp:67
This class implements a camera.
Definition: Camera.hpp:17
Vector3fT GetZAxis() const
Returns the z-axis (pointing up) of the camera space.
Definition: Camera.cpp:43
Vector3fT GetYAxis() const
Returns the y-axis (pointing forward) of the camera space. This is the direction the camera is lookin...
Definition: Camera.cpp:35
float FarPlaneDist
The distance of the far clip plane to the tip of the view pyramid.
Definition: Camera.hpp:40
Vector3fT Pos
The cameras position in the world.
Definition: Camera.hpp:33
float VerticalFOV
The cameras field-of-view angle, in vertical (up/down) direction.
Definition: Camera.hpp:38
cf::math::AnglesfT Angles
The angles that describe the cameras orientation. The pitch value is limited/clamped to the interval ...
Definition: Camera.hpp:34
Vector3fT GetXAxis() const
Returns the x-axis (pointing right) of the camera space.
Definition: Camera.cpp:27
float NearPlaneDist
The distance of the near clip plane to the tip of the view pyramid.
Definition: Camera.hpp:39
const MatrixT & GetMatrix() const
Returns the matrix that represents the position and orientation of this camera.
Definition: Camera.cpp:51
float ViewDirLength
This member defines how long the view direction vector (GetYAxis()) is drawn in the 2D views...
Definition: Camera.hpp:35