158 const double x,
const double y,
const double width,
159 const double height);
171 double& x,
double& y,
double& width,
double& height);
231 const double x_coord,
const double y_coord,
279 template <
typename T>
283 size_t foundCount = 0;
284 const auto* class_ID = &T::GetRuntimeClassIdStatic();
286 if (o && o->GetRuntimeClass()->derivedFrom(class_ID))
287 if (foundCount++ == ith)
return std::dynamic_pointer_cast<T>(o);
292 if (o && o->GetRuntimeClass() ==
295 typename T::Ptr obj = std::dynamic_pointer_cast<T>(
297 ->
template getByClass<T>(ith));
301 return typename T::Ptr();
332 const std::string& name = std::string(
""));
336 const int render_width,
const int render_height,
337 const int render_offset_x = 0,
const int render_offset_y = 0)
const;
396 mutable std::map<shader_id_t, mrpt::opengl::Program::Ptr>
m_shaders;
439 for (
const auto& it : v) s->insert(it);
float m_clip_min
The min/max clip depth distances (default: 0.1 - 10000)
opengl::CListOpenGLObjects m_objects
The list of objects that comprise the 3D scene.
void setBorderSize(unsigned int lineWidth)
Set the border size ("frame") of the viewport (default=0)
CRenderizable::Ptr getByName(const std::string &str)
Returns the first object with a given name, or nullptr if not found.
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...
const COpenGLViewport *const source_viewport
const_iterator begin() const
bool m_isTransparent
Whether to clear color buffer.
opengl::CCamera & getCamera()
Get a reference to the camera associated with this viewport.
mrpt::opengl::CTexturedPlane::Ptr m_imageview_plane
The image to display, after calling setImageView()
A set of object, which are referenced to the coordinates framework established in this object...
uint32_t m_borderWidth
Default=0, the border around the viewport.
void setCloneView(const std::string &clonedViewport)
Set this viewport as a clone of some other viewport, given its name - as a side effect, current list of internal OpenGL objects is cleared.
mrptEventGLPostRender(const COpenGLViewport *obj)
The basic event type for the observer-observable pattern in MRPT.
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) ...
std::deque< CRenderizable::Ptr > CListOpenGLObjects
A list of smart pointers to renderizable objects.
Keeps a list of text messages which can be rendered to OpenGL contexts by graphic classes...
void do_nothing() override
Just to allow this class to be polymorphic.
COpenGLScene::Ptr & operator<<(COpenGLScene::Ptr &s, const CRenderizable::Ptr &r)
Inserts an openGL object into a scene.
TLightParameters & lightParameters()
void setImageView(const mrpt::img::CImage &img)
Set this viewport into "image view"-mode, where an image is efficiently drawn (fitting the viewport a...
bool m_custom_backgb_color
void renderImageMode() const
Render in image mode.
void do_nothing() override
Just to allow this class to be polymorphic.
const opengl::CCamera & getCamera() const
Get a reference to the camera associated with this viewport.
CListOpenGLObjects::iterator iterator
A viewport within a COpenGLScene, containing a set of OpenGL objects to render.
void getViewportClipDistances(float &clip_min, float &clip_max) const
Get the current min/max clip depth distances of the rendering frustum (default: 0.1 - 10000)
void setCloneCamera(bool enable)
If set to true, and setCloneView() has been called, this viewport will be rendered using the camera o...
mrpt::safe_ptr< COpenGLScene > m_parent
The scene that contains this viewport.
TRenderMatrices m_state
Info updated with each "render()" and used in "get3DRayForPixelCoord".
mrpt::img::TColor m_borderColor
void loadDefaultShaders() const
Load all MPRT predefined shader programs into m_shaders.
const COpenGLViewport *const source_viewport
bool m_isClonedCamera
Set by setCloneCamera.
unsigned int getBorderSize() const
const mrpt::img::TColor & getBorderColor() const
void internal_enableImageView()
bool m_isImageView
Set by setImageView.
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...
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)
~COpenGLViewport() override
Destructor: clears all objects.
void resetCloneView()
Reset the viewport to normal mode: rendering its own objects.
void unloadShaders()
Unload shader programs in m_shaders.
void removeObject(const CRenderizable::Ptr &obj)
Removes the given object from the scene (it also deletes the object to free its memory).
const_iterator end() const
void setNormalMode()
Resets the viewport to a normal 3D viewport.
bool m_OpenGL_enablePolygonNicest
Inherit from this class for those objects capable of being observed by a CObserver class...
mrpt::img::TColorf getCustomBackgroundColor() const
Rendering state related to the projection and model-view matrices.
A wrapper class for pointers that can be safely copied with "=" operator without problems.
void getCurrentCameraPose(mrpt::poses::CPose3D &out_cameraPose) const
Compute the current 3D camera pose.
bool isPolygonNicestEnabled() const
TLightParameters m_lights
void setBorderColor(const mrpt::img::TColor &c)
void renderTextMessages() const
Renders all messages in the underlying class CTextMessageCapable.
size_t size() const
Number of objects contained.
CListOpenGLObjects::const_iterator const_iterator
mrptEventGLPreRender(const COpenGLViewport *obj)
#define CLASS_ID_NAMESPACE(class_name, namespaceName)
std::map< shader_id_t, mrpt::opengl::Program::Ptr > m_shaders
Default shader program.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
void clear()
Delete all internal obejcts.
An event sent by an mrpt::opengl::COpenGLViewport just after clearing the viewport and setting the GL...
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
void initializeTextures()
Initializes all textures in the scene (See opengl::CTexturedPlane::initializeTextures) ...
An event sent by an mrpt::opengl::COpenGLViewport after calling the scene OpenGL drawing primitives a...
void enablePolygonNicest(bool enable=true)
Sets glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST) is enabled, or GL_FASTEST otherwise.
An RGBA color - floats in the range [0,1].
mrpt::opengl::CSetOfLines::Ptr m_borderLines
The namespace for 3D scene representation and rendering.
This class allows the user to create, load, save, and render 3D scenes using OpenGL primitives...
void setTransparent(bool trans)
Set the transparency, that is, whether the viewport will be rendered transparent over previous viewpo...
The virtual base class which provides a unified interface for all persistent objects in MRPT...
std::string m_clonedViewport
Only if m_isCloned=true.
std::string getName()
Returns the name of the viewport.
mrpt::img::TColorf m_background_color
used only if m_custom_backgb_color
void renderNormalSceneMode() const
Render a normal scene with 3D objects.
#define DEFINE_SERIALIZABLE(class_name, NS)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
void setCustomBackgroundColor(const mrpt::img::TColorf &color)
Set a background color different from that of the parent GUI window.
A camera: if added to a scene, the viewpoint defined by this camera will be used instead of the camer...
void renderViewportBorder() const
Render the viewport border, if enabled.
const TLightParameters & lightParameters() const
bool isTransparent()
Return whether the viewport will be rendered transparent over previous viewports. ...
void setViewportPosition(const double x, const double y, const double width, const double height)
Change the viewport position and dimension on the rendering window.
void dumpListOfObjects(std::vector< std::string > &lst)
Retrieves a list of all objects in text form.
void getViewportPosition(double &x, double &y, double &width, double &height)
Get the current viewport position and dimension on the rendering window.
void insert(const CRenderizable::Ptr &newObject)
Insert a new object into the list.
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...
double m_view_x
The viewport position [0,1].
Lighting parameters, mostly for triangle shaders.
void setCurrentCameraFromPose(mrpt::poses::CPose3D &p)
Changes the point of view of the camera, from a given pose.
opengl::CCamera m_camera
The camera associated to the viewport.
std::string m_name
The viewport's name.
COpenGLViewport(COpenGLScene *parent=nullptr, const std::string &name=std::string(""))
Constructor, invoked from COpenGLScene only.
bool m_isCloned
Set by setCloneView.
3D line, represented by a base point and a director vector.