Go to the documentation of this file.
9 #ifndef opengl_COpenGLViewport_H
10 #define opengl_COpenGLViewport_H
25 namespace utils {
class CImage; }
57 public
mrpt::utils::CSerializable,
58 public
mrpt::utils::CObservable
71 void setCloneView( const std::
string &clonedViewport );
79 void setImageView(const
mrpt::utils::CImage &img);
84 void setImageView_fast(
mrpt::utils::CImage &img);
89 inline
void resetCloneView() { setNormalMode(); }
128 inline std::string
getName() {
return m_name; }
148 const double height );
175 inline void setBorderSize(
unsigned int lineWidth ) { m_borderWidth = lineWidth; }
223 void insert(
const CRenderizablePtr &newObject );
241 template <
typename T>
242 typename T::SmartPtr
getByClass(
const size_t &ith = 0 )
const
245 size_t foundCount = 0;
248 if ( (*it).present() && (*it)->GetRuntimeClass()->derivedFrom( class_ID ) )
249 if (foundCount++ == ith)
250 return typename T::SmartPtr(*it);
257 typename T::SmartPtr o = CSetOfObjectsPtr(*it)->getByClass<T>(ith);
258 if (o.present())
return o;
261 return typename T::SmartPtr();
270 inline size_t size()
const {
return m_objects.size(); }
272 inline bool empty()
const {
return m_objects.empty(); }
302 void render(
const int render_width,
const int render_height )
const;
313 double m_view_x,
m_view_y,m_view_width,m_view_height;
323 TLastProjectiveMatrixInfo() :
eye(0,0,0),pointing(0,0,0),up(0,0,0), viewport_width(640), viewport_height(480), FOV(30),
azimuth(0), elev(0), zoom(1),is_projective(true)
353 inline COpenGLViewportPtr &operator<<(COpenGLViewportPtr &s,const CRenderizablePtr &r) {
361 inline COpenGLViewportPtr &
operator<<(COpenGLViewportPtr &s,
const std::vector<CRenderizablePtr> &v) {
void do_nothing() MRPT_OVERRIDE
Just to allow this class to be polymorphic.
void getViewportPosition(double &x, double &y, double &width, double &height)
Get the current viewport position and dimension on the rendering window.
The basic event type for the observer-observable pattern in MRPT.
void removeObject(const CRenderizablePtr &obj)
Removes the given object from the scene (it also deletes the object to free its memory).
const CLight & getLight(const size_t i) const
size_t size() const
Number of objects contained.
bool m_isImageView
Set by setImageView.
mrpt::math::TPoint3D eye
The camera is here.
std::vector< CLight > m_lights
void getViewportClipDistances(double &clip_min, double &clip_max) const
Get the current min/max clip depth distances of the rendering frustum (default: 0....
const Scalar * const_iterator
std::string m_name
The viewport's name.
CRenderizablePtr getByName(const std::string &str)
Returns the first object with a given name, or NULL if not found.
void setViewportPosition(const double x, const double y, const double width, const double height)
Change the viewport position and dimension on the rendering window.
bool isPolygonNicestEnabled() const
This class allows the user to create, load, save, and render 3D scenes using OpenGL primitives.
void internal_setImageView_fast(const mrpt::utils::CImage &img, bool is_fast)
void addLight(const CLight &l)
Append a new light to the scene.
void setBorderSize(unsigned int lineWidth)
Set the border size ("frame") of the viewport (default=0).
An event sent by an mrpt::opengl::COpenGLViewport after calling the scene OpenGL drawing primitives a...
opengl::CCamera m_camera
The camera associated to the viewport.
uint32_t m_borderWidth
Default=0, the border around the viewport.
bool m_custom_backgb_color
CListOpenGLObjects::iterator iterator
const_iterator end() const
CLight & getLight(const size_t i)
Each of the possible lights of a 3D scene.
std::deque< CRenderizablePtr > CListOpenGLObjects
A list of objects pointers, automatically managing memory free at destructor, and managing copies cor...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
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)
mrpt::utils::CImagePtr m_imageview_img
The image to display, after calling setImageView()
mrpt::utils::TColorf getCustomBackgroundColor() const
A class for storing images as grayscale or RGB bitmaps.
#define ASSERT_BELOW_(__A, __B)
opengl::CCamera & getCamera()
Get a reference to the camera associated with this viewport.
utils::safe_ptr< COpenGLScene > m_parent
The scene that contains this viewport.
void lightsClearAll()
Removes all lights (and disables the global "GL_LIGHTING")
mrptEventGLPostRender(const COpenGLViewport *obj)
void initializeAllTextures()
Initializes all textures in the scene (See opengl::CTexturedPlane::loadTextureInOpenGL)
void dumpListOfObjects(mrpt::utils::CStringList &lst)
Retrieves a list of all objects in text form.
bool m_isCloned
Set by setCloneView.
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...
mrpt::math::TPoint3D pointing
The camera points to here.
TLastProjectiveMatrixInfo m_lastProjMat
Info updated with each "render()" and used in "get3DRayForPixelCoord".
A set of object, which are referenced to the coordinates framework established in this object.
An event sent by an mrpt::opengl::COpenGLViewport just after clearing the viewport and setting the GL...
const COpenGLViewport *const source_viewport
void setTransparent(bool trans)
Set the transparency, that is, whether the viewport will be rendered transparent over previous viewpo...
opengl::CListOpenGLObjects m_objects
The list of objects that comprise the 3D scene.
mrpt::math::TPoint3D up
Up vector of the camera.
void setCustomBackgroundColor(const mrpt::utils::TColorf &color)
Set a background color different from that of the parent GUI window.
TLastProjectiveMatrixInfo()
void setNormalMode()
Resets the viewport to a normal 3D viewport.
T::SmartPtr getByClass(const size_t &ith=0) const
Returns the i'th object of a given class (or of a descendant class), or NULL (an empty smart pointer)...
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
std::string getName()
Returns the name of the viewport.
#define DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
mrptEventGLPreRender(const COpenGLViewport *obj)
A camera: if added to a scene, the viewpoint defined by this camera will be used instead of the camer...
#define CLASS_ID_NAMESPACE(class_name, namespaceName)
Access to runtime class ID for a defined class name.
void render(const int render_width, const int render_height) const
Render the objects in this viewport (called from COpenGLScene only)
CListOpenGLObjects::const_iterator const_iterator
const_iterator begin() const
void enablePolygonNicest(bool enable=true)
Sets glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST) is enabled, or GL_FASTEST otherwise.
The virtual base class which provides a unified interface for all persistent objects in MRPT.
void clear()
Delete all internal obejcts.
std::string m_clonedViewport
Only if m_isCloned=true.
OPENGL_IMPEXP mrpt::utils::CStream & operator<<(mrpt::utils::CStream &out, const mrpt::opengl::CLight &o)
bool m_isClonedCamera
Set by setCloneCamera.
A RGB color - floats in the range [0,1].
#define DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
This declaration must be inserted in all CSerializable classes definition, before the class declarati...
EIGEN_STRONG_INLINE void eye()
Make the matrix an identity matrix
void do_nothing() MRPT_OVERRIDE
Just to allow this class to be polymorphic.
bool m_isTransparent
Whether to clear color buffer.
float elev
Camera elev & azimuth, in radians.
const COpenGLViewport *const source_viewport
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
bool m_OpenGL_enablePolygonNicest
A viewport within a COpenGLScene, containing a set of OpenGL objects to render.
A wrapper class for pointers that can be safely copied with "=" operator without problems.
mrpt::utils::TColorf m_background_color
used only if m_custom_backgb_color
void setCloneCamera(bool enable)
If set to true, and setCloneView() has been called, this viewport will be rendered using the camera o...
3D line, represented by a base point and a director vector.
A class for storing a list of text lines.
virtual ~COpenGLViewport()
Destructor: clears all objects.
void getCurrentCameraPose(mrpt::poses::CPose3D &out_cameraPose) const
Compute the current 3D camera pose.
A structure that holds runtime class type information.
The namespace for 3D scene representation and rendering.
void get3DRayForPixelCoord(const double x_coord, const double y_coord, mrpt::math::TLine3D &out_ray, mrpt::poses::CPose3D *out_cameraPose=NULL) const
Compute the 3D ray corresponding to a given pixel; this can be used to allow the user to pick and sel...
bool isTransparent()
Return whether the viewport will be rendered transparent over previous viewports.
#define MRPT_OVERRIDE
C++11 "override" for virtuals:
const opengl::CCamera & getCamera() const
Get a reference to the camera associated with this viewport.
void insert(const CRenderizablePtr &newObject)
Insert a new object into the list.
void setNumberOfLights(const size_t N)
Allocates a number of lights, which must be correctly defined via getLight(i), etc.
COpenGLViewport(COpenGLScene *parent=NULL, const std::string &name=std::string(""))
Constructor, invoked from COpenGLScene only.
Page generated by Doxygen 1.8.20 for MRPT 1.4.0 SVN: at Thu Aug 27 02:40:23 UTC 2020 | | |