MRPT  2.0.3
COpenGLViewport.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 
12 #include <mrpt/img/CImage.h>
13 #include <mrpt/opengl/CCamera.h>
18 #include <mrpt/opengl/Shader.h>
24 #include <mrpt/system/mrptEvent.h>
25 #include <map>
26 
27 namespace mrpt::img
28 {
29 class CImage;
30 }
31 namespace mrpt::opengl
32 {
33 /** A viewport within a COpenGLScene, containing a set of OpenGL objects to
34  *render.
35  * This class has protected constuctor, thus it cannot be created by users.
36  *Use COpenGLScene::createViewport instead.
37  * A viewport has these "operation modes":
38  * - Normal (default): It renders the contained objects.
39  * - Cloned: It clones the objects from another viewport. See \a
40  *setCloneView()
41  * - Image mode: It renders an image (e.g. from a video stream) efficiently
42  *using a textued quad. See \a setImageView().
43  *
44  * In any case, the viewport can be resized to only fit a part of the entire
45  *parent viewport.
46  * There will be always at least one viewport in a COpenGLScene named "main".
47  *
48  * This class can be observed (see mrpt::system::CObserver) for the following
49  *events (see mrpt::system::mrptEvent):
50  * - mrpt::opengl::mrptEventGLPreRender
51  * - mrpt::opengl::mrptEventGLPostRender
52  *
53  * Two directional light sources at infinity are created by default, with
54  *directions (-1,-1,-1) and (1,2,1), respectively.
55  *
56  * Lighting parameters are accessible via lightParameters().
57  *
58  * Refer to mrpt::opengl::COpenGLScene for further details.
59  * \ingroup mrpt_opengl_grp
60  */
64 {
66  friend class COpenGLScene;
67 
68  public:
69  /** @name Set the viewport "modes"
70  @{ */
71 
72  /** Set this viewport as a clone of some other viewport, given its name - as
73  * a side effect, current list of internal OpenGL objects is cleared.
74  * By default, only the objects are cloned, not the camera. See
75  * \sa resetCloneView
76  */
77  void setCloneView(const std::string& clonedViewport);
78 
79  /** Set this viewport into "image view"-mode, where an image is efficiently
80  * drawn (fitting the viewport area) using an OpenGL textured quad.
81  * Call this method with the new image to update the displayed image (but
82  * recall to first lock the parent openglscene's critical section, then do
83  * the update, then release the lock, and then issue a window repaint).
84  * Internally, the texture is drawn using a mrpt::opengl::CTexturedPlane
85  * The viewport can be reverted to behave like a normal viewport by
86  * calling setNormalMode()
87  */
88  void setImageView(const mrpt::img::CImage& img);
89 
90  /** Just like \a setImageView but moves the internal image memory instead of
91  * making a copy, so it's faster but empties the input image.
92  * \sa setImageView
93  */
94  void setImageView(mrpt::img::CImage&& img);
95 
96  /** Reset the viewport to normal mode: rendering its own objects.
97  * \sa setCloneView, setNormalMode
98  */
99  inline void resetCloneView() { setNormalMode(); }
100  /** If set to true, and setCloneView() has been called, this viewport will
101  * be rendered using the camera of the cloned viewport.
102  */
103  inline void setCloneCamera(bool enable) { m_isClonedCamera = enable; }
104  /** Resets the viewport to a normal 3D viewport \sa setCloneView,
105  * setImageView */
106  void setNormalMode();
107 
108  /** @} */
109  // end of Set the "viewport mode"
110 
111  /** @name OpenGL global settings that affect rendering all objects in the
112  scene/viewport
113  @{ */
114 
115  /** Sets glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST) is enabled, or GL_FASTEST
116  * otherwise. */
117  void enablePolygonNicest(bool enable = true)
118  {
120  }
122 
123  const TLightParameters& lightParameters() const { return m_lights; }
125 
126  /** @} */
127 
128  /** @name Change or read viewport properties (except "viewport modes")
129  @{ */
130 
131  /** Returns the name of the viewport */
132  inline std::string getName() { return m_name; }
133  /** Change the viewport position and dimension on the rendering window.
134  * X & Y coordinates here can have two interpretations:
135  * - If in the range [0,1], they are factors with respect to the actual
136  *window sizes (i.e. width=1 means the entire width of the rendering
137  *window).
138  * - If >1, they are interpreted as pixels.
139  *
140  * width & height can be interpreted as:
141  * - If >1, they are the size of the viewport in that dimension, in
142  *pixels.
143  * - If in [0,1], they are the size of the viewport in that dimension,
144  *in
145  *a factor of the width/height.
146  * - If in [-1,0[, the size is computed such as the right/top border
147  *ends
148  *up in the given coordinate, interpreted as a factor (e.g. -1: up to the
149  *end of the viewport, -0.5: up to the middle of it).
150  * - If <-1 the size is computed such as the right/top border ends up
151  *in
152  *the given absolute coordinate (e.g. -200: up to the row/column 200px).
153  *
154  * \note (x,y) specify the lower left corner of the viewport rectangle.
155  * \sa getViewportPosition
156  */
157  void setViewportPosition(
158  const double x, const double y, const double width,
159  const double height);
160 
161  /** Get the current viewport position and dimension on the rendering window.
162  * X & Y coordinates here can have two interpretations:
163  * - If in the range [0,1], they are factors with respect to the actual
164  * window sizes (i.e. width=1 means the entire width of the rendering
165  * window).
166  * - If >1, they are interpreted as pixels.
167  * \note (x,y) specify the lower left corner of the viewport rectangle.
168  * \sa setViewportPosition
169  */
170  void getViewportPosition(
171  double& x, double& y, double& width, double& height);
172 
173  /** Set the min/max clip depth distances of the rendering frustum (default:
174  * 0.1 - 10000)
175  * \sa getViewportClipDistances
176  */
177  void setViewportClipDistances(const float clip_min, const float clip_max);
178 
179  /** Get the current min/max clip depth distances of the rendering frustum
180  * (default: 0.1 - 10000)
181  * \sa setViewportClipDistances
182  */
183  void getViewportClipDistances(float& clip_min, float& clip_max) const;
184 
185  /** Set the border size ("frame") of the viewport (default=0) */
186  inline void setBorderSize(unsigned int lineWidth)
187  {
188  m_borderWidth = lineWidth;
189  }
190  inline unsigned int getBorderSize() const { return m_borderWidth; }
191 
193  const mrpt::img::TColor& getBorderColor() const { return m_borderColor; }
194 
195  /** Return whether the viewport will be rendered transparent over previous
196  * viewports.
197  */
198  inline bool isTransparent() { return m_isTransparent; }
199  /** Set the transparency, that is, whether the viewport will be rendered
200  * transparent over previous viewports (default=false).
201  */
202  inline void setTransparent(bool trans) { m_isTransparent = trans; }
203  /** Set a background color different from that of the parent GUI window */
205  {
206  m_custom_backgb_color = true;
207  m_background_color = color;
208  }
209 
211  {
212  return m_background_color;
213  }
214 
215  /** Compute the 3D ray corresponding to a given pixel; this can be used to
216  * allow the user to pick and select 3D objects by clicking onto the 2D
217  * image.
218  * \param x_coord Horizontal coordinate with the usual meaning (0:left of
219  * the viewport, W-1: right border).
220  * \param y_coord Horizontal coordinate with the usual meaning (0:top of
221  * the viewport, H-1: right border).
222  * \param out_cameraPose If not nullptr, will have the camera 3D pose as a
223  * mrpt::poses::CPose3D. See also
224  * \note (x,y) refer to VIEWPORT coordinates. Take into account this when
225  * viewports do not extend to the whole window size.
226  * \note x and y are double instead of integers to allow sub-pixel
227  * precision.
228  * \sa getCurrentCameraPose
229  */
231  const double x_coord, const double y_coord,
232  mrpt::math::TLine3D& out_ray,
233  mrpt::poses::CPose3D* out_cameraPose = nullptr) const;
234 
235  /** @} */ // end of Change or read viewport properties
236 
237  /** @name Contained objects set/get/search
238  @{ */
239 
240  using const_iterator = CListOpenGLObjects::const_iterator;
241  using iterator = CListOpenGLObjects::iterator;
242 
243  inline const_iterator begin() const { return m_objects.begin(); }
244  inline const_iterator end() const { return m_objects.end(); }
245  inline iterator begin() { return m_objects.begin(); }
246  inline iterator end() { return m_objects.end(); }
247  /** Delete all internal obejcts
248  * \sa insert */
249  void clear();
250 
251  /** Insert a new object into the list.
252  * The object MUST NOT be deleted, it will be deleted automatically by
253  * this object when not required anymore.
254  */
255  void insert(const CRenderizable::Ptr& newObject);
256 
257  /** Compute the current 3D camera pose.
258  * \sa get3DRayForPixelCoord
259  */
260  void getCurrentCameraPose(mrpt::poses::CPose3D& out_cameraPose) const;
261 
262  /** Changes the point of view of the camera, from a given pose.
263  * \sa getCurrentCameraPose
264  */
266 
267  /** Returns the first object with a given name, or nullptr if not found.
268  */
269  CRenderizable::Ptr getByName(const std::string& str);
270 
271  /** Returns the i'th object of a given class (or of a descendant class), or
272  nullptr (an empty smart pointer) if not found.
273  * Example:
274  * \code
275  CSphere::Ptr obs = view.getByClass<CSphere>();
276  * \endcode
277  * By default (ith=0), the first observation is returned.
278  */
279  template <typename T>
280  typename T::Ptr getByClass(size_t ith = 0) const
281  {
282  MRPT_START
283  size_t foundCount = 0;
284  const auto* class_ID = &T::GetRuntimeClassIdStatic();
285  for (const auto& o : m_objects)
286  if (o && o->GetRuntimeClass()->derivedFrom(class_ID))
287  if (foundCount++ == ith) return std::dynamic_pointer_cast<T>(o);
288 
289  // If not found directly, search recursively:
290  for (const auto& o : m_objects)
291  {
292  if (o && o->GetRuntimeClass() ==
294  {
295  typename T::Ptr obj = std::dynamic_pointer_cast<T>(
296  std::dynamic_pointer_cast<CSetOfObjects>(o)
297  ->template getByClass<T>(ith));
298  if (obj) return obj;
299  }
300  }
301  return typename T::Ptr(); // Not found: return empty smart pointer
302  MRPT_END
303  }
304 
305  /** Removes the given object from the scene (it also deletes the object to
306  * free its memory).
307  */
308  void removeObject(const CRenderizable::Ptr& obj);
309 
310  /** Number of objects contained. */
311  inline size_t size() const { return m_objects.size(); }
312  inline bool empty() const { return m_objects.empty(); }
313  /** Get a reference to the camera associated with this viewport. */
315  /** Get a reference to the camera associated with this viewport. */
316  const opengl::CCamera& getCamera() const { return m_camera; }
317  /** Evaluates the bounding box of this object (including possible children)
318  * in the coordinate frame of the object parent. */
319  void getBoundingBox(
321 
322  /** @} */ // end of Contained objects set/get/search
323  // ------------------------------------------------------
324 
325  /** Destructor: clears all objects. */
326  ~COpenGLViewport() override;
327 
328  /** Constructor, invoked from COpenGLScene only.
329  */
331  COpenGLScene* parent = nullptr,
332  const std::string& name = std::string(""));
333 
334  /** Render the objects in this viewport (called from COpenGLScene) */
335  void render(
336  const int render_width, const int render_height,
337  const int render_offset_x = 0, const int render_offset_y = 0) const;
338 
339  protected:
340  /** Initializes all textures in the scene (See
341  * opengl::CTexturedPlane::initializeTextures)
342  */
343  void initializeTextures();
344 
345  /** Retrieves a list of all objects in text form.
346  */
347  void dumpListOfObjects(std::vector<std::string>& lst);
348 
349  /** Render in image mode */
350  void renderImageMode() const;
351 
352  /** Render a normal scene with 3D objects */
353  void renderNormalSceneMode() const;
354 
355  /** Render the viewport border, if enabled */
356  void renderViewportBorder() const;
357 
358  /** The camera associated to the viewport */
360  /** The scene that contains this viewport. */
362  /** Set by setCloneView */
363  bool m_isCloned{false};
364  /** Set by setCloneCamera */
365  bool m_isClonedCamera{false};
366  /** Only if m_isCloned=true */
367  std::string m_clonedViewport;
368  /** The viewport's name */
369  std::string m_name;
370  /** Whether to clear color buffer. */
371  bool m_isTransparent{false};
372  /** Default=0, the border around the viewport. */
373  uint32_t m_borderWidth{0};
374 
375  mrpt::img::TColor m_borderColor{255, 255, 255, 255};
376 
377  /** The viewport position [0,1] */
379  /** The min/max clip depth distances (default: 0.1 - 10000) */
380  float m_clip_min = 0.1f, m_clip_max = 10000.0f;
382  /** used only if m_custom_backgb_color */
384  /** Set by setImageView */
385  bool m_isImageView{false};
386 
387  /** The image to display, after calling \a setImageView() */
389 
391 
392  /** Info updated with each "render()" and used in "get3DRayForPixelCoord" */
394 
395  /** Default shader program */
396  mutable std::map<shader_id_t, mrpt::opengl::Program::Ptr> m_shaders;
397 
398  /** Load all MPRT predefined shader programs into m_shaders */
399  void loadDefaultShaders() const;
400 
401  /** Unload shader programs in m_shaders */
402  void unloadShaders();
403 
404  /** The list of objects that comprise the 3D scene.
405  * Objects are automatically deleted when calling "clear" or in the
406  * destructor.
407  */
409 
411 
412  // OpenGL global settings:
414 
416 
417  /** Renders all messages in the underlying class CTextMessageCapable */
418  void renderTextMessages() const;
419 };
420 
421 /**
422  * Inserts an openGL object into a viewport. Allows call chaining.
423  * \sa mrpt::opengl::COpenGLViewport::insert
424  */
427 {
428  s->insert(r);
429  return s;
430 }
431 /**
432  * Inserts any iterable set of openGL objects into a viewport. Allows call
433  * chaining.
434  * \sa mrpt::opengl::COpenGLViewport::insert
435  */
437  COpenGLViewport::Ptr& s, const std::vector<CRenderizable::Ptr>& v)
438 {
439  for (const auto& it : v) s->insert(it);
440  return s;
441 }
442 
443 /** @name Events emitted by COpenGLViewport
444  @{ */
445 
446 /** An event sent by an mrpt::opengl::COpenGLViewport just after clearing the
447  * viewport and setting the GL_PROJECTION matrix, and before calling the scene
448  * OpenGL drawing primitives.
449  *
450  * While handling this event you can call OpenGL glDraw(), etc.
451  *
452  * IMPORTANTE NOTICE: Event handlers in your observer class will most likely be
453  * invoked from an internal GUI thread of MRPT, so all your code in the handler
454  * must be thread safe.
455  */
457 {
458  protected:
459  /** Just to allow this class to be polymorphic */
460  void do_nothing() override {}
461 
462  public:
464  : source_viewport(obj)
465  {
466  }
468 }; // End of class def.
469 
470 /** An event sent by an mrpt::opengl::COpenGLViewport after calling the scene
471  * OpenGL drawing primitives and before doing a glSwapBuffers
472  *
473  * While handling this event you can call OpenGL glBegin(),glEnd(),gl*
474  * functions or those in mrpt::opengl::gl_utils to draw stuff *on the top* of
475  * the normal
476  * objects contained in the COpenGLScene.
477  *
478  * IMPORTANTE NOTICE: Event handlers in your observer class will most likely
479  * be invoked from an internal GUI thread of MRPT,
480  * so all your code in the handler must be thread safe.
481  */
483 {
484  protected:
485  /** Just to allow this class to be polymorphic */
486  void do_nothing() override {}
487 
488  public:
490  : source_viewport(obj)
491  {
492  }
494 }; // End of class def.
495 
496 /** @} */
497 
498 } // namespace mrpt::opengl
CSetOfLines.h
TRenderMatrices.h
mrpt::system::mrptEvent
The basic event type for the observer-observable pattern in MRPT.
Definition: mrptEvent.h:31
mrpt::opengl::COpenGLViewport::empty
bool empty() const
Definition: COpenGLViewport.h:312
mrpt::opengl::COpenGLViewport::size
size_t size() const
Number of objects contained.
Definition: COpenGLViewport.h:311
mrpt::opengl::mrptEventGLPreRender::do_nothing
void do_nothing() override
Just to allow this class to be polymorphic.
Definition: COpenGLViewport.h:460
mrpt::opengl::COpenGLViewport::m_borderColor
mrpt::img::TColor m_borderColor
Definition: COpenGLViewport.h:375
mrpt::opengl::COpenGLViewport::m_isImageView
bool m_isImageView
Set by setImageView.
Definition: COpenGLViewport.h:385
mrpt::opengl::COpenGLViewport::m_lights
TLightParameters m_lights
Definition: COpenGLViewport.h:415
mrpt::opengl::COpenGLViewport::setImageView
void setImageView(const mrpt::img::CImage &img)
Set this viewport into "image view"-mode, where an image is efficiently drawn (fitting the viewport a...
Definition: COpenGLViewport.cpp:868
mrpt::opengl::COpenGLViewport::unloadShaders
void unloadShaders()
Unload shader programs in m_shaders.
Definition: COpenGLViewport.cpp:185
mrpt::opengl::COpenGLViewport::lightParameters
const TLightParameters & lightParameters() const
Definition: COpenGLViewport.h:123
mrpt::opengl::COpenGLViewport::m_parent
mrpt::safe_ptr< COpenGLScene > m_parent
The scene that contains this viewport.
Definition: COpenGLViewport.h:361
opengl_frwds.h
mrpt::math::TPoint3D_< double >
DEFINE_SERIALIZABLE
#define DEFINE_SERIALIZABLE(class_name, NS)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
Definition: CSerializable.h:152
mrpt::opengl::COpenGLViewport::m_name
std::string m_name
The viewport's name.
Definition: COpenGLViewport.h:369
mrpt::opengl::COpenGLViewport::getCurrentCameraPose
void getCurrentCameraPose(mrpt::poses::CPose3D &out_cameraPose) const
Compute the current 3D camera pose.
Definition: COpenGLViewport.cpp:849
CCamera.h
mrpt::opengl::COpenGLViewport::iterator
CListOpenGLObjects::iterator iterator
Definition: COpenGLViewport.h:241
mrpt::opengl::COpenGLViewport::isPolygonNicestEnabled
bool isPolygonNicestEnabled() const
Definition: COpenGLViewport.h:121
mrpt::opengl::COpenGLViewport::m_view_width
double m_view_width
Definition: COpenGLViewport.h:378
mrpt::opengl::COpenGLViewport::m_shaders
std::map< shader_id_t, mrpt::opengl::Program::Ptr > m_shaders
Default shader program.
Definition: COpenGLViewport.h:396
CSetOfObjects.h
mrpt::opengl::COpenGLScene
This class allows the user to create, load, save, and render 3D scenes using OpenGL primitives.
Definition: COpenGLScene.h:56
mrptEvent.h
mrpt::opengl::COpenGLViewport::setNormalMode
void setNormalMode()
Resets the viewport to a normal 3D viewport.
Definition: COpenGLViewport.cpp:858
mrpt::opengl::COpenGLViewport::setBorderSize
void setBorderSize(unsigned int lineWidth)
Set the border size ("frame") of the viewport (default=0)
Definition: COpenGLViewport.h:186
mrpt::opengl::COpenGLViewport::getBoundingBox
void getBoundingBox(mrpt::math::TPoint3D &bb_min, mrpt::math::TPoint3D &bb_max) const
Evaluates the bounding box of this object (including possible children) in the coordinate frame of th...
Definition: COpenGLViewport.cpp:893
mrpt::opengl::mrptEventGLPostRender
An event sent by an mrpt::opengl::COpenGLViewport after calling the scene OpenGL drawing primitives a...
Definition: COpenGLViewport.h:482
mrpt::opengl::COpenGLViewport::m_camera
opengl::CCamera m_camera
The camera associated to the viewport.
Definition: COpenGLViewport.h:359
mrpt::opengl::COpenGLViewport::m_borderWidth
uint32_t m_borderWidth
Default=0, the border around the viewport.
Definition: COpenGLViewport.h:373
mrpt::opengl::COpenGLViewport::end
iterator end()
Definition: COpenGLViewport.h:246
CTextMessageCapable.h
mrpt::opengl::COpenGLViewport::m_imageview_plane
mrpt::opengl::CTexturedPlane::Ptr m_imageview_plane
The image to display, after calling setImageView()
Definition: COpenGLViewport.h:388
mrpt::opengl::COpenGLViewport::m_custom_backgb_color
bool m_custom_backgb_color
Definition: COpenGLViewport.h:381
mrpt::opengl::COpenGLViewport::render
void render(const int render_width, const int render_height, const int render_offset_x=0, const int render_offset_y=0) const
Render the objects in this viewport (called from COpenGLScene)
Definition: COpenGLViewport.cpp:458
mrpt::opengl::COpenGLViewport::m_background_color
mrpt::img::TColorf m_background_color
used only if m_custom_backgb_color
Definition: COpenGLViewport.h:383
mrpt::opengl::CTexturedPlane::Ptr
std::shared_ptr< mrpt::opengl ::CTexturedPlane > Ptr
Definition: CTexturedPlane.h:22
mrpt::opengl::COpenGLViewport::m_view_x
double m_view_x
The viewport position [0,1].
Definition: COpenGLViewport.h:378
mrpt::opengl::COpenGLViewport::end
const_iterator end() const
Definition: COpenGLViewport.h:244
mrpt::opengl::COpenGLViewport::initializeTextures
void initializeTextures()
Initializes all textures in the scene (See opengl::CTexturedPlane::initializeTextures)
Definition: COpenGLViewport.cpp:662
mrpt::opengl::CRenderizable::Ptr
std::shared_ptr< CRenderizable > Ptr
Definition: CRenderizable.h:50
mrpt::opengl::COpenGLViewport::getCustomBackgroundColor
mrpt::img::TColorf getCustomBackgroundColor() const
Definition: COpenGLViewport.h:210
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: BaseAppDataSource.h:15
mrpt::opengl::COpenGLViewport::insert
void insert(const CRenderizable::Ptr &newObject)
Insert a new object into the list.
Definition: COpenGLViewport.cpp:99
mrpt::opengl::COpenGLViewport::clear
void clear()
Delete all internal obejcts.
Definition: COpenGLViewport.cpp:95
TLightParameters.h
mrpt::opengl::COpenGLViewport::dumpListOfObjects
void dumpListOfObjects(std::vector< std::string > &lst)
Retrieves a list of all objects in text form.
Definition: COpenGLViewport.cpp:667
mrpt::opengl::COpenGLViewport::getCamera
opengl::CCamera & getCamera()
Get a reference to the camera associated with this viewport.
Definition: COpenGLViewport.h:314
mrpt::opengl::COpenGLViewport::loadDefaultShaders
void loadDefaultShaders() const
Load all MPRT predefined shader programs into m_shaders.
Definition: COpenGLViewport.cpp:187
mrpt::opengl::COpenGLViewport::renderImageMode
void renderImageMode() const
Render in image mode.
Definition: COpenGLViewport.cpp:129
mrpt::opengl::mrptEventGLPostRender::mrptEventGLPostRender
mrptEventGLPostRender(const COpenGLViewport *obj)
Definition: COpenGLViewport.h:489
mrpt::opengl::COpenGLViewport::m_isCloned
bool m_isCloned
Set by setCloneView.
Definition: COpenGLViewport.h:363
mrpt::opengl::CTextMessageCapable
Keeps a list of text messages which can be rendered to OpenGL contexts by graphic classes.
Definition: CTextMessageCapable.h:22
mrpt::opengl::COpenGLViewport::getViewportPosition
void getViewportPosition(double &x, double &y, double &width, double &height)
Get the current viewport position and dimension on the rendering window.
Definition: COpenGLViewport.cpp:83
mrpt::opengl::mrptEventGLPostRender::do_nothing
void do_nothing() override
Just to allow this class to be polymorphic.
Definition: COpenGLViewport.h:486
mrpt::opengl::COpenGLViewport::m_view_y
double m_view_y
Definition: COpenGLViewport.h:378
mrpt::opengl::COpenGLViewport::begin
iterator begin()
Definition: COpenGLViewport.h:245
mrpt::utils::CImage
mrpt::img::CImage CImage
Definition: utils/CImage.h:5
bb_max
const auto bb_max
Definition: CPose3DPDFGrid_unittest.cpp:25
Shader.h
mrpt::opengl::CSetOfObjects
A set of object, which are referenced to the coordinates framework established in this object.
Definition: CSetOfObjects.h:26
mrpt::opengl::mrptEventGLPreRender
An event sent by an mrpt::opengl::COpenGLViewport just after clearing the viewport and setting the GL...
Definition: COpenGLViewport.h:456
mrpt::opengl::COpenGLViewport::setCustomBackgroundColor
void setCustomBackgroundColor(const mrpt::img::TColorf &color)
Set a background color different from that of the parent GUI window.
Definition: COpenGLViewport.h:204
mrpt::opengl::mrptEventGLPostRender::source_viewport
const COpenGLViewport *const source_viewport
Definition: COpenGLViewport.h:493
mrpt::opengl::COpenGLViewport::setViewportClipDistances
void setViewportClipDistances(const float clip_min, const float clip_max)
Set the min/max clip depth distances of the rendering frustum (default: 0.1 - 10000)
Definition: COpenGLViewport.cpp:707
bb_min
const auto bb_min
Definition: CPose3DPDFGrid_unittest.cpp:23
mrpt::opengl::COpenGLViewport::setTransparent
void setTransparent(bool trans)
Set the transparency, that is, whether the viewport will be rendered transparent over previous viewpo...
Definition: COpenGLViewport.h:202
mrpt::img
Definition: CCanvas.h:16
mrpt::opengl::COpenGLViewport::m_objects
opengl::CListOpenGLObjects m_objects
The list of objects that comprise the 3D scene.
Definition: COpenGLViewport.h:408
mrpt::opengl::COpenGLViewport::Ptr
std::shared_ptr< mrpt::opengl ::COpenGLViewport > Ptr
Definition: COpenGLViewport.h:65
CObservable.h
mrpt::opengl::COpenGLViewport::resetCloneView
void resetCloneView()
Reset the viewport to normal mode: rendering its own objects.
Definition: COpenGLViewport.h:99
MRPT_START
#define MRPT_START
Definition: exceptions.h:241
mrpt::opengl::COpenGLViewport::getByName
CRenderizable::Ptr getByName(const std::string &str)
Returns the first object with a given name, or nullptr if not found.
Definition: COpenGLViewport.cpp:643
mrpt::opengl::COpenGLViewport::m_borderLines
mrpt::opengl::CSetOfLines::Ptr m_borderLines
Definition: COpenGLViewport.h:390
mrpt::poses::CPose3D
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:85
mrpt::opengl::CSetOfLines::Ptr
std::shared_ptr< mrpt::opengl ::CSetOfLines > Ptr
Definition: CSetOfLines.h:35
mrpt::opengl::COpenGLViewport::setBorderColor
void setBorderColor(const mrpt::img::TColor &c)
Definition: COpenGLViewport.h:192
mrpt::opengl::COpenGLViewport::getName
std::string getName()
Returns the name of the viewport.
Definition: COpenGLViewport.h:132
mrpt::img::TColorf
An RGBA color - floats in the range [0,1].
Definition: TColor.h:88
mrpt::opengl::mrptEventGLPreRender::mrptEventGLPreRender
mrptEventGLPreRender(const COpenGLViewport *obj)
Definition: COpenGLViewport.h:463
mrpt::opengl::COpenGLViewport::m_clip_min
float m_clip_min
The min/max clip depth distances (default: 0.1 - 10000)
Definition: COpenGLViewport.h:380
mrpt::opengl::operator<<
COpenGLScene::Ptr & operator<<(COpenGLScene::Ptr &s, const CRenderizable::Ptr &r)
Inserts an openGL object into a scene.
Definition: COpenGLScene.h:252
mrpt::opengl::CCamera
A camera: if added to a scene, the viewpoint defined by this camera will be used instead of the camer...
Definition: CCamera.h:33
mrpt::img::TColor
A RGB color - 8bit.
Definition: TColor.h:25
CLASS_ID_NAMESPACE
#define CLASS_ID_NAMESPACE(class_name, namespaceName)
Definition: CObject.h:105
mrpt::serialization::CSerializable
The virtual base class which provides a unified interface for all persistent objects in MRPT.
Definition: CSerializable.h:30
mrpt::opengl::COpenGLViewport::setCurrentCameraFromPose
void setCurrentCameraFromPose(mrpt::poses::CPose3D &p)
Changes the point of view of the camera, from a given pose.
Definition: COpenGLViewport.cpp:843
mrpt::opengl::COpenGLViewport::getBorderColor
const mrpt::img::TColor & getBorderColor() const
Definition: COpenGLViewport.h:193
mrpt::opengl::COpenGLViewport::begin
const_iterator begin() const
Definition: COpenGLViewport.h:243
mrpt::opengl::COpenGLViewport::setViewportPosition
void setViewportPosition(const double x, const double y, const double width, const double height)
Change the viewport position and dimension on the rendering window.
Definition: COpenGLViewport.cpp:65
mrpt::opengl::COpenGLViewport::enablePolygonNicest
void enablePolygonNicest(bool enable=true)
Sets glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST) is enabled, or GL_FASTEST otherwise.
Definition: COpenGLViewport.h:117
mrpt::opengl::COpenGLViewport::m_clonedViewport
std::string m_clonedViewport
Only if m_isCloned=true.
Definition: COpenGLViewport.h:367
mrpt::opengl::COpenGLViewport::m_isClonedCamera
bool m_isClonedCamera
Set by setCloneCamera.
Definition: COpenGLViewport.h:365
mrpt::opengl::COpenGLViewport::~COpenGLViewport
~COpenGLViewport() override
Destructor: clears all objects.
Definition: COpenGLViewport.cpp:56
mrpt::opengl::COpenGLViewport::m_isTransparent
bool m_isTransparent
Whether to clear color buffer.
Definition: COpenGLViewport.h:371
safe_pointers.h
mrpt::opengl::TRenderMatrices
Rendering state related to the projection and model-view matrices.
Definition: TRenderMatrices.h:25
mrpt::opengl::COpenGLViewport::m_state
TRenderMatrices m_state
Info updated with each "render()" and used in "get3DRayForPixelCoord".
Definition: COpenGLViewport.h:393
mrpt::opengl::mrptEventGLPreRender::source_viewport
const COpenGLViewport *const source_viewport
Definition: COpenGLViewport.h:467
mrpt::opengl::COpenGLViewport::renderViewportBorder
void renderViewportBorder() const
Render the viewport border, if enabled.
Definition: COpenGLViewport.cpp:342
mrpt::opengl::COpenGLViewport::COpenGLViewport
COpenGLViewport(COpenGLScene *parent=nullptr, const std::string &name=std::string(""))
Constructor, invoked from COpenGLScene only.
Definition: COpenGLViewport.cpp:51
mrpt::opengl::COpenGLViewport::const_iterator
CListOpenGLObjects::const_iterator const_iterator
Definition: COpenGLViewport.h:240
MRPT_END
#define MRPT_END
Definition: exceptions.h:245
mrpt::opengl::CListOpenGLObjects
std::deque< CRenderizable::Ptr > CListOpenGLObjects
A list of smart pointers to renderizable objects.
Definition: CRenderizable.h:376
mrpt::opengl::COpenGLViewport::m_OpenGL_enablePolygonNicest
bool m_OpenGL_enablePolygonNicest
Definition: COpenGLViewport.h:413
mrpt::opengl::COpenGLViewport
A viewport within a COpenGLScene, containing a set of OpenGL objects to render.
Definition: COpenGLViewport.h:61
mrpt::opengl::COpenGLViewport::getBorderSize
unsigned int getBorderSize() const
Definition: COpenGLViewport.h:190
mrpt::opengl::COpenGLViewport::renderTextMessages
void renderTextMessages() const
Renders all messages in the underlying class CTextMessageCapable.
Definition: COpenGLViewport.cpp:383
mrpt::opengl::COpenGLViewport::getViewportClipDistances
void getViewportClipDistances(float &clip_min, float &clip_max) const
Get the current min/max clip depth distances of the rendering frustum (default: 0....
Definition: COpenGLViewport.cpp:716
mrpt::opengl::COpenGLViewport::setCloneCamera
void setCloneCamera(bool enable)
If set to true, and setCloneView() has been called, this viewport will be rendered using the camera o...
Definition: COpenGLViewport.h:103
mrpt::math::TLine3D
3D line, represented by a base point and a director vector.
Definition: TLine3D.h:19
mrpt::opengl::COpenGLViewport::internal_enableImageView
void internal_enableImageView()
Definition: COpenGLViewport.cpp:879
mrpt::opengl::COpenGLViewport::m_clip_max
float m_clip_max
Definition: COpenGLViewport.h:380
CImage.h
mrpt::opengl::COpenGLViewport::setCloneView
void setCloneView(const std::string &clonedViewport)
Set this viewport as a clone of some other viewport, given its name - as a side effect,...
Definition: COpenGLViewport.cpp:58
mrpt::opengl::TLightParameters
Lighting parameters, mostly for triangle shaders.
Definition: TLightParameters.h:22
CSerializable.h
mrpt::opengl
The namespace for 3D scene representation and rendering.
Definition: CGlCanvasBase.h:13
mrpt::opengl::COpenGLViewport::get3DRayForPixelCoord
void get3DRayForPixelCoord(const double x_coord, const double y_coord, mrpt::math::TLine3D &out_ray, mrpt::poses::CPose3D *out_cameraPose=nullptr) const
Compute the 3D ray corresponding to a given pixel; this can be used to allow the user to pick and sel...
Definition: COpenGLViewport.cpp:726
mrpt::opengl::COpenGLViewport::renderNormalSceneMode
void renderNormalSceneMode() const
Render a normal scene with 3D objects.
Definition: COpenGLViewport.cpp:210
mrpt::opengl::COpenGLViewport::isTransparent
bool isTransparent()
Return whether the viewport will be rendered transparent over previous viewports.
Definition: COpenGLViewport.h:198
mrpt::opengl::COpenGLViewport::getByClass
T::Ptr getByClass(size_t ith=0) const
Returns the i'th object of a given class (or of a descendant class), or nullptr (an empty smart point...
Definition: COpenGLViewport.h:280
mrpt::opengl::COpenGLViewport::getCamera
const opengl::CCamera & getCamera() const
Get a reference to the camera associated with this viewport.
Definition: COpenGLViewport.h:316
mrpt::system::CObservable
Inherit from this class for those objects capable of being observed by a CObserver class.
Definition: CObservable.h:31
mrpt::opengl::COpenGLViewport::m_view_height
double m_view_height
Definition: COpenGLViewport.h:378
mrpt::safe_ptr
A wrapper class for pointers that can be safely copied with "=" operator without problems.
Definition: safe_pointers.h:71
CTexturedPlane.h
mrpt::opengl::COpenGLViewport::lightParameters
TLightParameters & lightParameters()
Definition: COpenGLViewport.h:124
mrpt::opengl::COpenGLViewport::removeObject
void removeObject(const CRenderizable::Ptr &obj)
Removes the given object from the scene (it also deletes the object to free its memory).
Definition: COpenGLViewport.cpp:693



Page generated by Doxygen 1.8.17 for MRPT 2.0.3 at Thu May 21 21:53:32 UTC 2020