Main MRPT website > C++ reference for MRPT 1.9.9
COpenGLViewport.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #pragma once
10 
13 #include <mrpt/img/CImage.h>
14 #include <mrpt/opengl/CCamera.h>
16 #include <mrpt/opengl/CLight.h>
20 #include <mrpt/system/mrptEvent.h>
21 
22 namespace mrpt
23 {
24 namespace img
25 {
26 class CImage;
27 }
28 namespace opengl
29 {
30 /** A viewport within a COpenGLScene, containing a set of OpenGL objects to
31  *render.
32  * This class has protected constuctor, thus it cannot be created by users.
33  *Use COpenGLScene::createViewport instead.
34  * A viewport has these "operation modes":
35  * - Normal (default): It renders the contained objects.
36  * - Cloned: It clones the objects from another viewport. See \a
37  *setCloneView()
38  * - Image mode: It renders an image (e.g. from a video stream) efficiently
39  *using a textued quad. See \a setImageView().
40  *
41  * In any case, the viewport can be resized to only fit a part of the entire
42  *parent viewport.
43  * There will be always at least one viewport in a COpenGLScene named "main".
44  *
45  * This class can be observed (see mrpt::system::CObserver) for the following
46  *events (see mrpt::system::mrptEvent):
47  * - mrpt::opengl::mrptEventGLPreRender
48  * - mrpt::opengl::mrptEventGLPostRender
49  *
50  * Two directional light sources at infinity are created by default, with
51  *directions (-1,-1,-1) and (1,2,1), respectively.
52  * All OpenGL properties of light sources are accesible via the methods:
53  *setNumberOfLights(), lightsClearAll(), addLight(), and getLight().
54  * Please, refer to mrpt::opengl::CLight and the standard OpenGL documentation
55  *for the meaning of all light properties.
56  *
57  * Refer to mrpt::opengl::COpenGLScene for further details.
58  * \ingroup mrpt_opengl_grp
59  */
62 {
64  friend class COpenGLScene;
65 
66  public:
67  // -------------------------------------------------------------------
68  /** @name Set the viewport "modes"
69  @{ */
70 
71  /** Set this viewport as a clone of some other viewport, given its name - as
72  * a side effect, current list of internal OpenGL objects is cleared.
73  * By default, only the objects are cloned, not the camera. See
74  * \sa resetCloneView
75  */
76  void setCloneView(const std::string& clonedViewport);
77 
78  /** Set this viewport into "image view"-mode, where an image is efficiently
79  * drawn (fitting the viewport area) using an OpenGL textured quad.
80  * Call this method with the new image to update the displayed image (but
81  * recall to first lock the parent openglscene's critical section, then do
82  * the update, then release the lock, and then issue a window repaint).
83  * Internally, the texture is drawn using a mrpt::opengl::CTexturedPlane
84  * The viewport can be reverted to behave like a normal viewport by
85  * calling setNormalMode()
86  * \sa setImageView_fast
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  */
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  /** @} */ // end of Set the "viewport mode"
109  // ------------------------------------------------------
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  /** Removes all lights (and disables the global "GL_LIGHTING") */
123  void lightsClearAll() { m_lights.clear(); }
124  /** Append a new light to the scene. By default there are two lights.
125  * "GL_LIGHTING" is disabled if all lights are removed */
126  void addLight(const CLight& l) { m_lights.push_back(l); }
127  /** Allocates a number of lights, which must be correctly defined via
128  * getLight(i), etc. */
129  void setNumberOfLights(const size_t N) { m_lights.resize(N); }
130  CLight& getLight(const size_t i)
131  {
132  ASSERT_BELOW_(i, m_lights.size());
133  return m_lights[i];
134  }
135  const CLight& getLight(const size_t i) const
136  {
137  ASSERT_BELOW_(i, m_lights.size());
138  return m_lights[i];
139  }
140 
141  /** @} */ // end of OpenGL settings
142 
143  // -------------------------------------------------------------------
144  /** @name Change or read viewport properties (except "viewport modes")
145  @{ */
146 
147  /** Returns the name of the viewport */
148  inline std::string getName() { return m_name; }
149  /** Change the viewport position and dimension on the rendering window.
150  * X & Y coordinates here can have two interpretations:
151  * - If in the range [0,1], they are factors with respect to the actual
152  *window sizes (i.e. width=1 means the entire width of the rendering
153  *window).
154  * - If >1, they are interpreted as pixels.
155  *
156  * width & height can be interpreted as:
157  * - If >1, they are the size of the viewport in that dimension, in
158  *pixels.
159  * - If in [0,1], they are the size of the viewport in that dimension,
160  *in
161  *a factor of the width/height.
162  * - If in [-1,0[, the size is computed such as the right/top border
163  *ends
164  *up in the given coordinate, interpreted as a factor (e.g. -1: up to the
165  *end of the viewport, -0.5: up to the middle of it).
166  * - If <-1 the size is computed such as the right/top border ends up
167  *in
168  *the given absolute coordinate (e.g. -200: up to the row/column 200px).
169  *
170  * \note (x,y) specify the lower left corner of the viewport rectangle.
171  * \sa getViewportPosition
172  */
173  void setViewportPosition(
174  const double x, const double y, const double width,
175  const double height);
176 
177  /** Get the current viewport position and dimension on the rendering window.
178  * X & Y coordinates here can have two interpretations:
179  * - If in the range [0,1], they are factors with respect to the actual
180  * window sizes (i.e. width=1 means the entire width of the rendering
181  * window).
182  * - If >1, they are interpreted as pixels.
183  * \note (x,y) specify the lower left corner of the viewport rectangle.
184  * \sa setViewportPosition
185  */
186  void getViewportPosition(
187  double& x, double& y, double& width, double& height);
188 
189  /** Set the min/max clip depth distances of the rendering frustum (default:
190  * 0.1 - 10000)
191  * \sa getViewportClipDistances
192  */
193  void setViewportClipDistances(const double clip_min, const double clip_max);
194 
195  /** Get the current min/max clip depth distances of the rendering frustum
196  * (default: 0.1 - 10000)
197  * \sa setViewportClipDistances
198  */
199  void getViewportClipDistances(double& clip_min, double& clip_max) const;
200 
201  /** Set the border size ("frame") of the viewport (default=0).
202  */
203  inline void setBorderSize(unsigned int lineWidth)
204  {
205  m_borderWidth = lineWidth;
206  }
207 
208  /** Return whether the viewport will be rendered transparent over previous
209  * viewports.
210  */
211  inline bool isTransparent() { return m_isTransparent; }
212  /** Set the transparency, that is, whether the viewport will be rendered
213  * transparent over previous viewports (default=false).
214  */
215  inline void setTransparent(bool trans) { m_isTransparent = trans; }
216  /** Set a background color different from that of the parent GUI window */
218  {
219  m_custom_backgb_color = true;
221  }
222 
224  {
225  return m_background_color;
226  }
227 
228  /** Compute the 3D ray corresponding to a given pixel; this can be used to
229  * allow the user to pick and select 3D objects by clicking onto the 2D
230  * image.
231  * \param x_coord Horizontal coordinate with the usual meaning (0:left of
232  * the viewport, W-1: right border).
233  * \param y_coord Horizontal coordinate with the usual meaning (0:top of
234  * the viewport, H-1: right border).
235  * \param out_cameraPose If not nullptr, will have the camera 3D pose as a
236  * mrpt::poses::CPose3D. See also
237  * \note (x,y) refer to VIEWPORT coordinates. Take into account this when
238  * viewports do not extend to the whole window size.
239  * \note x and y are double instead of integers to allow sub-pixel
240  * precision.
241  * \sa getCurrentCameraPose
242  */
244  const double x_coord, const double y_coord,
245  mrpt::math::TLine3D& out_ray,
246  mrpt::poses::CPose3D* out_cameraPose = nullptr) const;
247 
248  /** @} */ // end of Change or read viewport properties
249  // ------------------------------------------------------
250 
251  // -------------------------------------------------------------------
252  /** @name Contained objects set/get/search
253  @{ */
254 
257 
258  inline const_iterator begin() const { return m_objects.begin(); }
259  inline const_iterator end() const { return m_objects.end(); }
260  inline iterator begin() { return m_objects.begin(); }
261  inline iterator end() { return m_objects.end(); }
262  /** Delete all internal obejcts
263  * \sa insert */
264  void clear();
265 
266  /** Insert a new object into the list.
267  * The object MUST NOT be deleted, it will be deleted automatically by
268  * this object when not required anymore.
269  */
270  void insert(const CRenderizable::Ptr& newObject);
271 
272  /** Compute the current 3D camera pose.
273  * \sa get3DRayForPixelCoord
274  */
275  void getCurrentCameraPose(mrpt::poses::CPose3D& out_cameraPose) const;
276 
277  /** Returns the first object with a given name, or nullptr if not found.
278  */
280 
281  /** Returns the i'th object of a given class (or of a descendant class), or
282  nullptr (an empty smart pointer) if not found.
283  * Example:
284  * \code
285  CSphere::Ptr obs = view.getByClass<CSphere>();
286  * \endcode
287  * By default (ith=0), the first observation is returned.
288  */
289  template <typename T>
290  typename T::Ptr getByClass(const size_t& ith = 0) const
291  {
292  MRPT_START
293  size_t foundCount = 0;
294  const auto* class_ID = &T::GetRuntimeClassIdStatic();
295  for (const auto& o : m_objects)
296  if (o && o->GetRuntimeClass()->derivedFrom(class_ID))
297  if (foundCount++ == ith) return std::dynamic_pointer_cast<T>(o);
298 
299  // If not found directly, search recursively:
300  for (const auto& o : m_objects)
301  {
302  if (o &&
303  o->GetRuntimeClass() ==
305  {
306  typename T::Ptr obj = std::dynamic_pointer_cast<T>(
307  std::dynamic_pointer_cast<CSetOfObjects>(o)
308  ->template getByClass<T>(ith));
309  if (obj) return obj;
310  }
311  }
312  return typename T::Ptr(); // Not found: return empty smart pointer
313  MRPT_END
314  }
315 
316  /** Removes the given object from the scene (it also deletes the object to
317  * free its memory).
318  */
319  void removeObject(const CRenderizable::Ptr& obj);
320 
321  /** Number of objects contained. */
322  inline size_t size() const { return m_objects.size(); }
323  inline bool empty() const { return m_objects.empty(); }
324  /** Get a reference to the camera associated with this viewport. */
326  /** Get a reference to the camera associated with this viewport. */
327  const opengl::CCamera& getCamera() const { return m_camera; }
328  /** Evaluates the bounding box of this object (including possible children)
329  * in the coordinate frame of the object parent. */
330  void getBoundingBox(
331  mrpt::math::TPoint3D& bb_min, mrpt::math::TPoint3D& bb_max) const;
332 
333  /** @} */ // end of Contained objects set/get/search
334  // ------------------------------------------------------
335 
336  /** Destructor: clears all objects. */
337  virtual ~COpenGLViewport();
338 
339  protected:
340  /** Constructor, invoked from COpenGLScene only.
341  */
343  COpenGLScene* parent = nullptr,
344  const std::string& name = std::string(""));
345 
346  /** Initializes all textures in the scene (See
347  * opengl::CTexturedPlane::loadTextureInOpenGL)
348  */
349  void initializeAllTextures();
350 
351  /** Retrieves a list of all objects in text form.
352  */
353  void dumpListOfObjects(std::vector<std::string>& lst);
354 
355  /** Render the objects in this viewport (called from COpenGLScene only) */
356  void render(const int render_width, const int render_height) const;
357 
358  /** The camera associated to the viewport */
360  /** The scene that contains this viewport. */
362  /** Set by setCloneView */
364  /** Set by setCloneCamera */
366  /** Only if m_isCloned=true */
368  /** The viewport's name */
370  /** Whether to clear color buffer. */
372  /** Default=0, the border around the viewport. */
374  /** The viewport position [0,1] */
376  /** The min/max clip depth distances (default: 0.1 - 10000) */
379  /** used only if m_custom_backgb_color */
381  /** Set by setImageView */
383  // CRenderizable::Ptr m_imageview_quad ; //!< A mrpt::opengl::CTexturedPlane
384  // used after setImageView() is called
385  /** The image to display, after calling \a setImageView() */
387 
389  {
391  : eye(0, 0, 0),
392  pointing(0, 0, 0),
393  up(0, 0, 0),
394  viewport_width(640),
395  viewport_height(480),
396  FOV(30),
397  azimuth(0),
398  elev(0),
399  zoom(1),
400  is_projective(true)
401  {
402  }
403  /** The camera is here. */
405  /** The camera points to here */
407  /** Up vector of the camera. */
409  /** In pixels. This may be smaller than the total render window. */
411  /** FOV in degrees. */
412  float FOV;
413  /** Camera elev & azimuth, in radians. */
414  float azimuth, elev;
415  float zoom;
416  bool is_projective; // true: projective, false: ortho
417  };
418  /** Info updated with each "render()" and used in "get3DRayForPixelCoord" */
420 
421  /** The list of objects that comprise the 3D scene.
422  * Objects are automatically deleted when calling "clear" or in the
423  * destructor.
424  */
426 
427  void internal_setImageView_fast(const mrpt::img::CImage& img, bool is_fast);
428 
429  // OpenGL global settings:
431 
432  std::vector<CLight> m_lights;
433 };
434 /**
435  * Inserts an openGL object into a viewport. Allows call chaining.
436  * \sa mrpt::opengl::COpenGLViewport::insert
437  */
440 {
441  s->insert(r);
442  return s;
443 }
444 /**
445  * Inserts any iterable set of openGL objects into a viewport. Allows call
446  * chaining.
447  * \sa mrpt::opengl::COpenGLViewport::insert
448  */
450  COpenGLViewport::Ptr& s, const std::vector<CRenderizable::Ptr>& v)
451 {
453  it != v.end(); ++it)
454  s->insert(*it);
455  return s;
456 }
457 
458 /** @name Events emitted by COpenGLViewport
459  @{ */
460 
461 /** An event sent by an mrpt::opengl::COpenGLViewport just after clearing the
462  * viewport and setting the GL_PROJECTION matrix, and before calling the scene
463  * OpenGL drawing primitives.
464  *
465  * While handling this event you can call OpenGL glBegin(),glEnd(),gl*
466  * functions or those in mrpt::opengl::gl_utils to draw stuff *in the back* of
467  * the normal
468  * objects contained in the COpenGLScene.
469  *
470  * After processing this event, COpenGLViewport will change the OpenGL matrix
471  * mode into "GL_MODELVIEW" and load an identity matrix to continue
472  * rendering the scene objects as usual. Any change done to the GL_PROJECTION
473  * will have effects, so do a glPushMatrix()/glPopMatrix() if that is not your
474  * intention.
475  *
476  *
477  * IMPORTANTE NOTICE: Event handlers in your observer class will most likely
478  * be invoked from an internal GUI thread of MRPT,
479  * so all your code in the handler must be thread safe.
480  */
482 {
483  protected:
484  /** Just to allow this class to be polymorphic */
485  void do_nothing() override {}
486  public:
489  {
490  }
492 }; // End of class def.
493 
494 /** An event sent by an mrpt::opengl::COpenGLViewport after calling the scene
495  * OpenGL drawing primitives and before doing a glSwapBuffers
496  *
497  * While handling this event you can call OpenGL glBegin(),glEnd(),gl*
498  * functions or those in mrpt::opengl::gl_utils to draw stuff *on the top* of
499  * the normal
500  * objects contained in the COpenGLScene.
501  *
502  * IMPORTANTE NOTICE: Event handlers in your observer class will most likely
503  * be invoked from an internal GUI thread of MRPT,
504  * so all your code in the handler must be thread safe.
505  */
507 {
508  protected:
509  /** Just to allow this class to be polymorphic */
510  void do_nothing() override {}
511  public:
514  {
515  }
517 }; // End of class def.
518 
519 /** @} */
520 
521 } // namespace opengl
522 
523 } // namespace mrpt
mrpt::system::mrptEvent
The basic event type for the observer-observable pattern in MRPT.
Definition: mrptEvent.h:33
mrpt::opengl::COpenGLViewport::empty
bool empty() const
Definition: COpenGLViewport.h:323
mrpt::opengl::COpenGLViewport::getLight
const CLight & getLight(const size_t i) const
Definition: COpenGLViewport.h:135
mrpt::opengl::COpenGLViewport::size
size_t size() const
Number of objects contained.
Definition: COpenGLViewport.h:322
mrpt::opengl::mrptEventGLPreRender::do_nothing
void do_nothing() override
Just to allow this class to be polymorphic.
Definition: COpenGLViewport.h:485
mrpt::opengl::COpenGLViewport::m_isImageView
bool m_isImageView
Set by setImageView.
Definition: COpenGLViewport.h:382
mrpt::opengl::COpenGLViewport::TLastProjectiveMatrixInfo::eye
mrpt::math::TPoint3D eye
The camera is here.
Definition: COpenGLViewport.h:404
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:883
const_iterator
const Scalar * const_iterator
Definition: eigen_plugins.h:27
mrpt::opengl::COpenGLViewport::TLastProjectiveMatrixInfo
Definition: COpenGLViewport.h:388
mrpt::opengl::COpenGLViewport::m_lights
std::vector< CLight > m_lights
Definition: COpenGLViewport.h:432
CLight.h
mrpt::opengl::COpenGLViewport::m_parent
mrpt::safe_ptr< COpenGLScene > m_parent
The scene that contains this viewport.
Definition: COpenGLViewport.h:361
s
GLdouble s
Definition: glext.h:3676
mrpt::opengl::COpenGLViewport::TLastProjectiveMatrixInfo::FOV
float FOV
FOV in degrees.
Definition: COpenGLViewport.h:412
opengl_frwds.h
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:864
CCamera.h
mrpt::opengl::COpenGLViewport::iterator
CListOpenGLObjects::iterator iterator
Definition: COpenGLViewport.h:256
mrpt::opengl::COpenGLViewport::isPolygonNicestEnabled
bool isPolygonNicestEnabled() const
Definition: COpenGLViewport.h:121
mrpt::opengl::COpenGLViewport::m_view_width
double m_view_width
Definition: COpenGLViewport.h:375
CSetOfObjects.h
mrpt::opengl::COpenGLScene
This class allows the user to create, load, save, and render 3D scenes using OpenGL primitives.
Definition: COpenGLScene.h:59
mrptEvent.h
mrpt::opengl::COpenGLViewport::addLight
void addLight(const CLight &l)
Append a new light to the scene.
Definition: COpenGLViewport.h:126
mrpt::opengl::COpenGLViewport::setNormalMode
void setNormalMode()
Resets the viewport to a normal 3D viewport.
Definition: COpenGLViewport.cpp:873
mrpt::opengl::COpenGLViewport::setBorderSize
void setBorderSize(unsigned int lineWidth)
Set the border size ("frame") of the viewport (default=0).
Definition: COpenGLViewport.h:203
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:911
mrpt::opengl::mrptEventGLPostRender
An event sent by an mrpt::opengl::COpenGLViewport after calling the scene OpenGL drawing primitives a...
Definition: COpenGLViewport.h:506
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:261
mrpt::opengl::COpenGLViewport::m_custom_backgb_color
bool m_custom_backgb_color
Definition: COpenGLViewport.h:378
mrpt::opengl::COpenGLViewport::m_background_color
mrpt::img::TColorf m_background_color
used only if m_custom_backgb_color
Definition: COpenGLViewport.h:380
obj
GLsizei GLsizei GLuint * obj
Definition: glext.h:4070
mrpt::opengl::COpenGLViewport::m_view_x
double m_view_x
The viewport position [0,1].
Definition: COpenGLViewport.h:375
mrpt::opengl::COpenGLViewport::end
const_iterator end() const
Definition: COpenGLViewport.h:259
mrpt::opengl::COpenGLViewport::getLight
CLight & getLight(const size_t i)
Definition: COpenGLViewport.h:130
mrpt::opengl::COpenGLViewport::setImageView_fast
void setImageView_fast(mrpt::img::CImage &img)
Just like setImageView but moves the internal image memory instead of making a copy,...
Definition: COpenGLViewport.cpp:887
mrpt::opengl::COpenGLViewport::m_clip_min
double m_clip_min
The min/max clip depth distances (default: 0.1 - 10000)
Definition: COpenGLViewport.h:377
mrpt::opengl::COpenGLViewport::getViewportClipDistances
void getViewportClipDistances(double &clip_min, double &clip_max) const
Get the current min/max clip depth distances of the rendering frustum (default: 0....
Definition: COpenGLViewport.cpp:729
mrpt::opengl::CRenderizable::Ptr
std::shared_ptr< CRenderizable > Ptr
Definition: CRenderizable.h:45
mrpt::opengl::COpenGLViewport::getCustomBackgroundColor
mrpt::img::TColorf getCustomBackgroundColor() const
Definition: COpenGLViewport.h:223
mrpt::opengl::CLight
Each of the possible lights of a 3D scene.
Definition: CLight.h:24
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
mrpt::opengl::COpenGLViewport::insert
void insert(const CRenderizable::Ptr &newObject)
Insert a new object into the list.
Definition: COpenGLViewport.cpp:145
mrpt::opengl::COpenGLViewport::clear
void clear()
Delete all internal obejcts.
Definition: COpenGLViewport.cpp:141
mrpt::opengl::COpenGLViewport::TLastProjectiveMatrixInfo::is_projective
bool is_projective
Definition: COpenGLViewport.h:416
mrpt::opengl::COpenGLViewport::render
void render(const int render_width, const int render_height) const
Render the objects in this viewport (called from COpenGLScene only)
Definition: COpenGLViewport.cpp:153
mrpt::opengl::COpenGLViewport::dumpListOfObjects
void dumpListOfObjects(std::vector< std::string > &lst)
Retrieves a list of all objects in text form.
Definition: COpenGLViewport.cpp:672
mrpt::opengl::COpenGLViewport::getCamera
opengl::CCamera & getCamera()
Get a reference to the camera associated with this viewport.
Definition: COpenGLViewport.h:325
mrpt::opengl::COpenGLViewport::initializeAllTextures
void initializeAllTextures()
Initializes all textures in the scene (See opengl::CTexturedPlane::loadTextureInOpenGL)
Definition: COpenGLViewport.cpp:656
mrpt::opengl::COpenGLViewport::m_clip_max
double m_clip_max
Definition: COpenGLViewport.h:377
name
GLuint const GLchar * name
Definition: glext.h:4054
mrpt::opengl::COpenGLViewport::lightsClearAll
void lightsClearAll()
Removes all lights (and disables the global "GL_LIGHTING")
Definition: COpenGLViewport.h:123
mrpt::opengl::COpenGLViewport::internal_setImageView_fast
void internal_setImageView_fast(const mrpt::img::CImage &img, bool is_fast)
Definition: COpenGLViewport.cpp:892
mrpt::opengl::mrptEventGLPostRender::mrptEventGLPostRender
mrptEventGLPostRender(const COpenGLViewport *obj)
Definition: COpenGLViewport.h:512
lightweight_geom_data.h
mrpt::opengl::COpenGLViewport::m_isCloned
bool m_isCloned
Set by setCloneView.
Definition: COpenGLViewport.h:363
v
const GLdouble * v
Definition: glext.h:3678
r
GLdouble GLdouble GLdouble r
Definition: glext.h:3705
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:129
mrpt::opengl::mrptEventGLPostRender::do_nothing
void do_nothing() override
Just to allow this class to be polymorphic.
Definition: COpenGLViewport.h:510
mrpt::opengl::COpenGLViewport::m_view_y
double m_view_y
Definition: COpenGLViewport.h:375
mrpt::opengl::COpenGLViewport::begin
iterator begin()
Definition: COpenGLViewport.h:260
mrpt::opengl::COpenGLViewport::TLastProjectiveMatrixInfo::pointing
mrpt::math::TPoint3D pointing
The camera points to here.
Definition: COpenGLViewport.h:406
mrpt::utils::CImage
mrpt::img::CImage CImage
Definition: utils/CImage.h:7
mrpt::opengl::COpenGLViewport::m_lastProjMat
TLastProjectiveMatrixInfo m_lastProjMat
Info updated with each "render()" and used in "get3DRayForPixelCoord".
Definition: COpenGLViewport.h:419
ASSERT_BELOW_
#define ASSERT_BELOW_(__A, __B)
Definition: exceptions.h:165
mrpt::opengl::CSetOfObjects
A set of object, which are referenced to the coordinates framework established in this object.
Definition: CSetOfObjects.h:28
mrpt::opengl::mrptEventGLPreRender
An event sent by an mrpt::opengl::COpenGLViewport just after clearing the viewport and setting the GL...
Definition: COpenGLViewport.h:481
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:217
mrpt::opengl::mrptEventGLPostRender::source_viewport
const COpenGLViewport *const source_viewport
Definition: COpenGLViewport.h:516
mrpt::opengl::COpenGLViewport::TLastProjectiveMatrixInfo::viewport_width
size_t viewport_width
In pixels.
Definition: COpenGLViewport.h:410
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:215
mrpt::opengl::COpenGLViewport::m_objects
opengl::CListOpenGLObjects m_objects
The list of objects that comprise the 3D scene.
Definition: COpenGLViewport.h:425
mrpt::opengl::COpenGLViewport::TLastProjectiveMatrixInfo::up
mrpt::math::TPoint3D up
Up vector of the camera.
Definition: COpenGLViewport.h:408
CObservable.h
mrpt::opengl::COpenGLViewport::TLastProjectiveMatrixInfo::TLastProjectiveMatrixInfo
TLastProjectiveMatrixInfo()
Definition: COpenGLViewport.h:390
mrpt::opengl::COpenGLViewport::resetCloneView
void resetCloneView()
Reset the viewport to normal mode: rendering its own objects.
Definition: COpenGLViewport.h:99
mrpt::opengl::COpenGLViewport::setViewportClipDistances
void setViewportClipDistances(const double clip_min, const double clip_max)
Set the min/max clip depth distances of the rendering frustum (default: 0.1 - 10000)
Definition: COpenGLViewport.cpp:717
MRPT_START
#define MRPT_START
Definition: exceptions.h:262
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:634
mrpt::poses::CPose3D
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:88
mrpt::opengl::COpenGLViewport::getName
std::string getName()
Returns the name of the viewport.
Definition: COpenGLViewport.h:148
mrpt::img::TColorf
A RGB color - floats in the range [0,1].
Definition: TColor.h:79
mrpt::opengl::mrptEventGLPreRender::mrptEventGLPreRender
mrptEventGLPreRender(const COpenGLViewport *obj)
Definition: COpenGLViewport.h:487
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:30
CLASS_ID_NAMESPACE
#define CLASS_ID_NAMESPACE(class_name, namespaceName)
Definition: CObject.h:88
mrpt::serialization::CSerializable
The virtual base class which provides a unified interface for all persistent objects in MRPT.
Definition: CSerializable.h:32
color
GLuint color
Definition: glext.h:8300
mrpt::opengl::COpenGLViewport::TLastProjectiveMatrixInfo::viewport_height
size_t viewport_height
Definition: COpenGLViewport.h:410
mrpt::opengl::COpenGLViewport::begin
const_iterator begin() const
Definition: COpenGLViewport.h:258
height
GLenum GLsizei GLsizei height
Definition: glext.h:3554
mrpt::opengl::COpenGLViewport::m_imageview_img
mrpt::img::CImage::Ptr m_imageview_img
The image to display, after calling setImageView()
Definition: COpenGLViewport.h:386
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:111
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::img::CImage
A class for storing images as grayscale or RGB bitmaps.
Definition: img/CImage.h:130
mrpt::opengl::COpenGLViewport::~COpenGLViewport
virtual ~COpenGLViewport()
Destructor: clears all objects.
Definition: COpenGLViewport.cpp:97
mrpt::opengl::operator<<
mrpt::serialization::CArchive & operator<<(mrpt::serialization::CArchive &out, const mrpt::opengl::CLight &o)
Definition: CLight.cpp:130
mrpt::math::TPoint3D
Lightweight 3D point.
Definition: lightweight_geom_data.h:378
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::m_isTransparent
bool m_isTransparent
Whether to clear color buffer.
Definition: COpenGLViewport.h:371
safe_pointers.h
mrpt::opengl::COpenGLViewport::TLastProjectiveMatrixInfo::azimuth
float azimuth
Camera elev & azimuth, in radians.
Definition: COpenGLViewport.h:414
mrpt::opengl::COpenGLViewport::TLastProjectiveMatrixInfo::elev
float elev
Definition: COpenGLViewport.h:414
mrpt::opengl::mrptEventGLPreRender::source_viewport
const COpenGLViewport *const source_viewport
Definition: COpenGLViewport.h:491
mrpt::img::CImage::Ptr
std::shared_ptr< CImage > Ptr
Definition: img/CImage.h:132
mrpt::opengl::COpenGLViewport::COpenGLViewport
COpenGLViewport(COpenGLScene *parent=nullptr, const std::string &name=std::string(""))
Constructor, invoked from COpenGLScene only.
Definition: COpenGLViewport.cpp:50
img
GLint GLvoid * img
Definition: glext.h:3763
DEFINE_SERIALIZABLE
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
Definition: CSerializable.h:102
mrpt::opengl::COpenGLViewport::const_iterator
CListOpenGLObjects::const_iterator const_iterator
Definition: COpenGLViewport.h:255
width
GLenum GLsizei width
Definition: glext.h:3531
MRPT_END
#define MRPT_END
Definition: exceptions.h:266
mrpt::opengl::CListOpenGLObjects
std::deque< CRenderizable::Ptr > CListOpenGLObjects
A list of objects pointers, automatically managing memory free at destructor, and managing copies cor...
Definition: CRenderizable.h:332
mrpt::opengl::COpenGLViewport::m_OpenGL_enablePolygonNicest
bool m_OpenGL_enablePolygonNicest
Definition: COpenGLViewport.h:430
mrpt::opengl::COpenGLViewport
A viewport within a COpenGLScene, containing a set of OpenGL objects to render.
Definition: COpenGLViewport.h:60
mrpt::opengl::COpenGLViewport::TLastProjectiveMatrixInfo::zoom
float zoom
Definition: COpenGLViewport.h:415
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: lightweight_geom_data.h:1244
string
GLsizei const GLchar ** string
Definition: glext.h:4101
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:101
iterator
Scalar * iterator
Definition: eigen_plugins.h:26
mrpt::opengl::COpenGLViewport::getByClass
T::Ptr getByClass(const 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:290
CSerializable.h
mrpt::opengl
The namespace for 3D scene representation and rendering.
Definition: CGlCanvasBase.h:15
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:739
mrpt::opengl::COpenGLViewport::Ptr
std::shared_ptr< COpenGLViewport > Ptr
Definition: COpenGLViewport.h:63
y
GLenum GLint GLint y
Definition: glext.h:3538
mrpt::opengl::COpenGLViewport::isTransparent
bool isTransparent()
Return whether the viewport will be rendered transparent over previous viewports.
Definition: COpenGLViewport.h:211
mrpt::opengl::COpenGLViewport::getCamera
const opengl::CCamera & getCamera() const
Get a reference to the camera associated with this viewport.
Definition: COpenGLViewport.h:327
mrpt::system::CObservable
Inherit from this class for those objects capable of being observed by a CObserver class.
Definition: CObservable.h:33
uint32_t
unsigned __int32 uint32_t
Definition: rptypes.h:47
mrpt::opengl::COpenGLViewport::m_view_height
double m_view_height
Definition: COpenGLViewport.h:375
mrpt::safe_ptr
A wrapper class for pointers that can be safely copied with "=" operator without problems.
Definition: safe_pointers.h:71
x
GLenum GLint x
Definition: glext.h:3538
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:699
mrpt::opengl::COpenGLViewport::setNumberOfLights
void setNumberOfLights(const size_t N)
Allocates a number of lights, which must be correctly defined via getLight(i), etc.
Definition: COpenGLViewport.h:129



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST