Go to the documentation of this file.
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>(
296 std::dynamic_pointer_cast<CSetOfObjects>(o)
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);
The basic event type for the observer-observable pattern in MRPT.
size_t size() const
Number of objects contained.
void do_nothing() override
Just to allow this class to be polymorphic.
mrpt::img::TColor m_borderColor
bool m_isImageView
Set by setImageView.
TLightParameters m_lights
void setImageView(const mrpt::img::CImage &img)
Set this viewport into "image view"-mode, where an image is efficiently drawn (fitting the viewport a...
void unloadShaders()
Unload shader programs in m_shaders.
const TLightParameters & lightParameters() const
mrpt::safe_ptr< COpenGLScene > m_parent
The scene that contains this viewport.
#define DEFINE_SERIALIZABLE(class_name, NS)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
std::string m_name
The viewport's name.
void getCurrentCameraPose(mrpt::poses::CPose3D &out_cameraPose) const
Compute the current 3D camera pose.
CListOpenGLObjects::iterator iterator
bool isPolygonNicestEnabled() const
std::map< shader_id_t, mrpt::opengl::Program::Ptr > m_shaders
Default shader program.
This class allows the user to create, load, save, and render 3D scenes using OpenGL primitives.
void setNormalMode()
Resets the viewport to a normal 3D viewport.
void setBorderSize(unsigned int lineWidth)
Set the border size ("frame") of the viewport (default=0)
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...
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.
mrpt::opengl::CTexturedPlane::Ptr m_imageview_plane
The image to display, after calling setImageView()
bool m_custom_backgb_color
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)
mrpt::img::TColorf m_background_color
used only if m_custom_backgb_color
std::shared_ptr< mrpt::opengl ::CTexturedPlane > Ptr
double m_view_x
The viewport position [0,1].
const_iterator end() const
void initializeTextures()
Initializes all textures in the scene (See opengl::CTexturedPlane::initializeTextures)
std::shared_ptr< CRenderizable > Ptr
mrpt::img::TColorf getCustomBackgroundColor() const
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
void insert(const CRenderizable::Ptr &newObject)
Insert a new object into the list.
void clear()
Delete all internal obejcts.
void dumpListOfObjects(std::vector< std::string > &lst)
Retrieves a list of all objects in text form.
opengl::CCamera & getCamera()
Get a reference to the camera associated with this viewport.
void loadDefaultShaders() const
Load all MPRT predefined shader programs into m_shaders.
void renderImageMode() const
Render in image mode.
mrptEventGLPostRender(const COpenGLViewport *obj)
bool m_isCloned
Set by setCloneView.
Keeps a list of text messages which can be rendered to OpenGL contexts by graphic classes.
void getViewportPosition(double &x, double &y, double &width, double &height)
Get the current viewport position and dimension on the rendering window.
void do_nothing() override
Just to allow this class to be polymorphic.
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...
void setCustomBackgroundColor(const mrpt::img::TColorf &color)
Set a background color different from that of the parent GUI window.
const COpenGLViewport *const source_viewport
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)
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.
std::shared_ptr< mrpt::opengl ::COpenGLViewport > Ptr
void resetCloneView()
Reset the viewport to normal mode: rendering its own objects.
CRenderizable::Ptr getByName(const std::string &str)
Returns the first object with a given name, or nullptr if not found.
mrpt::opengl::CSetOfLines::Ptr m_borderLines
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
std::shared_ptr< mrpt::opengl ::CSetOfLines > Ptr
void setBorderColor(const mrpt::img::TColor &c)
std::string getName()
Returns the name of the viewport.
An RGBA color - floats in the range [0,1].
mrptEventGLPreRender(const COpenGLViewport *obj)
float m_clip_min
The min/max clip depth distances (default: 0.1 - 10000)
COpenGLScene::Ptr & operator<<(COpenGLScene::Ptr &s, const CRenderizable::Ptr &r)
Inserts an openGL object into a scene.
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)
The virtual base class which provides a unified interface for all persistent objects in MRPT.
void setCurrentCameraFromPose(mrpt::poses::CPose3D &p)
Changes the point of view of the camera, from a given pose.
const mrpt::img::TColor & getBorderColor() const
const_iterator begin() const
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 enablePolygonNicest(bool enable=true)
Sets glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST) is enabled, or GL_FASTEST otherwise.
std::string m_clonedViewport
Only if m_isCloned=true.
bool m_isClonedCamera
Set by setCloneCamera.
~COpenGLViewport() override
Destructor: clears all objects.
bool m_isTransparent
Whether to clear color buffer.
Rendering state related to the projection and model-view matrices.
TRenderMatrices m_state
Info updated with each "render()" and used in "get3DRayForPixelCoord".
const COpenGLViewport *const source_viewport
void renderViewportBorder() const
Render the viewport border, if enabled.
COpenGLViewport(COpenGLScene *parent=nullptr, const std::string &name=std::string(""))
Constructor, invoked from COpenGLScene only.
CListOpenGLObjects::const_iterator const_iterator
std::deque< CRenderizable::Ptr > CListOpenGLObjects
A list of smart pointers to renderizable objects.
bool m_OpenGL_enablePolygonNicest
A viewport within a COpenGLScene, containing a set of OpenGL objects to render.
unsigned int getBorderSize() const
void renderTextMessages() const
Renders all messages in the underlying class CTextMessageCapable.
void getViewportClipDistances(float &clip_min, float &clip_max) const
Get the current min/max clip depth distances of the rendering frustum (default: 0....
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.
void internal_enableImageView()
void setCloneView(const std::string &clonedViewport)
Set this viewport as a clone of some other viewport, given its name - as a side effect,...
Lighting parameters, mostly for triangle shaders.
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=nullptr) const
Compute the 3D ray corresponding to a given pixel; this can be used to allow the user to pick and sel...
void renderNormalSceneMode() const
Render a normal scene with 3D objects.
bool isTransparent()
Return whether the viewport will be rendered transparent over previous viewports.
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...
const opengl::CCamera & getCamera() const
Get a reference to the camera associated with this viewport.
Inherit from this class for those objects capable of being observed by a CObserver class.
A wrapper class for pointers that can be safely copied with "=" operator without problems.
TLightParameters & lightParameters()
void removeObject(const CRenderizable::Ptr &obj)
Removes the given object from the scene (it also deletes the object to free its memory).
Page generated by Doxygen 1.8.17 for MRPT 2.0.3 at Fri May 15 15:49:54 UTC 2020 | |