MRPT  2.0.4
CRenderizable.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #pragma once
10 
11 #include <mrpt/img/TColor.h>
12 #include <mrpt/math/TPoint3D.h>
13 #include <mrpt/math/math_frwds.h>
16 #include <mrpt/opengl/Shader.h>
19 #include <mrpt/poses/CPose3D.h>
21 #include <deque>
22 
23 namespace mrpt::opengl
24 {
25 // Frwd decls:
26 class COpenGLViewport;
27 class CSetOfObjects;
28 class CText;
29 struct TLightParameters;
30 
31 /** The base class of 3D objects that can be directly rendered through OpenGL.
32  * In this class there are a set of common properties to all 3D objects,
33  *mainly:
34  * - A name (m_name): A name that can be optionally asigned to objects for
35  *easing its reference.
36  * - 6D coordinates (x,y,z,yaw,pitch,roll), relative to the "current"
37  *reference framework. By default, any object is referenced to global scene
38  *coordinates.
39  * - A RGB color: This field will be used in simple elements (points,
40  *lines, text,...) but is ignored in more complex objects that carry their own
41  *color information (triangle sets,...)
42  *
43  * See the main class opengl::COpenGLScene
44  *
45  * \sa opengl::COpenGLScene, mrpt::opengl
46  * \ingroup mrpt_opengl_grp
47  */
49 {
51 
52  friend class mrpt::opengl::COpenGLViewport;
53  friend class mrpt::opengl::CSetOfObjects;
54 
55  protected:
56  std::string m_name;
57  bool m_show_name{false};
58  /** Color components in the range [0,255] */
60  /** 6D pose wrt the parent coordinate reference. This class automatically
61  * holds the cached 3x3 rotation matrix for quick load into opengl stack. */
63  /** Scale components to apply to the object (default=1) */
64  float m_scale_x{1}, m_scale_y{1}, m_scale_z{1};
65  /** Is the object visible? (default=true) */
66  bool m_visible{true};
67 
68  public:
69  /** @name Changes the appearance of the object to render
70  @{ */
71 
72  /** Changes the name of the object */
73  void setName(const std::string& n) { m_name = n; }
74  /** Returns the name of the object */
75  const std::string& getName() const { return m_name; }
76  inline bool isVisible()
77  const /** Is the object visible? \sa setVisibility */
78  {
79  return m_visible;
80  }
81  inline void setVisibility(
82  bool visible =
83  true) /** Set object visibility (default=true) \sa isVisible */
84  {
85  m_visible = visible;
86  }
87 
88  /** Enables or disables showing the name of the object as a label when
89  * rendering */
90  inline void enableShowName(bool showName = true) { m_show_name = showName; }
91  /** \sa enableShowName */
92  inline bool isShowNameEnabled() const { return m_show_name; }
93  /** Set the 3D pose from a mrpt::poses::CPose3D object (return a ref to
94  * this) */
96  /** Set the 3D pose from a mrpt::poses::CPose3D object (return a ref to
97  * this) */
99  /** Set the 3D pose from a mrpt::math::TPose3D object (return a ref to
100  * this) */
102  /** Set the 3D pose from a mrpt::math::TPose3D object (return a ref to
103  * this) */
105  /** Set the 3D pose from a mrpt::poses::CPose3D object (return a ref to
106  * this) */
108  /** Set the 3D pose from a mrpt::poses::CPose3D object (return a ref to
109  * this) */
111 
112  /** Returns the 3D pose of the object as TPose3D */
114 
115  /** Returns a const ref to the 3D pose of the object as mrpt::poses::CPose3D
116  * (which explicitly contains the 3x3 rotation matrix) */
117  inline const mrpt::poses::CPose3D& getPoseRef() const { return m_pose; }
118 
119  /** Changes the location of the object, keeping untouched the orientation
120  * \return a ref to this */
121  inline CRenderizable& setLocation(double x, double y, double z)
122  {
123  m_pose.x(x);
124  m_pose.y(y);
125  m_pose.z(z);
126  return *this;
127  }
128 
129  /** Changes the location of the object, keeping untouched the orientation
130  * \return a ref to this */
132  {
133  m_pose.x(p.x);
134  m_pose.y(p.y);
135  m_pose.z(p.z);
136  return *this;
137  }
138 
139  /** Translation relative to parent coordinate origin. */
140  inline double getPoseX() const { return m_pose.x(); }
141  /** Translation relative to parent coordinate origin. */
142  inline double getPoseY() const { return m_pose.y(); }
143  /** Translation relative to parent coordinate origin. */
144  inline double getPoseZ() const { return m_pose.z(); }
145  /** Rotation relative to parent coordinate origin, in **DEGREES**. */
146  inline double getPoseYaw() const { return mrpt::RAD2DEG(m_pose.yaw()); }
147  /** Rotation relative to parent coordinate origin, in **DEGREES**. */
148  inline double getPosePitch() const { return mrpt::RAD2DEG(m_pose.pitch()); }
149  /** Rotation relative to parent coordinate origin, in **DEGREES**. */
150  inline double getPoseRoll() const { return mrpt::RAD2DEG(m_pose.roll()); }
151  /** Rotation relative to parent coordinate origin, in radians. */
152  inline double getPoseYawRad() const { return m_pose.yaw(); }
153  /** Rotation relative to parent coordinate origin, in radians. */
154  inline double getPosePitchRad() const { return m_pose.pitch(); }
155  /** Rotation relative to parent coordinate origin, in radians. */
156  inline double getPoseRollRad() const { return m_pose.roll(); }
157  /** Color components in the range [0,1] */
158  inline float getColorR() const { return u8tof(m_color.R); }
159  /** Color components in the range [0,1] */
160  inline float getColorG() const { return u8tof(m_color.G); }
161  /** Color components in the range [0,1] */
162  inline float getColorB() const { return u8tof(m_color.B); }
163  /** Color components in the range [0,1] */
164  inline float getColorA() const { return u8tof(m_color.A); }
165  /** Color components in the range [0,255] */
166  inline uint8_t getColorR_u8() const { return m_color.R; }
167  /** Color components in the range [0,255] */
168  inline uint8_t getColorG_u8() const { return m_color.G; }
169  /** Color components in the range [0,255] */
170  inline uint8_t getColorB_u8() const { return m_color.B; }
171  /** Color components in the range [0,255] */
172  inline uint8_t getColorA_u8() const { return m_color.A; }
173  /**Color components in the range [0,1] \return a ref to this */
174  CRenderizable& setColorR(const float r) { return setColorR_u8(f2u8(r)); }
175  /**Color components in the range [0,1] \return a ref to this */
176  CRenderizable& setColorG(const float g) { return setColorG_u8(f2u8(g)); }
177  /**Color components in the range [0,1] \return a ref to this */
178  CRenderizable& setColorB(const float b) { return setColorB_u8(f2u8(b)); }
179  /**Color components in the range [0,1] \return a ref to this */
180  CRenderizable& setColorA(const float a) { return setColorA_u8(f2u8(a)); }
181  /**Color components in the range [0,255] \return a ref to this */
182  virtual CRenderizable& setColorR_u8(const uint8_t r)
183  {
184  m_color.R = r;
185  return *this;
186  }
187  /**Color components in the range [0,255] \return a ref to this */
188  virtual CRenderizable& setColorG_u8(const uint8_t g)
189  {
190  m_color.G = g;
191  return *this;
192  }
193  /**Color components in the range [0,255] \return a ref to this */
194  virtual CRenderizable& setColorB_u8(const uint8_t b)
195  {
196  m_color.B = b;
197  return *this;
198  }
199  /**Color components in the range [0,255] \return a ref to this */
200  virtual CRenderizable& setColorA_u8(const uint8_t a)
201  {
202  m_color.A = a;
203  return *this;
204  }
205 
206  /** Scale to apply to the object, in all three axes (default=1) \return a
207  * ref to this */
208  inline CRenderizable& setScale(float s)
209  {
210  m_scale_x = m_scale_y = m_scale_z = s;
211  return *this;
212  }
213  /** Scale to apply to the object in each axis (default=1) \return a ref to
214  * this */
215  inline CRenderizable& setScale(float sx, float sy, float sz)
216  {
217  m_scale_x = sx;
218  m_scale_y = sy;
219  m_scale_z = sz;
220  return *this;
221  }
222  /** Get the current scaling factor in one axis */
223  inline float getScaleX() const { return m_scale_x; }
224  /** Get the current scaling factor in one axis */
225  inline float getScaleY() const { return m_scale_y; }
226  /** Get the current scaling factor in one axis */
227  inline float getScaleZ() const { return m_scale_z; }
228  /** Returns the object color property as a TColorf */
230  {
231  return mrpt::img::TColorf(m_color);
232  }
233  /** Changes the default object color \return a ref to this */
235  {
236  return setColor_u8(
237  mrpt::img::TColor(f2u8(c.R), f2u8(c.G), f2u8(c.B), f2u8(c.A)));
238  }
239 
240  /** Set the color components of this object (R,G,B,Alpha, in the range 0-1)
241  * \return a ref to this */
242  inline CRenderizable& setColor(float R, float G, float B, float A = 1)
243  {
244  return setColor_u8(f2u8(R), f2u8(G), f2u8(B), f2u8(A));
245  }
246 
247  /** Returns the object color property as a TColor */
248  inline const mrpt::img::TColor& getColor_u8() const { return m_color; }
249  /*** Changes the default object color \return a ref to this */
250  virtual CRenderizable& setColor_u8(const mrpt::img::TColor& c);
251 
252  /** Set the color components of this object (R,G,B,Alpha, in the range
253  * 0-255) \return a ref to this */
254  CRenderizable& setColor_u8(uint8_t R, uint8_t G, uint8_t B, uint8_t A = 255)
255  {
256  return setColor_u8(mrpt::img::TColor(R, G, B, A));
257  }
258 
259  /** @} */
260 
261  /** Default constructor: */
262  CRenderizable();
263  ~CRenderizable() override;
264 
265  /** Context for calls to render() */
267  {
268  RenderContext() = default;
269 
271  const mrpt::opengl::Program* shader = nullptr;
274  };
275 
276  /** Implements the rendering of 3D objects in each class derived from
277  * CRenderizable. This can be called more than once (one per required shader
278  * program) if the object registered several shaders. \sa
279  * renderUpdateBuffers
280  */
281  virtual void render(const RenderContext& rc) const = 0;
282 
283  /** Process all children objects recursively, if the object is a container
284  */
286  [[maybe_unused]] const mrpt::opengl::TRenderMatrices& state,
287  [[maybe_unused]] RenderQueue& rq) const
288  {
289  // do thing
290  }
291 
292  /** Called whenever m_outdatedBuffers is true: used to re-generate
293  * OpenGL vertex buffers, etc. before they are sent for rendering in
294  * render() */
295  virtual void renderUpdateBuffers() const = 0;
296 
297  /** Returns the ID of the OpenGL shader program required to render this
298  * class. \sa DefaultShaderID
299  */
301  {
302  THROW_EXCEPTION("Not implemented in derived class!");
303  }
304 
305  /** Calls renderUpdateBuffers() and clear the flag that is set with
306  * notifyChange() */
307  void updateBuffers() const
308  {
310  const_cast<CRenderizable&>(*this).m_outdatedBuffers = false;
311  }
312 
313  /** Call to enable calling renderUpdateBuffers() before the next
314  * render() rendering iteration. */
315  void notifyChange() const
316  {
317  const_cast<CRenderizable&>(*this).m_outdatedBuffers = true;
318  }
319 
320  /** Returns whether notifyChange() has been invoked since the last call
321  * to renderUpdateBuffers(), meaning the latter needs to be called again
322  * before rendering.
323  */
324  bool hasToUpdateBuffers() const { return m_outdatedBuffers; }
325 
326  /** Simulation of ray-trace, given a pose. Returns true if the ray
327  * effectively collisions with the object (returning the distance to the
328  * origin of the ray in "dist"), or false in other case. "dist" variable
329  * yields undefined behaviour when false is returned
330  */
331  virtual bool traceRay(const mrpt::poses::CPose3D& o, double& dist) const;
332 
333  /** Evaluates the bounding box of this object (including possible
334  * children) in the coordinate frame of the object parent. */
335  virtual void getBoundingBox(
337 
338  /** Provide a representative point (in object local coordinates), used to
339  * sort objects by eye-distance while rendering with transparencies
340  * (Default=[0,0,0]) */
342  {
343  return m_representativePoint;
344  }
345 
346  /** See getLocalRepresentativePoint() */
348  {
350  }
351 
352  /** Returns or constructs (in its first invokation) the associated
353  * mrpt::opengl::CText object representing the label of the object.
354  * \sa enableShowName()
355  */
357 
358  /** Free opengl buffers */
359  virtual void freeOpenGLResources() = 0;
360 
361  /** Initializes all textures (loads them into opengl memory). */
362  virtual void initializeTextures() const {}
363 
364  protected:
367 
368  bool m_outdatedBuffers = true;
370 
371  /** Optional pointer to a mrpt::opengl::CText */
372  mutable std::shared_ptr<mrpt::opengl::CText> m_label_obj;
373 };
374 
375 /** A list of smart pointers to renderizable objects */
376 using CListOpenGLObjects = std::deque<CRenderizable::Ptr>;
377 
378 /** @name Miscellaneous rendering methods
379 @{ */
380 
381 /** Processes, recursively, all objects in the list, classifying them by shader
382  * programs into a list suitable to be used within processPendingRendering()
383  *
384  * For each object in the list:
385  * - checks visibility of each object
386  * - update the MODELVIEW matrix according to its coordinates
387  * - call its ::render()
388  * - shows its name (if enabled).
389  *
390  * \note Used by CSetOfObjects and COpenGLViewport
391  *
392  * \sa processPendingRendering
393  */
394 void enqueForRendering(
396  const mrpt::opengl::TRenderMatrices& state, RenderQueue& rq);
397 
398 /** After enqueForRendering(), actually executes the rendering tasks, grouped
399  * shader by shader.
400  *
401  * \note Used by COpenGLViewport
402  */
403 void processRenderQueue(
404  const RenderQueue& rq,
405  std::map<shader_id_t, mrpt::opengl::Program::Ptr>& shaders,
406  const mrpt::opengl::TLightParameters& lights);
407 
408 /** @} */
409 
410 } // namespace mrpt::opengl
mrpt::opengl::Program
A resource handling helper for OpenGL Shader "programs".
Definition: Shader.h:77
TRenderMatrices.h
mrpt::opengl::CRenderizable::setColor
CRenderizable & setColor(float R, float G, float B, float A=1)
Set the color components of this object (R,G,B,Alpha, in the range 0-1)
Definition: CRenderizable.h:242
mrpt::opengl::CRenderizable::setColor_u8
CRenderizable & setColor_u8(uint8_t R, uint8_t G, uint8_t B, uint8_t A=255)
Set the color components of this object (R,G,B,Alpha, in the range 0-255)
Definition: CRenderizable.h:254
mrpt::opengl::CRenderizable::setColorG_u8
virtual CRenderizable & setColorG_u8(const uint8_t g)
Color components in the range [0,255].
Definition: CRenderizable.h:188
mrpt::opengl::CRenderizable::setPose
CRenderizable & setPose(const mrpt::poses::CPose3D &o)
Set the 3D pose from a mrpt::poses::CPose3D object (return a ref to this)
Definition: CRenderizable.cpp:189
mrpt::opengl::shader_id_t
uint8_t shader_id_t
Type for IDs of shaders.
Definition: Shader.h:23
mrpt::opengl::CRenderizable::enqueForRenderRecursive
virtual void enqueForRenderRecursive([[maybe_unused]] const mrpt::opengl::TRenderMatrices &state, [[maybe_unused]] RenderQueue &rq) const
Process all children objects recursively, if the object is a container.
Definition: CRenderizable.h:285
mrpt::opengl::CRenderizable::~CRenderizable
~CRenderizable() override
mrpt::opengl::CRenderizable::notifyChange
void notifyChange() const
Call to enable calling renderUpdateBuffers() before the next render() rendering iteration.
Definition: CRenderizable.h:315
mrpt::opengl::CRenderizable::RenderContext::shader
const mrpt::opengl::Program * shader
Definition: CRenderizable.h:271
mrpt::opengl::RenderQueue
std::map< shader_id_t, std::multimap< float, RenderQueueElement > > RenderQueue
A queue for rendering, sorted by shader program to minimize changes of OpenGL shader programs while r...
Definition: RenderQueue.h:46
mrpt::opengl::CRenderizable::getPosePitch
double getPosePitch() const
Rotation relative to parent coordinate origin, in DEGREES.
Definition: CRenderizable.h:148
mrpt::math::TPoint3D_< double >
G
const double G
Definition: vision_stereo_rectify/test.cpp:32
mrpt::poses::CPose3D::pitch
double pitch() const
Get the PITCH angle (in radians)
Definition: CPose3D.h:552
mrpt::opengl::CRenderizable::readFromStreamRender
void readFromStreamRender(mrpt::serialization::CArchive &in)
Definition: CRenderizable.cpp:99
mrpt::opengl::CRenderizable::getColorB_u8
uint8_t getColorB_u8() const
Color components in the range [0,255].
Definition: CRenderizable.h:170
mrpt::poses::CPoseOrPoint::x
double x() const
Common members of all points & poses classes.
Definition: CPoseOrPoint.h:143
mrpt::opengl::CRenderizable::m_outdatedBuffers
bool m_outdatedBuffers
Definition: CRenderizable.h:368
mrpt::opengl::CRenderizable::CRenderizable
CRenderizable()
Default constructor:
Definition: CRenderizable.cpp:32
mrpt::opengl::CRenderizable
The base class of 3D objects that can be directly rendered through OpenGL.
Definition: CRenderizable.h:48
mrpt::opengl::CRenderizable::renderUpdateBuffers
virtual void renderUpdateBuffers() const =0
Called whenever m_outdatedBuffers is true: used to re-generate OpenGL vertex buffers,...
mrpt::opengl::CRenderizable::labelObject
mrpt::opengl::CText & labelObject() const
Returns or constructs (in its first invokation) the associated mrpt::opengl::CText object representin...
Definition: CRenderizable.cpp:238
mrpt::opengl::CRenderizable::setScale
CRenderizable & setScale(float s)
Scale to apply to the object, in all three axes (default=1)
Definition: CRenderizable.h:208
mrpt::opengl::processRenderQueue
void processRenderQueue(const RenderQueue &rq, std::map< shader_id_t, mrpt::opengl::Program::Ptr > &shaders, const mrpt::opengl::TLightParameters &lights)
After enqueForRendering(), actually executes the rendering tasks, grouped shader by shader.
Definition: RenderQueue.cpp:126
mrpt::math::TPoint3D_data::z
T z
Definition: TPoint3D.h:29
mrpt::opengl::CRenderizable::getScaleX
float getScaleX() const
Get the current scaling factor in one axis.
Definition: CRenderizable.h:223
mrpt::opengl::CRenderizable::setColorB
CRenderizable & setColorB(const float b)
Color components in the range [0,1].
Definition: CRenderizable.h:178
mrpt::opengl::CRenderizable::traceRay
virtual bool traceRay(const mrpt::poses::CPose3D &o, double &dist) const
Simulation of ray-trace, given a pose.
Definition: CRenderizable.cpp:224
mrpt::opengl::CRenderizable::setColorA_u8
virtual CRenderizable & setColorA_u8(const uint8_t a)
Color components in the range [0,255].
Definition: CRenderizable.h:200
mrpt::f2u8
uint8_t f2u8(const float f)
converts a float [0,1] into an uint8_t [0,255] (without checking for out of bounds)
Definition: core/include/mrpt/core/bits_math.h:193
mrpt::img::TColorf::R
float R
Definition: TColor.h:107
mrpt::opengl::CRenderizable::setLocalRepresentativePoint
void setLocalRepresentativePoint(const mrpt::math::TPoint3Df &p)
See getLocalRepresentativePoint()
Definition: CRenderizable.h:347
mrpt::img::TColor::R
uint8_t R
Definition: TColor.h:51
mrpt::opengl::CRenderizable::getBoundingBox
virtual void getBoundingBox(mrpt::math::TPoint3D &bb_min, mrpt::math::TPoint3D &bb_max) const =0
Evaluates the bounding box of this object (including possible children) in the coordinate frame of th...
mrpt::opengl::CRenderizable::isShowNameEnabled
bool isShowNameEnabled() const
Definition: CRenderizable.h:92
mrpt::opengl::CRenderizable::setLocation
CRenderizable & setLocation(const mrpt::math::TPoint3D &p)
Changes the location of the object, keeping untouched the orientation.
Definition: CRenderizable.h:131
mrpt::opengl::CRenderizable::setColorB_u8
virtual CRenderizable & setColorB_u8(const uint8_t b)
Color components in the range [0,255].
Definition: CRenderizable.h:194
out
mrpt::vision::TStereoCalibResults out
Definition: chessboard_stereo_camera_calib_unittest.cpp:25
mrpt::opengl::CRenderizable::setColor
CRenderizable & setColor(const mrpt::img::TColorf &c)
Changes the default object color.
Definition: CRenderizable.h:234
mrpt::opengl::CRenderizable::RenderContext::RenderContext
RenderContext()=default
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: BaseAppDataSource.h:15
mrpt::opengl::CRenderizable::setColorR_u8
virtual CRenderizable & setColorR_u8(const uint8_t r)
Color components in the range [0,255].
Definition: CRenderizable.h:182
mrpt::opengl::CRenderizable::m_name
std::string m_name
Definition: CRenderizable.h:56
mrpt::opengl::CRenderizable::getScaleZ
float getScaleZ() const
Get the current scaling factor in one axis.
Definition: CRenderizable.h:227
mrpt::opengl::CRenderizable::getPoseZ
double getPoseZ() const
Translation relative to parent coordinate origin.
Definition: CRenderizable.h:144
R
const float R
Definition: CKinematicChain.cpp:137
mrpt::opengl::CRenderizable::getColorR
float getColorR() const
Color components in the range [0,1].
Definition: CRenderizable.h:158
THROW_EXCEPTION
#define THROW_EXCEPTION(msg)
Definition: exceptions.h:67
mrpt::opengl::CRenderizable::getPosePitchRad
double getPosePitchRad() const
Rotation relative to parent coordinate origin, in radians.
Definition: CRenderizable.h:154
mrpt::opengl::CRenderizable::setLocation
CRenderizable & setLocation(double x, double y, double z)
Changes the location of the object, keeping untouched the orientation.
Definition: CRenderizable.h:121
mrpt::serialization::CArchive
Virtual base class for "archives": classes abstracting I/O streams.
Definition: CArchive.h:54
mrpt::opengl::CRenderizable::enableShowName
void enableShowName(bool showName=true)
Enables or disables showing the name of the object as a label when rendering.
Definition: CRenderizable.h:90
mrpt::opengl::CRenderizable::getPose
mrpt::math::TPose3D getPose() const
Returns the 3D pose of the object as TPose3D.
Definition: CRenderizable.cpp:223
mrpt::opengl::CRenderizable::m_representativePoint
mrpt::math::TPoint3Df m_representativePoint
Definition: CRenderizable.h:369
mrpt::img::TColorf::B
float B
Definition: TColor.h:107
bb_max
const auto bb_max
Definition: CPose3DPDFGrid_unittest.cpp:25
Shader.h
mrpt::img::TColor::B
uint8_t B
Definition: TColor.h:51
mrpt::opengl::CSetOfObjects
A set of object, which are referenced to the coordinates framework established in this object.
Definition: CSetOfObjects.h:26
mrpt::opengl::CRenderizable::getPoseY
double getPoseY() const
Translation relative to parent coordinate origin.
Definition: CRenderizable.h:142
bb_min
const auto bb_min
Definition: CPose3DPDFGrid_unittest.cpp:23
mrpt::opengl::CRenderizable::m_pose
mrpt::poses::CPose3D m_pose
6D pose wrt the parent coordinate reference.
Definition: CRenderizable.h:62
mrpt::opengl::CRenderizable::m_color
mrpt::img::TColor m_color
Color components in the range [0,255].
Definition: CRenderizable.h:59
mrpt::opengl::CRenderizable::getPoseRollRad
double getPoseRollRad() const
Rotation relative to parent coordinate origin, in radians.
Definition: CRenderizable.h:156
mrpt::opengl::CRenderizable::getPoseRef
const mrpt::poses::CPose3D & getPoseRef() const
Returns a const ref to the 3D pose of the object as mrpt::poses::CPose3D (which explicitly contains t...
Definition: CRenderizable.h:117
opengl_fonts.h
mrpt::opengl::CRenderizable::getScaleY
float getScaleY() const
Get the current scaling factor in one axis.
Definition: CRenderizable.h:225
mrpt::poses::CPose2D
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle.
Definition: CPose2D.h:39
DefaultShaders.h
mrpt::RAD2DEG
constexpr double RAD2DEG(const double x)
Radians to degrees.
Definition: core/include/mrpt/core/bits_math.h:56
mrpt::u8tof
float u8tof(const uint8_t v)
converts a uint8_t [0,255] into a float [0,1]
Definition: core/include/mrpt/core/bits_math.h:196
mrpt::poses::CPose3D
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:85
mrpt::opengl::CRenderizable::getColorA
float getColorA() const
Color components in the range [0,1].
Definition: CRenderizable.h:164
mrpt::opengl::CRenderizable::setColorA
CRenderizable & setColorA(const float a)
Color components in the range [0,1].
Definition: CRenderizable.h:180
mrpt::img::TColorf
An RGBA color - floats in the range [0,1].
Definition: TColor.h:88
mrpt::poses::CPoseOrPoint::y
double y() const
Definition: CPoseOrPoint.h:147
mrpt::poses::CPose3D::roll
double roll() const
Get the ROLL angle (in radians)
Definition: CPose3D.h:558
mrpt::opengl::CRenderizable::setColorG
CRenderizable & setColorG(const float g)
Color components in the range [0,1].
Definition: CRenderizable.h:176
mrpt::img::TColor
A RGB color - 8bit.
Definition: TColor.h:25
mrpt::opengl::CRenderizable::m_label_obj
std::shared_ptr< mrpt::opengl::CText > m_label_obj
Optional pointer to a mrpt::opengl::CText.
Definition: CRenderizable.h:372
mrpt::math::TPose2D
Lightweight 2D pose.
Definition: TPose2D.h:22
math_frwds.h
mrpt::serialization::CSerializable
The virtual base class which provides a unified interface for all persistent objects in MRPT.
Definition: CSerializable.h:30
mrpt::opengl::CRenderizable::getPoseX
double getPoseX() const
Translation relative to parent coordinate origin.
Definition: CRenderizable.h:140
mrpt::opengl::CRenderizable::m_scale_y
float m_scale_y
Definition: CRenderizable.h:64
mrpt::math::TPose3D
Lightweight 3D pose (three spatial coordinates, plus three angular coordinates).
Definition: TPose3D.h:24
A
Definition: is_defined_unittest.cpp:13
mrpt::opengl::CRenderizable::setVisibility
void setVisibility(bool visible=true)
Set object visibility (default=true)
Definition: CRenderizable.h:81
mrpt::img::TColor::A
uint8_t A
Definition: TColor.h:51
mrpt::opengl::CRenderizable::getPoseRoll
double getPoseRoll() const
Rotation relative to parent coordinate origin, in DEGREES.
Definition: CRenderizable.h:150
mrpt::opengl::CRenderizable::m_show_name
bool m_show_name
Definition: CRenderizable.h:57
mrpt::opengl::CRenderizable::hasToUpdateBuffers
bool hasToUpdateBuffers() const
Returns whether notifyChange() has been invoked since the last call to renderUpdateBuffers(),...
Definition: CRenderizable.h:324
mrpt::opengl::CRenderizable::m_scale_x
float m_scale_x
Scale components to apply to the object (default=1)
Definition: CRenderizable.h:64
mrpt::opengl::CRenderizable::RenderContext
Context for calls to render()
Definition: CRenderizable.h:266
DEFINE_VIRTUAL_SERIALIZABLE
#define DEFINE_VIRTUAL_SERIALIZABLE(class_name)
This declaration must be inserted in virtual CSerializable classes definition:
Definition: CSerializable.h:171
mrpt::opengl::CRenderizable::getName
const std::string & getName() const
Returns the name of the object.
Definition: CRenderizable.h:75
mrpt::opengl::CRenderizable::RenderContext::shader_id
mrpt::opengl::shader_id_t shader_id
Definition: CRenderizable.h:272
mrpt::math::TPoint3D_data::y
T y
Definition: TPoint3D.h:29
mrpt::opengl::enqueForRendering
void enqueForRendering(const mrpt::opengl::CListOpenGLObjects &objs, const mrpt::opengl::TRenderMatrices &state, RenderQueue &rq)
Processes, recursively, all objects in the list, classifying them by shader programs into a list suit...
Definition: RenderQueue.cpp:28
mrpt::opengl::CRenderizable::freeOpenGLResources
virtual void freeOpenGLResources()=0
Free opengl buffers.
CPose3D.h
mrpt::opengl::CRenderizable::getColorB
float getColorB() const
Color components in the range [0,1].
Definition: CRenderizable.h:162
mrpt::opengl::TRenderMatrices
Rendering state related to the projection and model-view matrices.
Definition: TRenderMatrices.h:25
mrpt::opengl::CRenderizable::m_visible
bool m_visible
Is the object visible? (default=true)
Definition: CRenderizable.h:66
mrpt::opengl::CRenderizable::m_scale_z
float m_scale_z
Definition: CRenderizable.h:64
mrpt::img::TColorf::G
float G
Definition: TColor.h:107
mrpt::opengl::CRenderizable::updateBuffers
void updateBuffers() const
Calls renderUpdateBuffers() and clear the flag that is set with notifyChange()
Definition: CRenderizable.h:307
mrpt::opengl::CRenderizable::getColorA_u8
uint8_t getColorA_u8() const
Color components in the range [0,255].
Definition: CRenderizable.h:172
mrpt::poses::CPose3D::yaw
double yaw() const
Get the YAW angle (in radians)
Definition: CPose3D.h:546
TPoint3D.h
mrpt::opengl::CRenderizable::getPoseYaw
double getPoseYaw() const
Rotation relative to parent coordinate origin, in DEGREES.
Definition: CRenderizable.h:146
mrpt::opengl::CRenderizable::RenderContext::lights
const mrpt::opengl::TLightParameters * lights
Definition: CRenderizable.h:273
mrpt::opengl::CRenderizable::getColor
mrpt::img::TColorf getColor() const
Returns the object color property as a TColorf.
Definition: CRenderizable.h:229
mrpt::img::TColor::G
uint8_t G
Definition: TColor.h:51
mrpt::opengl::CListOpenGLObjects
std::deque< CRenderizable::Ptr > CListOpenGLObjects
A list of smart pointers to renderizable objects.
Definition: CRenderizable.h:376
mrpt::math::TPoint3D_data::x
T x
X,Y,Z coordinates.
Definition: TPoint3D.h:29
mrpt::opengl::CRenderizable::getColorG
float getColorG() const
Color components in the range [0,1].
Definition: CRenderizable.h:160
mrpt::opengl::COpenGLViewport
A viewport within a COpenGLScene, containing a set of OpenGL objects to render.
Definition: COpenGLViewport.h:61
mrpt::opengl::CRenderizable::getColor_u8
const mrpt::img::TColor & getColor_u8() const
Returns the object color property as a TColor.
Definition: CRenderizable.h:248
mrpt::opengl::shader_list_t
std::vector< shader_id_t > shader_list_t
A list of shader IDs.
Definition: Shader.h:26
mrpt::opengl::CRenderizable::setName
void setName(const std::string &n)
Changes the name of the object.
Definition: CRenderizable.h:73
RenderQueue.h
mrpt::opengl::TLightParameters
Lighting parameters, mostly for triangle shaders.
Definition: TLightParameters.h:22
mrpt::opengl::CRenderizable::setColorR
CRenderizable & setColorR(const float r)
Color components in the range [0,1].
Definition: CRenderizable.h:174
mrpt::opengl::CRenderizable::getLocalRepresentativePoint
virtual mrpt::math::TPoint3Df getLocalRepresentativePoint() const
Provide a representative point (in object local coordinates), used to sort objects by eye-distance wh...
Definition: CRenderizable.h:341
mrpt::opengl::CRenderizable::requiredShaders
virtual shader_list_t requiredShaders() const
Returns the ID of the OpenGL shader program required to render this class.
Definition: CRenderizable.h:300
mrpt::opengl::CRenderizable::RenderContext::state
const mrpt::opengl::TRenderMatrices * state
Definition: CRenderizable.h:270
mrpt::opengl::CRenderizable::getColorR_u8
uint8_t getColorR_u8() const
Color components in the range [0,255].
Definition: CRenderizable.h:166
mrpt::poses::CPoint2D
A class used to store a 2D point.
Definition: CPoint2D.h:32
mrpt::poses::CPoint3D
A class used to store a 3D point.
Definition: CPoint3D.h:31
CSerializable.h
mrpt::opengl::CRenderizable::writeToStreamRender
void writeToStreamRender(mrpt::serialization::CArchive &out) const
Definition: CRenderizable.cpp:44
mrpt::opengl::CRenderizable::setColor_u8
virtual CRenderizable & setColor_u8(const mrpt::img::TColor &c)
Definition: CRenderizable.cpp:229
mrpt::opengl::CRenderizable::getColorG_u8
uint8_t getColorG_u8() const
Color components in the range [0,255].
Definition: CRenderizable.h:168
mrpt::img::TColorf::A
float A
Definition: TColor.h:107
mrpt::opengl
The namespace for 3D scene representation and rendering.
Definition: CGlCanvasBase.h:13
mrpt::opengl::CRenderizable::getPoseYawRad
double getPoseYawRad() const
Rotation relative to parent coordinate origin, in radians.
Definition: CRenderizable.h:152
mrpt::opengl::CText
A 2D text (bitmap rendering): it always "faces the observer" despite it's at some 3D location.
Definition: CText.h:35
mrpt::opengl::CRenderizable::isVisible
bool isVisible() const
Is the object visible?
Definition: CRenderizable.h:76
TColor.h
mrpt::opengl::CRenderizable::initializeTextures
virtual void initializeTextures() const
Initializes all textures (loads them into opengl memory).
Definition: CRenderizable.h:362
mrpt::opengl::CRenderizable::setScale
CRenderizable & setScale(float sx, float sy, float sz)
Scale to apply to the object in each axis (default=1)
Definition: CRenderizable.h:215
mrpt::opengl::CRenderizable::render
virtual void render(const RenderContext &rc) const =0
Implements the rendering of 3D objects in each class derived from CRenderizable.



Page generated by Doxygen 1.8.17 for MRPT 2.0.4 at Sun Jul 19 15:15:43 UTC 2020