GLC_lib  2.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
glc_camera.h
Go to the documentation of this file.
1 /****************************************************************************
2 
3  This file is part of the GLC-lib library.
4  Copyright (C) 2005-2008 Laurent Ribon (laumaya@users.sourceforge.net)
5  Copyright (C) 2009 Laurent Bauer
6  http://glc-lib.sourceforge.net
7 
8  GLC-lib is free software; you can redistribute it and/or modify
9  it under the terms of the GNU Lesser General Public License as published by
10  the Free Software Foundation; either version 3 of the License, or
11  (at your option) any later version.
12 
13  GLC-lib is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU Lesser General Public License for more details.
17 
18  You should have received a copy of the GNU Lesser General Public License
19  along with GLC-lib; if not, write to the Free Software
20  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 
22 *****************************************************************************/
23 
25 
26 #ifndef GLC_CAMERA_H_
27 #define GLC_CAMERA_H_
28 
29 #include "../glc_object.h"
30 #include "../maths/glc_vector3d.h"
31 #include "../maths/glc_matrix4x4.h"
32 
33 #include "../glc_config.h"
34 
37 
41 
42 
44  public GLC_Object
45 {
47 
49 
50 public:
52 
53  GLC_Camera();
54 
56  /* VectUp and VectCam could not be parallel
57  * VectUp could not be NULL
58  * VectCam could not be NULL */
59  GLC_Camera(const GLC_Point3d &, const GLC_Point3d &, const GLC_Vector3d &);
60 
62  GLC_Camera(const GLC_Camera&);
64 
66 
68 
69 public:
71  inline double distEyeTarget(void) const
72  {return (m_Eye - m_Target).length();}
73 
75  inline GLC_Point3d eye(void) const
76  {return m_Eye;}
77 
79  inline GLC_Point3d target(void) const
80  {return m_Target;}
81 
83  inline GLC_Vector3d upVector(void) const
84  {return m_VectUp;}
85 
87  inline GLC_Vector3d forward(void) const
88  {return m_Target - m_Eye;}
89 
91  inline GLC_Vector3d sideVector() const
92  {return ((m_Target - m_Eye).normalize() ^ m_VectUp).normalize();}
93 
95  inline GLC_Matrix4x4 viewMatrix(void) const
96  {return m_ModelViewMatrix;}
97 
99  bool operator==(const GLC_Camera&) const;
100 
102  bool isAlmostEqualTo(const GLC_Camera&, const double distanceAccuracy=0.05) const;
103 
105  inline GLC_Vector3d defaultUpVector() const
106  {return m_DefaultVectUp;}
107 
109  GLC_Camera frontView() const;
110 
112  GLC_Camera rearView() const;
113 
115  GLC_Camera rightView() const;
116 
118  GLC_Camera leftView() const;
119 
121  GLC_Camera topView() const;
122 
124  GLC_Camera bottomView() const;
125 
127 
128  GLC_Camera isoView() const;
129 
131  inline GLC_Matrix4x4 modelViewMatrix() const
132  {
133  GLC_Matrix4x4 translate(-m_Eye);
134  GLC_Matrix4x4 modelView= GLC_Matrix4x4(m_ModelViewMatrix * translate);
135  return modelView;
136  }
137 
139 
141 
143 
144 public:
146  GLC_Camera& orbit(GLC_Vector3d VectOldPoss, GLC_Vector3d VectCurPoss);
147 
149  GLC_Camera& pan(GLC_Vector3d VectDep);
150 
152 
153  GLC_Camera& zoom(double factor);
154 
156  GLC_Camera& move(const GLC_Matrix4x4 &MatMove);
157 
159  GLC_Camera& rotateAround(const GLC_Vector3d&, const double&, const GLC_Point3d&);
160 
162  GLC_Camera& rotateAroundTarget(const GLC_Vector3d&, const double&);
163 
165  GLC_Camera& translate(const GLC_Vector3d &VectTrans);
166 
168  /* VectUp and VectCam could not be parallel
169  * VectUp could not be NULL
170  * VectCam could not be NULL */
171  GLC_Camera& setCam(GLC_Point3d Eye, GLC_Point3d Target, GLC_Vector3d Up);
172 
174  GLC_Camera& setCam(const GLC_Camera&);
175 
177  GLC_Camera& setEyeCam(const GLC_Point3d &Eye);
178 
180  GLC_Camera& setTargetCam(const GLC_Point3d &Target);
181 
183  GLC_Camera& setUpCam(const GLC_Vector3d &Up);
184 
186  GLC_Camera& setDistEyeTarget(double Longueur);
187 
189  GLC_Camera& setDistTargetEye(double Longueur);
190 
193 
195 
196  inline GLC_Camera& setDefaultUpVector(const GLC_Vector3d& up)
197  {
198  Q_ASSERT((up == glc::X_AXIS) || (up == glc::Y_AXIS) || (up == glc::Z_AXIS));
199  m_DefaultVectUp= up;
200  return *this;
201  }
202 
204  inline void setFrontView()
205  {setCam(frontView());}
206 
208  inline void setRearView()
209  {setCam(rearView());}
210 
212  inline void setRightView()
213  {setCam(rightView());}
214 
216  inline void setLeftView()
217  {setCam(leftView());}
218 
220  inline void setTopView()
221  {setCam(topView());}
222 
224  inline void setBottomView()
225  {setCam(bottomView());}
226 
228 
229  inline void setIsoView()
230  {setCam(isoView());}
231 
233 
235 
237 
238 public:
240  void glExecute();
241 
243 
245 // Private services Functions
247 private:
249  void createMatComp(void);
250 
251 
253 // Private Member
255 private:
258 
261 
264 
267 
270 };
271 #endif //GLC_CAMERA_H_

©2005-2013 Laurent Ribon