V-ART
camera.h
Go to the documentation of this file.
1 
5 #ifndef VART_CAMERA_H
6 #define VART_CAMERA_H
7 
8 #include "vart/point4d.h"
9 #include <string> //STL include
10 
11 namespace VART {
16  class Camera {
17  friend std::ostream& operator<<(std::ostream& output, const Camera& cam);
18  public:
20 
21  Camera();
22 
30  Camera(const Point4D& position, const Point4D& focus, const Point4D& upVec);
31 
32  Camera(const Camera& cam);
33 
34  Camera& operator=(const Camera& cam);
35 
37  const std::string& GetDescription() const { return description; }
38 
40  void SetDescription(const std::string& descriptionValue);
41 
44 
46  void SetProjectionType(ProjectionType newValue) { projectionType = newValue; }
47 
49  float GetAspectRatio() const { return aspectRatio; }
50 
52  void SetAspectRatio(float newAR) { aspectRatio = newAR; }
53 
55  float GetNearPlaneDistance() const { return nearPlaneDistance; }
56 
58  void SetNearPlaneDistance(float newValue) { nearPlaneDistance = newValue; }
59 
61  float GetFarPlaneDistance() const { return farPlaneDistance; }
62 
64  void SetFarPlaneDistance(float newValue) { farPlaneDistance = newValue; }
65 
67  float GetFovY() const;
68 
70  void SetFovY(float f);
71 
73  Point4D GetLocation() const;
74 
76  void SetLocation(const Point4D& locationValue);
77 
79  Point4D GetTarget() const;
80 
82  void SetTarget(const Point4D& targetValue);
83 
85  Point4D GetUp() const;
86 
88  void LeftVector(Point4D* resultPtr) const;
89 
91  void FrontVector(Point4D* resultPtr) const;
92 
94  void SetUp(const Point4D& upValue);
95 
97  void SetVisibleVolumeHLimits(double left, double right)
98  { vvLeft = left; vvRight = right; }
99 
101  void SetVisibleVolumeVLimits(double top, double bottom)
102  { vvTop = top; vvBottom = bottom; }
103 
106  const double GetVisibleVolumeLeftLimit() const { return vvLeft; }
107 
110  const double GetVisibleVolumeRightLimit() const { return vvRight; }
111 
114  const double GetVisibleVolumeTopLimit() const { return vvTop; }
115 
118  const double GetVisibleVolumeBottomLimit() const { return vvBottom; }
119 
125  void SetVisibleVolumeHeight(double newValue);
126 
131  void ScaleVisibleVolume(float horScale, float verScale);
132 
134  void YawAroundTarget(float radians);
136  void Yaw(float radians);
138  void Roll(float radians);
140  void PitchAroundTarget(float radians);
142  void MoveForward(double distance);
144  void MoveSideways(double distance);
146  void MoveUp(double distance);
147 
150  bool DrawOGL() const;
151 
157  void SetMatrices() const;
158 
159  protected:
163  float fovY;
165  float aspectRatio;
170 
173  double vvLeft;
176  double vvRight;
179  double vvTop;
182  double vvBottom;
183 
189  //FixMe: Should be kept orthogonal to (target-location).
191  private:
192  std::string description;
193  }; // end class declaration
194 } // end namespace
195 #endif // VART_CAMERA_H
void MoveForward(double distance)
Moves the camera forward (relative to the camera).
Definition: camera.cpp:241
float GetFovY() const
Returns the vertical field of view (in degrees).
Definition: camera.cpp:173
const std::string & GetDescription() const
Gets the description associated with the camera.
Definition: camera.h:37
void SetAspectRatio(float newAR)
Sets the camera's width/height ratio.
Definition: camera.h:52
float GetAspectRatio() const
Gets the camera's width/height ratio.
Definition: camera.h:49
void SetMatrices() const
Loads camera transform into rendering engine.
Definition: camera.cpp:297
float GetFarPlaneDistance() const
Returns the distance to the far plane.
Definition: camera.h:61
Point4D location
Position where the camera is at.
Definition: camera.h:185
Points and vectors using homogeneous coordinates.
Definition: point4d.h:22
void Roll(float radians)
Rolls the Camera around itself.
Definition: camera.cpp:221
float fovY
Vertical angle of frustum. Used if projectionType == PERSPECTIVE.
Definition: camera.h:163
friend std::ostream & operator<<(std::ostream &output, const Camera &cam)
void SetDescription(const std::string &descriptionValue)
Sets the description associated with the camera.
Definition: camera.cpp:96
void LeftVector(Point4D *resultPtr) const
Computes the vector pointing left.
Definition: camera.cpp:181
void ScaleVisibleVolume(float horScale, float verScale)
Scales the visible volume.
Definition: camera.cpp:202
const double GetVisibleVolumeBottomLimit() const
Gets the coordinates of the orthographic view volume.
Definition: camera.h:118
Point4D GetTarget() const
Returns the camera target (where it is looking at).
Definition: camera.cpp:157
void SetProjectionType(ProjectionType newValue)
Sets the projection type (PERSPECTIVE/ORTHOGRAPHIC).
Definition: camera.h:46
const double GetVisibleVolumeLeftLimit() const
Gets the coordinates of the orthographic view volume.
Definition: camera.h:106
float farPlaneDistance
Distance to far plane.
Definition: camera.h:169
void SetTarget(const Point4D &targetValue)
Sets the camera target (where it is looking at).
Definition: camera.cpp:161
void SetUp(const Point4D &upValue)
Sets the camera up vector.
Definition: camera.cpp:169
void SetFovY(float f)
Sets the vertical field of view (in degrees).
Definition: camera.cpp:177
bool DrawOGL() const
Positions a camera using OpenGL commands.
Definition: camera.cpp:276
Virtual camera.
Definition: camera.h:16
void YawAroundTarget(float radians)
Rotates the Camera around the axis defined by the target and up vector.
Definition: camera.cpp:209
void SetLocation(const Point4D &locationValue)
Sets the camera location.
Definition: camera.cpp:153
Point4D up
Up direction, relative to the camera.
Definition: camera.h:190
ProjectionType GetProjectionType() const
Gets the projection type (PERSPECTIVE/ORTHOGRAPHIC).
Definition: camera.h:43
void Yaw(float radians)
Rotates the Camera around itself (location and up vector).
Definition: camera.cpp:215
Point4D GetUp() const
Returns the camera up vector.
Definition: camera.cpp:165
void MoveUp(double distance)
Moves the camera up and down.
Definition: camera.cpp:265
void SetVisibleVolumeVLimits(double top, double bottom)
Sets the vertical limit coordinates of the orthographic view volume.
Definition: camera.h:101
const double GetVisibleVolumeTopLimit() const
Gets the coordinates of the orthographic view volume.
Definition: camera.h:114
ProjectionType
Definition: camera.h:19
void SetVisibleVolumeHeight(double newValue)
Sets the visible volume by given height.
Definition: camera.cpp:193
double vvRight
Visible Volume right coordinate (in world coordinates). Used if projectionType is ORTHOGRAPHIC...
Definition: camera.h:176
void SetVisibleVolumeHLimits(double left, double right)
Sets the horizontal limit coordinates of the orthographic view volume.
Definition: camera.h:97
Header file for V-ART class "Point4D".
void PitchAroundTarget(float radians)
Rotates the Camera around the axis defined by the target and left vector.
Definition: camera.cpp:230
void MoveSideways(double distance)
Moves the camera sideways.
Definition: camera.cpp:251
double vvBottom
Visible Volume bottom coordinate (in world coordinates). Used if projectionType is ORTHOGRAPHIC...
Definition: camera.h:182
float aspectRatio
Viewing aspect ratio (width/height).
Definition: camera.h:165
Camera & operator=(const Camera &cam)
Definition: camera.cpp:78
float GetNearPlaneDistance() const
Returns the distance to the near plane.
Definition: camera.h:55
void SetNearPlaneDistance(float newValue)
Sets the distance to the near plane.
Definition: camera.h:58
Point4D GetLocation() const
Returns the camera location (its position).
Definition: camera.cpp:149
Point4D target
Position where the camera is looking at.
Definition: camera.h:187
float nearPlaneDistance
Distance to near plane.
Definition: camera.h:167
double vvTop
Visible Volume top coordinate (in world coordinates). Used if projectionType is ORTHOGRAPHIC.
Definition: camera.h:179
double vvLeft
Visible Volume left coordinate (in world coordinates). Used if projectionType is ORTHOGRAPHIC.
Definition: camera.h:173
void FrontVector(Point4D *resultPtr) const
Computes the vector pointing ahead.
Definition: camera.cpp:187
ProjectionType projectionType
Indicates whether a perspective ou orthographic projection should be used.
Definition: camera.h:161
void SetFarPlaneDistance(float newValue)
Sets the distance to the far plane distance.
Definition: camera.h:64
const double GetVisibleVolumeRightLimit() const
Gets the coordinates of the orthographic view volume.
Definition: camera.h:110