scg3  0.6
Camera.h
Go to the documentation of this file.
1 
9 /*
10  * Copyright 2014-2019 Volker Ahlers
11  *
12  * Licensed under the Apache License, Version 2.0 (the "License");
13  * you may not use this file except in compliance with the License.
14  * You may obtain a copy of the License at
15  *
16  * http://www.apache.org/licenses/LICENSE-2.0
17  *
18  * Unless required by applicable law or agreed to in writing, software
19  * distributed under the License is distributed on an "AS IS" BASIS,
20  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21  * See the License for the specific language governing permissions and
22  * limitations under the License.
23  */
24 
25 #ifndef CAMERA_H_
26 #define CAMERA_H_
27 
28 #include "scg_glew.h"
29 #include "scg_glm.h"
30 #include "scg_internals.h"
31 #include "Transformation.h"
32 
33 namespace scg {
34 
35 
51 class Camera: public Transformation {
52 
53 public:
54 
58  Camera();
59 
63  virtual ~Camera();
64 
68  virtual const glm::mat4& getProjection();
69 
73  virtual const glm::mat4& getViewTransform(RenderState* renderState);
74 
79  virtual void updateProjection() = 0;
80 
84  const glm::vec3& getPosition() const;
85 
90  Camera* setPosition(const glm::vec3& position);
91 
95  const glm::quat& getOrientation() const;
96 
101  Camera* setOrientation(const glm::quat& orientation);
102 
106  const glm::vec3& getViewDirection() const;
107 
111  GLfloat getCenterDist() const;
112 
117  virtual Camera* setMatrix(const glm::mat4& matrix);
118 
123  virtual Camera* translate(glm::vec3 translation);
124 
129  virtual Camera* rotateRad(GLfloat angleRad, glm::vec3 axis);
130 
135  virtual Camera* rotate(GLfloat angleDeg, glm::vec3 axis) {
136  return rotateRad(glm::radians(angleDeg), axis);
137  }
138 
143  virtual Camera* scale(glm::vec3 scaling);
144 
150  Camera* dolly(GLfloat distance);
151 
157  Camera* rotateAzimuthRad(GLfloat angleRad);
158 
164  Camera* rotateAzimuth(GLfloat angleDeg) {
165  return rotateAzimuthRad(glm::radians(angleDeg));
166  }
167 
173  Camera* rotateElevationRad(GLfloat angleRad);
174 
180  Camera* rotateElevation(GLfloat angleDeg) {
181  return rotateElevationRad(glm::radians(angleDeg));
182  }
183 
189  Camera* rotatePitchRad(GLfloat angleRad);
190 
196  Camera* rotatePitch(GLfloat angleDeg) {
197  return rotatePitchRad(glm::radians(angleDeg));
198  }
199 
205  Camera* rotateRollRad(GLfloat angleRad);
206 
212  Camera* rotateRoll(GLfloat angleDeg) {
213  return rotateRollRad(glm::radians(angleDeg));
214  }
215 
221  Camera* rotateYawRad(GLfloat angleRad);
222 
228  Camera* rotateYaw(GLfloat angleDeg) {
229  return rotateYawRad(glm::radians(angleDeg));
230  }
231 
235  bool isDrawCenter() const;
236 
242 
246  void accept(Traverser* traverser);
247 
251  virtual void acceptPost(Traverser* traverser);
252 
257  virtual void render(RenderState* renderState);
258 
262  virtual void renderPost(RenderState* renderState);
263 
264 protected:
265 
269  virtual void update_();
270 
271 protected:
272 
273  glm::mat4 projection_;
274  glm::mat4 viewTransform_;
275  glm::vec3 eyePt_;
276  glm::vec3 centerPt_;
277  GLfloat centerDist_;
278  glm::vec3 viewDir_;
279  glm::vec3 upDir_;
280  glm::vec3 rightDir_;
281  glm::quat orientation_;
283 
284 };
285 
286 
287 } /* namespace scg */
288 
289 #endif /* CAMERA_H_ */
virtual const glm::mat4 & getViewTransform(RenderState *renderState)
glm::vec3 centerPt_
Definition: Camera.h:276
virtual Camera * scale(glm::vec3 scaling)
Base class for all cameras (composite node, abstract).
Definition: Camera.h:51
virtual Camera * translate(glm::vec3 translation)
Local header file for GLM OpenGL Mathematics library.
virtual ~Camera()
Camera * rotateElevationRad(GLfloat angleRad)
virtual void update_()
Camera * setOrientation(const glm::quat &orientation)
Camera * rotateAzimuthRad(GLfloat angleRad)
Camera * rotatePitchRad(GLfloat angleRad)
Camera * setPosition(const glm::vec3 &position)
GLfloat getCenterDist() const
Camera * rotatePitch(GLfloat angleDeg)
Definition: Camera.h:196
virtual const glm::mat4 & getProjection()
glm::vec3 upDir_
Definition: Camera.h:279
glm::quat orientation_
Definition: Camera.h:281
A transformation node to be used to appy a transformation to the sub-tree (composite node).
const glm::vec3 & getViewDirection() const
bool isDrawCenter() const
glm::mat4 projection_
Definition: Camera.h:273
virtual Camera * rotate(GLfloat angleDeg, glm::vec3 axis)
Definition: Camera.h:135
glm::vec3 rightDir_
Definition: Camera.h:280
glm::vec3 viewDir_
Definition: Camera.h:278
Camera * rotateRoll(GLfloat angleDeg)
Definition: Camera.h:212
Base class for all traversers (visitor pattern, abstract).
Definition: Traverser.h:36
Local header file for GLEW library.
Camera * dolly(GLfloat distance)
Camera * rotateAzimuth(GLfloat angleDeg)
Definition: Camera.h:164
const glm::quat & getOrientation() const
Camera * rotateRollRad(GLfloat angleRad)
Camera * rotateElevation(GLfloat angleDeg)
Definition: Camera.h:180
Camera * setDrawCenter(bool isDrawCenter)
Camera * rotateYaw(GLfloat angleDeg)
Definition: Camera.h:228
virtual void updateProjection()=0
virtual void render(RenderState *renderState)
void accept(Traverser *traverser)
The central render state that collects information about the current shader, transformations,...
Definition: RenderState.h:107
const glm::vec3 & getPosition() const
A transformation node to be used to appy a transformation to the sub-tree (composite node).
glm::mat4 viewTransform_
Definition: Camera.h:274
Camera * rotateYawRad(GLfloat angleRad)
Definition: Animation.h:28
virtual Camera * setMatrix(const glm::mat4 &matrix)
virtual void renderPost(RenderState *renderState)
Internal definitions required by most classes.
virtual void acceptPost(Traverser *traverser)
bool isDrawCenter_
Definition: Camera.h:282
GLfloat centerDist_
Definition: Camera.h:277
virtual Camera * rotateRad(GLfloat angleRad, glm::vec3 axis)
glm::vec3 eyePt_
Definition: Camera.h:275