BALL  1.4.79
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
116  Vector3 convertCameraToSceneCoordinates(const Vector3& v);
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  //_
165  void calculateVectors_();
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
ProjectionMode projection_mode_
Definition: camera.h:188
const Vector3 & getLookAtPosition() const
Get the direction of the camera.
Definition: camera.h:82
TVector3 & normalize()
Definition: vector3.h:770
virtual ~Camera()
Destructor.
Definition: camera.h:46
Vector3 getViewVector() const
Get the view vector.
Definition: camera.h:105
const Vector3 & getViewPoint() const
Get the position of the camera.
Definition: camera.h:74
void moveForward(float translation)
Move the camera along the view vector.
Definition: camera.h:65
Vector3 look_up_vector_
Definition: camera.h:174
Vector3 view_point_
Definition: camera.h:168
const Vector3 & getLookUpVector() const
Get the look up vector.
Definition: camera.h:90
Vector3 getRightVector() const
Get an vector orthogonal to the viewing vector and showing to the right.
Definition: camera.h:109
void setProjectionMode(ProjectionMode const &mode)
Set the projection mode.
Definition: camera.h:129
void setLookAtPosition(const Vector3 &look_at)
Set the direction of the camera.
Definition: camera.h:86
#define BALL_VIEW_EXPORT
Definition: COMMON/global.h:52
Vector3 look_at_
Definition: camera.h:171
ProjectionMode getProjectionMode() const
Get the projection mode.
Definition: camera.h:133
ProjectionMode
Enumeration of different projection modes.
Definition: camera.h:27
float getDistance() const
Get the distance between the view point and the look at point.
Definition: camera.h:101
Vector3 view_vector_
Definition: camera.h:179
BALL_EXPORT bool operator==(const String &s1, const String &s2)
void setViewPoint(const Vector3 &view_point)
Set the position of the camera.
Definition: camera.h:78
void moveUp(float translation)
Move the camera along the up vector.
Definition: camera.h:61
void setLookUpVector(const Vector3 &look_up_vector)
Set the look up vector and compute the new right vector.
Definition: camera.h:94
Vector3 right_vector_
Definition: camera.h:184
void moveRight(float translation)
Move the camera along the right vector.
Definition: camera.h:57
virtual void clear()
Reset Camera to standard values.
Definition: camera.h:125
BALL_EXPORT bool operator<(const String &s1, const String &s2)