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
10namespace argos {
11 class CQTOpenGLCamera;
12}
13
14class 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
29namespace argos {
30
31 class CQTOpenGLCamera : public QObject {
32
33 Q_OBJECT
34
35 public:
36
53
54 struct SKeyframe {
56 UInt32 un_placement_index,
57 bool b_interpolate_to_next) :
58 Step(un_step),
59 PlacementIndex(un_placement_index),
60 InterpolateToNext(b_interpolate_to_next) {}
67 };
68
69 public:
70
72
74
75 void Init(TConfigurationNode& t_tree);
76
77 void Reset();
78
79 void Look();
80
81 inline const CVector3& GetPosition() const {
82 return m_sActivePlacement.Position;
83 }
84
85 inline const CVector3& GetTarget() const {
86 return m_sActivePlacement.Target;
87 }
88
89 inline Real GetLensFocalLength() const {
90 return m_sActivePlacement.LensFocalLength;
91 }
92
93 void Rotate(const QPoint& c_delta);
94
95 void Rotate(const CRadians& c_up_down,
96 const CRadians& c_left_right);
97
98 void Move(SInt32 n_forwards_backwards,
99 SInt32 n_sideways,
100 SInt32 n_up_down);
101
102 void Interpolate(UInt32 un_start_placement,
103 UInt32 un_end_placement,
104 Real f_time_fraction);
105
107 return m_sActivePlacement;
108 }
109
110 inline const SPlacement& GetActivePlacement() const {
111 return m_sActivePlacement;
112 }
113
114 inline void SetActivePlacement(UInt32 n_index) {
115 ARGOS_ASSERT(n_index < m_arrPlacements.size(),
116 "CQTOpenGLCamera::SetActivePlacement():"
117 " index out of bounds: n_index = " << n_index <<
118 ", m_arrPlacements.size() = " << m_arrPlacements.size());
119 m_sActivePlacement = m_arrPlacements[n_index];
120 }
121
122 inline SPlacement& GetPlacement(UInt32 n_index) {
123 ARGOS_ASSERT(n_index < m_arrPlacements.size(),
124 "CQTOpenGLCamera::GetPlacement():"
125 " index out of bounds: n_index = " << n_index <<
126 ", m_arrPlacements.size() = " << m_arrPlacements.size());
127 return m_arrPlacements[n_index];
128 }
129
130 void UpdateTimeline();
131
132 private:
133 bool m_bEnableTimeline;
134 bool m_bHasTimeline;
135 UInt32 m_unLoop;
136 SPlacement m_sActivePlacement;
137 std::array<SPlacement, 12> m_arrPlacements;
138 std::vector<SKeyframe> m_vecKeyframes;
139 };
140
141}
142
143#endif
144
signed int SInt32
32-bit signed integer.
Definition datatypes.h:93
unsigned int UInt32
32-bit unsigned integer.
Definition datatypes.h:97
float Real
Collects all ARGoS code.
Definition datatypes.h:39
#define ARGOS_ASSERT(condition, message)
When code is compiled in debug, this macro throws an ARGoS exception with the passed message if the s...
The namespace containing all the ARGoS related code.
Definition ci_actuator.h:12
ticpp::Element TConfigurationNode
The ARGoS configuration XML node.
It defines the basic type CRadians, used to store an angle value in radians.
Definition angles.h:42
It defines the basic type CDegrees, used to store an angle value in degrees.
Definition angles.h:288
A 3D vector class.
Definition vector3.h:31
void SetActivePlacement(UInt32 n_index)
const SPlacement & GetActivePlacement() const
void Interpolate(UInt32 un_start_placement, UInt32 un_end_placement, Real f_time_fraction)
const CVector3 & GetTarget() const
void Move(SInt32 n_forwards_backwards, SInt32 n_sideways, SInt32 n_up_down)
SPlacement & GetActivePlacement()
void Init(TConfigurationNode &t_tree)
const CVector3 & GetPosition() const
Real GetLensFocalLength() const
SPlacement & GetPlacement(UInt32 n_index)
void Rotate(const QPoint &c_delta)
CVector3 Up
The local Z axis of the camera in the global reference frame.
CVector3 Position
The position of the camera in the global reference frame.
void Init(TConfigurationNode &t_tree)
Initialize from XML.
CDegrees YFieldOfView
The focal length of the camera.
Real LensFocalLength
The focal length of the lens (if this was a real camera)
CVector3 Target
What we are looking at in the global reference frame.
void CalculateYFieldOfView()
Calculates the value of YFieldOfView.
UInt32 PlacementIndex
An index into the camera placements array [0-12)
UInt32 Step
The step at which this keyframe should be applied.
SKeyframe(UInt32 un_step, UInt32 un_placement_index, bool b_interpolate_to_next)
bool InterpolateToNext
Whether or not linear interpolation should be applied.