ARGoS  3
A parallel, multi-engine simulator for swarm robotics
qtopengl_camera.h
Go to the documentation of this file.
1 
7 #ifndef QTOPENGL_CAMERA_H
8 #define QTOPENGL_CAMERA_H
9 
10 namespace argos {
11  class CQTOpenGLCamera;
12 }
13 
14 class QPoint;
15 
16 #include <QObject>
17 #include <argos3/core/utility/datatypes/datatypes.h>
18 #include <argos3/core/utility/math/ray3.h>
19 #include <argos3/core/utility/configuration/argos_configuration.h>
20 
21 #ifdef __APPLE__
22 #include <gl.h>
23 #include <glu.h>
24 #else
25 #include <GL/gl.h>
26 #include <GL/glu.h>
27 #endif
28 
29 namespace argos {
30 
31  class CQTOpenGLCamera : public QObject {
32 
33  Q_OBJECT
34 
35  public:
36 
37  struct SSettings {
56 
58  Position(-2.0f, 0.0f, 2.0f),
59  Left(CVector3::Y),
60  Up(CVector3(1.0f, 0.0f, 1.0f).Normalize()),
61  Forward(CVector3(1.0f, 0.0f, -1.0f).Normalize()),
62  Target(),
63  LensFocalLength(0.02f),
64  MotionSensitivity(0.005),
65  RotationSensitivity(0.01) {
67  }
68 
70  void Init(TConfigurationNode& t_tree);
72  void RotateUpDown(const CRadians& c_angle);
74  void RotateLeftRight(const CRadians& c_angle);
76  void RotateLeftRight2(const CRadians& c_angle);
78  void Translate(const CVector3& c_delta);
80  void Do();
82  void CalculateYFieldOfView();
84  void CalculateSensitivity();
85  };
86 
87  public:
88 
91 
92  void Init(TConfigurationNode& t_tree);
93 
94  inline void Look() {
95  m_sSettings[m_unActiveSettings].Do();
96  }
97 
98  inline const CVector3& GetPosition() const {
99  return m_sSettings[m_unActiveSettings].Position;
100  }
101 
102  inline const CVector3& GetTarget() const {
103  return m_sSettings[m_unActiveSettings].Target;
104  }
105 
106  inline Real GetLensFocalLength() const {
107  return m_sSettings[m_unActiveSettings].LensFocalLength;
108  }
109 
110  void Rotate(const QPoint& c_delta);
111 
112  void Move(SInt32 n_forwards_backwards,
113  SInt32 n_sideways,
114  SInt32 n_up_down);
115 
117  return m_sSettings[m_unActiveSettings];
118  }
119 
120  inline const SSettings& GetActiveSettings() const {
121  return m_sSettings[m_unActiveSettings];
122  }
123 
124  inline void SetActiveSettings(UInt32 un_settings) {
125  m_unActiveSettings = un_settings;
126  }
127 
128  inline SSettings& GetSetting(UInt32 n_index) {
129  return m_sSettings[n_index];
130  }
131 
132  private:
133 
134  UInt32 m_unActiveSettings;
135  SSettings m_sSettings[12];
136 
137  };
138 
139 }
140 
141 #endif
142 
argos::CQTOpenGLCamera::SSettings::LensFocalLength
Real LensFocalLength
The focal length of the lens (if this was a real camera)
Definition: qtopengl_camera.h:49
argos::CQTOpenGLCamera::Look
void Look()
Definition: qtopengl_camera.h:94
argos::CQTOpenGLCamera::SSettings::Do
void Do()
Places this camera in the right position.
Definition: qtopengl_camera.cpp:270
argos::CQTOpenGLCamera::SSettings::CalculateSensitivity
void CalculateSensitivity()
Calculate the sensitivity of the camera.
Definition: qtopengl_camera.cpp:293
argos
The namespace containing all the ARGoS related code.
Definition: ci_actuator.h:12
argos::CVector3
A 3D vector class.
Definition: vector3.h:29
argos::CQTOpenGLCamera::GetLensFocalLength
Real GetLensFocalLength() const
Definition: qtopengl_camera.h:106
argos::CRadians
It defines the basic type CRadians, used to store an angle value in radians.
Definition: angles.h:42
argos::CQTOpenGLCamera
Definition: qtopengl_camera.h:31
argos::CQTOpenGLCamera::SSettings::SSettings
SSettings()
Definition: qtopengl_camera.h:57
argos::CQTOpenGLCamera::SSettings::YFieldOfView
CDegrees YFieldOfView
The focal length of the camera.
Definition: qtopengl_camera.h:51
argos::CQTOpenGLCamera::SSettings::RotateUpDown
void RotateUpDown(const CRadians &c_angle)
Rotation around the local Y axis.
Definition: qtopengl_camera.cpp:96
argos::CQTOpenGLCamera::SSettings::Up
CVector3 Up
The local Z axis of the camera in the global reference frame.
Definition: qtopengl_camera.h:43
argos::CQTOpenGLCamera::SSettings::RotateLeftRight
void RotateLeftRight(const CRadians &c_angle)
Rotation around the local Z axis.
Definition: qtopengl_camera.cpp:151
argos::CQTOpenGLCamera::SSettings::Init
void Init(TConfigurationNode &t_tree)
Initialize from XML.
Definition: qtopengl_camera.cpp:48
argos::CQTOpenGLCamera::SetActiveSettings
void SetActiveSettings(UInt32 un_settings)
Definition: qtopengl_camera.h:124
argos::CQTOpenGLCamera::~CQTOpenGLCamera
~CQTOpenGLCamera()
Definition: qtopengl_camera.cpp:308
argos::CQTOpenGLCamera::SSettings::RotateLeftRight2
void RotateLeftRight2(const CRadians &c_angle)
Rotation around the global Z axis.
Definition: qtopengl_camera.cpp:183
argos::CQTOpenGLCamera::Move
void Move(SInt32 n_forwards_backwards, SInt32 n_sideways, SInt32 n_up_down)
Definition: qtopengl_camera.cpp:328
argos::TConfigurationNode
ticpp::Element TConfigurationNode
The ARGoS configuration XML node.
Definition: argos_configuration.h:27
argos::CQTOpenGLCamera::SSettings::Left
CVector3 Left
The local Y axis of the camera in the global reference frame.
Definition: qtopengl_camera.h:41
argos::CQTOpenGLCamera::Rotate
void Rotate(const QPoint &c_delta)
Definition: qtopengl_camera.cpp:314
argos::CQTOpenGLCamera::SSettings::Position
CVector3 Position
The position of the camera in the global reference frame.
Definition: qtopengl_camera.h:39
argos::CQTOpenGLCamera::CQTOpenGLCamera
CQTOpenGLCamera()
Definition: qtopengl_camera.cpp:301
argos::CQTOpenGLCamera::SSettings::CalculateYFieldOfView
void CalculateYFieldOfView()
Calculates the value of YFieldOfView.
Definition: qtopengl_camera.cpp:286
argos::CQTOpenGLCamera::GetActiveSettings
SSettings & GetActiveSettings()
Definition: qtopengl_camera.h:116
SInt32
signed int SInt32
32-bit signed integer.
Definition: datatypes.h:93
argos::CQTOpenGLCamera::GetPosition
const CVector3 & GetPosition() const
Definition: qtopengl_camera.h:98
argos::CQTOpenGLCamera::SSettings::MotionSensitivity
Real MotionSensitivity
Motion sensitivity.
Definition: qtopengl_camera.h:53
argos::CQTOpenGLCamera::Init
void Init(TConfigurationNode &t_tree)
Definition: qtopengl_camera.cpp:20
argos::CQTOpenGLCamera::SSettings::Target
CVector3 Target
The direction of sight of the camera in the global reference frame.
Definition: qtopengl_camera.h:47
argos::CQTOpenGLCamera::SSettings
Definition: qtopengl_camera.h:37
argos::CQTOpenGLCamera::SSettings::Forward
CVector3 Forward
The local X axis of the camera in the global reference frame.
Definition: qtopengl_camera.h:45
UInt32
unsigned int UInt32
32-bit unsigned integer.
Definition: datatypes.h:97
argos::CQTOpenGLCamera::GetActiveSettings
const SSettings & GetActiveSettings() const
Definition: qtopengl_camera.h:120
argos::CQTOpenGLCamera::SSettings::RotationSensitivity
Real RotationSensitivity
Rotation sensitivity.
Definition: qtopengl_camera.h:55
argos::CDegrees
It defines the basic type CDegrees, used to store an angle value in degrees.
Definition: angles.h:288
argos::CQTOpenGLCamera::GetSetting
SSettings & GetSetting(UInt32 n_index)
Definition: qtopengl_camera.h:128
Real
float Real
Collects all ARGoS code.
Definition: datatypes.h:39
argos::CQTOpenGLCamera::SSettings::Translate
void Translate(const CVector3 &c_delta)
c_delta is expressed in the camera local coordinates
Definition: qtopengl_camera.cpp:261
argos::CQTOpenGLCamera::GetTarget
const CVector3 & GetTarget() const
Definition: qtopengl_camera.h:102