BALL  1.5.0
camera.h
Go to the documentation of this file.
1 #ifndef BALL_VIEW_RENDERING_CAMERA_H
2 #define BALL_VIEW_RENDERING_CAMERA_H
3 
4 #ifndef BALL_COMMON_GLOBAL_H
5  #include <BALL/COMMON/global.h>
6 #endif
7 
8 #ifndef BALL_MATHS_VECTOR3_H
9  #include <BALL/MATHS/vector3.h>
10 #endif
11 
12 #ifndef BALL_MATHS_QUATERNION_H
13  #include <BALL/MATHS/quaternion.h>
14 #endif
15 
16 namespace BALL
17 {
18  namespace VIEW
19  {
24  {
25  public:
28  {
29  PERSPECTIVE = 0,
30  ORTHOGRAPHIC
31  };
32 
36 
38  Camera();
39 
41  Camera(const Camera& camera);
42 
43  Camera(const Vector3& view_point, const Vector3& look_at, const Vector3& look_up_vector, const ProjectionMode& mode = PERSPECTIVE);
44 
46  virtual ~Camera(){}
47 
49  Camera& operator = (const Camera& camera);
50 
52 
55 
57  void moveRight(float translation)
58  { view_point_ += right_vector_*translation; look_at_ += right_vector_*translation; }
59 
61  void moveUp(float translation)
62  { view_point_ += look_up_vector_*translation; look_at_ += look_up_vector_*translation; }
63 
65  void moveForward(float translation)
66  {
67  Vector3 normal_view_vector(view_vector_);
68  normal_view_vector.normalize();
69  view_point_ += normal_view_vector*translation;
70  look_at_ += normal_view_vector*translation;
71  }
72 
74  const Vector3& getViewPoint() const
75  { return view_point_;}
76 
78  void setViewPoint(const Vector3& view_point)
79  { view_point_ = view_point; calculateVectors_();}
80 
82  const Vector3& getLookAtPosition() const
83  { return look_at_;}
84 
86  void setLookAtPosition(const Vector3& look_at)
87  { look_at_ = look_at; calculateVectors_();}
88 
90  const Vector3& getLookUpVector() const
91  { return look_up_vector_;}
92 
94  void setLookUpVector(const Vector3& look_up_vector)
95  { look_up_vector_ = look_up_vector; calculateVectors_();}
96 
98  void rotateAboutView(float degree);
99 
101  float getDistance() const
102  { return view_point_.getDistance(look_at_);}
103 
106  { return view_vector_;}
107 
110  { return right_vector_;}
111 
113  void translate(const Vector3& v);
114 
117 
119  void rotate(const Quaternion& q, const Vector3& origin);
120 
122  void rotate(const Matrix4x4& mat, const Vector3& origin);
123 
125  virtual void clear()
126  { *this = Camera();}
127 
130  { projection_mode_ = mode; }
131 
134  { return projection_mode_; }
135 
137  String toString() const;
138 
140  bool readFromString(const String& data);
141 
143 
146 
148  bool operator == (const Camera& camera) const;
149 
151  bool operator < (const Camera& camera) const;
152 
154 
161  virtual void dump(std::ostream& s = std::cout, Size depth = 0) const;
162 
163  protected:
164  //_
166 
167  //_
169 
170  //_
172 
173  //_
175 
176  /*_ The viewing vector.
177  Stored only for better performance in the scene.
178  */
180 
181  /*_ The orthogonal vector to the viewing vector, which is showing to the right.
182  Stored only for better performance in the scene.
183  */
185 
186  /* The projection mode used by this camera.
187  */
189  };
190 
191  } // namespace VIEW
192 } // namespace BALL
193 
194 #endif //BALL_VIEW_RENDERING_CAMERA_H
BALL::VIEW::Camera::~Camera
virtual ~Camera()
Destructor.
Definition: camera.h:46
global.h
BALL::VIEW::Camera::Camera
Camera()
Constructor.
BALL::VIEW::Camera::setLookAtPosition
void setLookAtPosition(const Vector3 &look_at)
Set the direction of the camera.
Definition: camera.h:86
BALL::VIEW::Camera::moveForward
void moveForward(float translation)
Move the camera along the view vector.
Definition: camera.h:65
BALL::VIEW::Camera::rotateAboutView
void rotateAboutView(float degree)
Rotate up and right around the view vector.
BALL::VIEW::Camera::moveUp
void moveUp(float translation)
Move the camera along the up vector.
Definition: camera.h:61
BALL::VIEW::Camera::view_vector_
Vector3 view_vector_
Definition: camera.h:179
vector3.h
BALL::operator<
BALL_EXPORT bool operator<(const String &s1, const String &s2)
BALL::VIEW::Camera::rotate
void rotate(const Matrix4x4 &mat, const Vector3 &origin)
Rotate the camera.
BALL::VIEW::Camera::translate
void translate(const Vector3 &v)
Translate the view point and the point the camera is looking to by a given vector.
BALL::VIEW::Camera::getViewVector
Vector3 getViewVector() const
Get the view vector.
Definition: camera.h:105
BALL::VIEW::Camera
Definition: camera.h:24
BALL::TMatrix4x4< float >
BALL::VIEW::Camera::projection_mode_
ProjectionMode projection_mode_
Definition: camera.h:188
BALL::VIEW::Camera::clear
virtual void clear()
Reset Camera to standard values.
Definition: camera.h:125
BALL::VIEW::Camera::getLookUpVector
const Vector3 & getLookUpVector() const
Get the look up vector.
Definition: camera.h:90
BALL::String
Definition: string.h:57
BALL::TVector3::normalize
TVector3 & normalize()
Definition: vector3.h:770
BALL::VIEW::Camera::view_point_
Vector3 view_point_
Definition: camera.h:168
BALL::VIEW::Camera::right_vector_
Vector3 right_vector_
Definition: camera.h:184
BALL
Definition: constants.h:13
BALL::VIEW::Camera::Camera
Camera(const Vector3 &view_point, const Vector3 &look_at, const Vector3 &look_up_vector, const ProjectionMode &mode=PERSPECTIVE)
quaternion.h
BALL::VIEW::Camera::Camera
Camera(const Camera &camera)
Copy Constructor.
BALL::VIEW::Camera::moveRight
void moveRight(float translation)
Move the camera along the right vector.
Definition: camera.h:57
BALL::VIEW::Camera::calculateVectors_
void calculateVectors_()
BALL::VIEW::Camera::getViewPoint
const Vector3 & getViewPoint() const
Get the position of the camera.
Definition: camera.h:74
BALL::VIEW::Camera::getDistance
float getDistance() const
Get the distance between the view point and the look at point.
Definition: camera.h:101
BALL::VIEW::Camera::dump
virtual void dump(std::ostream &s=std::cout, Size depth=0) const
BALL_SIZE_TYPE
BALL::VIEW::Camera::getRightVector
Vector3 getRightVector() const
Get an vector orthogonal to the viewing vector and showing to the right.
Definition: camera.h:109
BALL::TVector3< float >
BALL_VIEW_EXPORT
#define BALL_VIEW_EXPORT
Definition: COMMON/global.h:52
BALL::VIEW::Camera::setProjectionMode
void setProjectionMode(ProjectionMode const &mode)
Set the projection mode.
Definition: camera.h:129
BALL::VIEW::Camera::rotate
void rotate(const Quaternion &q, const Vector3 &origin)
Rotate the camera.
BALL::VIEW::Camera::ProjectionMode
ProjectionMode
Enumeration of different projection modes.
Definition: camera.h:28
BALL::TQuaternion< float >
BALL::VIEW::Camera::setViewPoint
void setViewPoint(const Vector3 &view_point)
Set the position of the camera.
Definition: camera.h:78
BALL::VIEW::Camera::setLookUpVector
void setLookUpVector(const Vector3 &look_up_vector)
Set the look up vector and compute the new right vector.
Definition: camera.h:94
BALL::VIEW::Camera::getLookAtPosition
const Vector3 & getLookAtPosition() const
Get the direction of the camera.
Definition: camera.h:82
BALL::VIEW::Camera::getProjectionMode
ProjectionMode getProjectionMode() const
Get the projection mode.
Definition: camera.h:133
BALL::operator==
BALL_EXPORT bool operator==(const String &s1, const String &s2)
BALL::VIEW::Camera::readFromString
bool readFromString(const String &data)
BALL::VIEW::Camera::toString
String toString() const
BALL::VIEW::Camera::look_at_
Vector3 look_at_
Definition: camera.h:171
BALL::VIEW::Camera::convertCameraToSceneCoordinates
Vector3 convertCameraToSceneCoordinates(const Vector3 &v)
Convert the given vector from camera system to cartesian coordinates.
BALL::VIEW::Camera::look_up_vector_
Vector3 look_up_vector_
Definition: camera.h:174