Omnidome
Fulldome Mapping Software Toolkit
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CameraInterface.h
Go to the documentation of this file.
1 /* Copyright (c) 2014-2016 "Omnidome" by cr8tr
2  * Dome Mapping Projection Software (http://omnido.me).
3  * Omnidome was created by Michael Winkelmann aka Wilston Oreo (@WilstonOreo)
4  *
5  * This file is part of Omnidome.
6  *
7  * Omnidome is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Affero General Public License as
9  * published by the Free Software Foundation, either version 3 of the
10  * License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU Affero General Public License for more details.
16  * You should have received a copy of the GNU Affero General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef OMNI_VISUAL_CAMERAINTERFACE_H_
21 #define OMNI_VISUAL_CAMERAINTERFACE_H_
22 
23 #include <QOpenGLFunctions>
24 #include "Tracker.h"
25 
26 namespace omni {
27  namespace visual {
28  /// A generic camera interface
29  class CameraInterface : public Tracker
30  {
31  public:
33  CameraInterface(const Tracker& _tracker,
34  qreal _near = 0.1,
35  qreal _far = 1000.0,
36  const QVector3D& _up = QVector3D(0.0, 0.0, 1.0));
37 
38  /// Right vector
39  QVector3D right() const;
40 
41  /// Move camera to the right (or to the left if value is negative)
42  void strafe(qreal _right);
43 
44  /// Move camera upwards (or downwards if value is negative)
45  void lift(qreal _up);
46 
47  /// Camera orientation
48  QVector3D up() const;
49  void setUp(QVector3D const&);
50 
51  /// Camera's near plane
52  qreal near() const;
53  void setNear(qreal);
54 
55  /// Camera's far plane
56  qreal far() const;
57  void setFar(qreal);
58 
59  /// Setup perspective camera in OpenGL
60  virtual void setup(qreal _aspect) const = 0;
61 
62  /// Deserialize from stream
63  void fromStream(QDataStream&);
64 
65  /// Serialize to stream
66  void toStream(QDataStream&) const;
67 
68  /// Test for equality. ScreenSetup is ignored
69  friend bool operator==(CameraInterface const&,
70  CameraInterface const&);
71 
72  /// Expose field of field
73  inline virtual qreal fov() const {
74  return 0.0;
75  }
76 
77  inline virtual void setFov(qreal _fov) {
78  }
79 
80  private:
81  /// camera orientation
82  QVector3D up_;
83 
84  /// Near plane
85  qreal near_ = 0.1;
86 
87  /// Far plane
88  qreal far_ = 1000.0;
89  };
90  }
91 }
92 
94 
95 #endif /* OMNI_VISUAL_CAMERAINTERFACE_H_ */
A generic camera interface.
Definition: CameraInterface.h:29
void setUp(QVector3D const &)
Definition: CameraInterface.cpp:62
QVector3D up_
camera orientation
Definition: CameraInterface.h:82
virtual void setFov(qreal _fov)
Definition: CameraInterface.h:77
virtual void setup(qreal _aspect) const =0
Setup perspective camera in OpenGL.
#define OMNI_DECL_STREAM_OPERATORS(CLASS)
Definition: Interface.h:53
QVector3D up() const
Camera orientation.
Definition: CameraInterface.cpp:57
void lift(qreal _up)
Move camera upwards (or downwards if value is negative)
Definition: CameraInterface.cpp:50
void setFar(qreal)
Definition: CameraInterface.cpp:82
QVector3D right() const
Right vector.
Definition: CameraInterface.cpp:40
qreal far_
Far plane.
Definition: CameraInterface.h:88
friend bool operator==(CameraInterface const &, CameraInterface const &)
Test for equality. ScreenSetup is ignored.
Definition: CameraInterface.cpp:100
Definition: Tracker.h:27
qreal far() const
Camera's far plane.
Definition: CameraInterface.cpp:77
void toStream(QDataStream &) const
Serialize to stream.
Definition: CameraInterface.cpp:94
qreal near_
Near plane.
Definition: CameraInterface.h:85
void fromStream(QDataStream &)
Deserialize from stream.
Definition: CameraInterface.cpp:88
CameraInterface()
Definition: CameraInterface.cpp:26
void setNear(qreal)
Definition: CameraInterface.cpp:72
virtual qreal fov() const
Expose field of field.
Definition: CameraInterface.h:73
void strafe(qreal _right)
Move camera to the right (or to the left if value is negative)
Definition: CameraInterface.cpp:45
qreal near() const
Camera's near plane.
Definition: CameraInterface.cpp:67