MRPT
2.0.4
|
A viewport within a COpenGLScene, containing a set of OpenGL objects to render.
This class has protected constuctor, thus it cannot be created by users. Use COpenGLScene::createViewport instead. A viewport has these "operation modes":
In any case, the viewport can be resized to only fit a part of the entire parent viewport. There will be always at least one viewport in a COpenGLScene named "main".
This class can be observed (see mrpt::system::CObserver) for the following events (see mrpt::system::mrptEvent):
Two directional light sources at infinity are created by default, with directions (-1,-1,-1) and (1,2,1), respectively.
Lighting parameters are accessible via lightParameters().
Refer to mrpt::opengl::COpenGLScene for further details.
Definition at line 61 of file COpenGLViewport.h.
#include <mrpt/opengl/COpenGLViewport.h>
Public Member Functions | |
~COpenGLViewport () override | |
Destructor: clears all objects. More... | |
COpenGLViewport (COpenGLScene *parent=nullptr, const std::string &name=std::string("")) | |
Constructor, invoked from COpenGLScene only. More... | |
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) More... | |
virtual mxArray * | writeToMatlab () const |
Introduces a pure virtual method responsible for writing to a mxArray Matlab object, typically a MATLAB struct whose contents are documented in each derived class. More... | |
void | clearTextMessages () |
void | addTextMessage (const double x_frac, const double y_frac, const std::string &text, const size_t unique_index=0, const TFontParams &fontParams=TFontParams()) |
Add 2D text messages overlapped to the 3D rendered scene. More... | |
bool | updateTextMessage (const size_t unique_index, const std::string &text) |
Just updates the text of a given text message, without touching the other parameters. More... | |
const TListTextMessages & | getTextMessages () const |
Set the viewport "modes" | |
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. More... | |
void | setImageView (const mrpt::img::CImage &img) |
Set this viewport into "image view"-mode, where an image is efficiently drawn (fitting the viewport area) using an OpenGL textured quad. More... | |
void | setImageView (mrpt::img::CImage &&img) |
Just like setImageView but moves the internal image memory instead of making a copy, so it's faster but empties the input image. More... | |
void | resetCloneView () |
Reset the viewport to normal mode: rendering its own objects. More... | |
void | setCloneCamera (bool enable) |
If set to true, and setCloneView() has been called, this viewport will be rendered using the camera of the cloned viewport. More... | |
void | setNormalMode () |
Resets the viewport to a normal 3D viewport. More... | |
OpenGL global settings that affect rendering all objects in the | |
scene/viewport | |
void | enablePolygonNicest (bool enable=true) |
Sets glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST) is enabled, or GL_FASTEST otherwise. More... | |
bool | isPolygonNicestEnabled () const |
const TLightParameters & | lightParameters () const |
TLightParameters & | lightParameters () |
Change or read viewport properties (except "viewport modes") | |
std::string | getName () |
Returns the name of the viewport. More... | |
void | setViewportPosition (const double x, const double y, const double width, const double height) |
Change the viewport position and dimension on the rendering window. More... | |
void | getViewportPosition (double &x, double &y, double &width, double &height) |
Get the current viewport position and dimension on the rendering window. More... | |
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) More... | |
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) More... | |
void | setBorderSize (unsigned int lineWidth) |
Set the border size ("frame") of the viewport (default=0) More... | |
unsigned int | getBorderSize () const |
void | setBorderColor (const mrpt::img::TColor &c) |
const mrpt::img::TColor & | getBorderColor () const |
bool | isTransparent () |
Return whether the viewport will be rendered transparent over previous viewports. More... | |
void | setTransparent (bool trans) |
Set the transparency, that is, whether the viewport will be rendered transparent over previous viewports (default=false). More... | |
void | setCustomBackgroundColor (const mrpt::img::TColorf &color) |
Set a background color different from that of the parent GUI window. More... | |
mrpt::img::TColorf | getCustomBackgroundColor () const |
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 select 3D objects by clicking onto the 2D image. More... | |
RTTI classes and functions for polymorphic hierarchies | |
mrpt::rtti::CObject::Ptr | duplicateGetSmartPtr () const |
Makes a deep copy of the object and returns a smart pointer to it. More... | |
Protected Member Functions | |
void | initializeTextures () |
Initializes all textures in the scene (See opengl::CTexturedPlane::initializeTextures) More... | |
void | dumpListOfObjects (std::vector< std::string > &lst) |
Retrieves a list of all objects in text form. More... | |
void | renderImageMode () const |
Render in image mode. More... | |
void | renderNormalSceneMode () const |
Render a normal scene with 3D objects. More... | |
void | renderViewportBorder () const |
Render the viewport border, if enabled. More... | |
void | loadDefaultShaders () const |
Load all MPRT predefined shader programs into m_shaders. More... | |
void | unloadShaders () |
Unload shader programs in m_shaders. More... | |
void | internal_enableImageView () |
void | renderTextMessages () const |
Renders all messages in the underlying class CTextMessageCapable. More... | |
void | publishEvent (const mrptEvent &e) const |
Called when you want this object to emit an event to all the observers currently subscribed to this object. More... | |
bool | hasSubscribers () const |
Can be called by a derived class before preparing an event for publishing with publishEvent to determine if there is no one subscribed, so it can save the wasted time preparing an event that will be not read. More... | |
CSerializable virtual methods | |
uint8_t | serializeGetVersion () const override |
Must return the current versioning number of the object. More... | |
void | serializeTo (mrpt::serialization::CArchive &out) const override |
Pure virtual method for writing (serializing) to an abstract archive. More... | |
void | serializeFrom (mrpt::serialization::CArchive &in, uint8_t serial_version) override |
Pure virtual method for reading (deserializing) from an abstract archive. More... | |
CSerializable virtual methods | |
virtual void | serializeTo (CSchemeArchiveBase &out) const |
Virtual method for writing (serializing) to an abstract schema based archive. More... | |
virtual void | serializeFrom (CSchemeArchiveBase &in) |
Virtual method for reading (deserializing) from an abstract schema based archive. More... | |
Protected Attributes | |
opengl::CCamera | m_camera |
The camera associated to the viewport. More... | |
mrpt::safe_ptr< COpenGLScene > | m_parent |
The scene that contains this viewport. More... | |
bool | m_isCloned {false} |
Set by setCloneView. More... | |
bool | m_isClonedCamera {false} |
Set by setCloneCamera. More... | |
std::string | m_clonedViewport |
Only if m_isCloned=true. More... | |
std::string | m_name |
The viewport's name. More... | |
bool | m_isTransparent {false} |
Whether to clear color buffer. More... | |
uint32_t | m_borderWidth {0} |
Default=0, the border around the viewport. More... | |
mrpt::img::TColor | m_borderColor {255, 255, 255, 255} |
double | m_view_x {0} |
The viewport position [0,1]. More... | |
double | m_view_y {0} |
double | m_view_width {1} |
double | m_view_height {1} |
float | m_clip_min = 0.1f |
The min/max clip depth distances (default: 0.1 - 10000) More... | |
float | m_clip_max = 10000.0f |
bool | m_custom_backgb_color {false} |
mrpt::img::TColorf | m_background_color = {0.6f, 0.6f, 0.6f} |
used only if m_custom_backgb_color More... | |
bool | m_isImageView {false} |
Set by setImageView. More... | |
mrpt::opengl::CTexturedPlane::Ptr | m_imageview_plane |
The image to display, after calling setImageView() More... | |
mrpt::opengl::CSetOfLines::Ptr | m_borderLines |
TRenderMatrices | m_state |
Info updated with each "render()" and used in "get3DRayForPixelCoord". More... | |
std::map< shader_id_t, mrpt::opengl::Program::Ptr > | m_shaders |
Default shader program. More... | |
opengl::CListOpenGLObjects | m_objects |
The list of objects that comprise the 3D scene. More... | |
bool | m_OpenGL_enablePolygonNicest {true} |
TLightParameters | m_lights |
TListTextMessages | m_2D_texts |
Friends | |
class | COpenGLScene |
RTTI stuff | |
using | Ptr = std::shared_ptr< mrpt::opengl ::COpenGLViewport > |
using | ConstPtr = std::shared_ptr< const mrpt::opengl ::COpenGLViewport > |
using | UniquePtr = std::unique_ptr< mrpt::opengl ::COpenGLViewport > |
using | ConstUniquePtr = std::unique_ptr< const mrpt::opengl ::COpenGLViewport > |
static const mrpt::rtti::TRuntimeClassId | runtimeClassId |
static constexpr const char * | className = "mrpt::opengl" "::" "COpenGLViewport" |
static const mrpt::rtti::TRuntimeClassId * | _GetBaseClass () |
static constexpr auto | getClassName () |
static const mrpt::rtti::TRuntimeClassId & | GetRuntimeClassIdStatic () |
static std::shared_ptr< CObject > | CreateObject () |
template<typename... Args> | |
static Ptr | Create (Args &&... args) |
template<typename Alloc , typename... Args> | |
static Ptr | CreateAlloc (const Alloc &alloc, Args &&... args) |
template<typename... Args> | |
static UniquePtr | CreateUnique (Args &&... args) |
virtual const mrpt::rtti::TRuntimeClassId * | GetRuntimeClass () const override |
Returns information about the class of an object in runtime. More... | |
virtual mrpt::rtti::CObject * | clone () const override |
Returns a deep copy (clone) of the object, indepently of its class. More... | |
Contained objects set/get/search | |
using | const_iterator = CListOpenGLObjects::const_iterator |
using | iterator = CListOpenGLObjects::iterator |
const_iterator | begin () const |
const_iterator | end () const |
iterator | begin () |
iterator | end () |
void | clear () |
Delete all internal obejcts. More... | |
void | insert (const CRenderizable::Ptr &newObject) |
Insert a new object into the list. More... | |
void | getCurrentCameraPose (mrpt::poses::CPose3D &out_cameraPose) const |
Compute the current 3D camera pose. More... | |
void | setCurrentCameraFromPose (mrpt::poses::CPose3D &p) |
Changes the point of view of the camera, from a given pose. More... | |
CRenderizable::Ptr | getByName (const std::string &str) |
Returns the first object with a given name, or nullptr if not found. More... | |
template<typename T > | |
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 pointer) if not found. More... | |
void | removeObject (const CRenderizable::Ptr &obj) |
Removes the given object from the scene (it also deletes the object to free its memory). More... | |
size_t | size () const |
Number of objects contained. More... | |
bool | empty () const |
opengl::CCamera & | getCamera () |
Get a reference to the camera associated with this viewport. More... | |
const opengl::CCamera & | getCamera () const |
Get a reference to the camera associated with this viewport. More... | |
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 the object parent. More... | |
using mrpt::opengl::COpenGLViewport::const_iterator = CListOpenGLObjects::const_iterator |
Definition at line 240 of file COpenGLViewport.h.
using mrpt::opengl::COpenGLViewport::ConstPtr = std::shared_ptr<const mrpt::opengl :: COpenGLViewport > |
Definition at line 65 of file COpenGLViewport.h.
using mrpt::opengl::COpenGLViewport::ConstUniquePtr = std::unique_ptr<const mrpt::opengl :: COpenGLViewport > |
Definition at line 65 of file COpenGLViewport.h.
using mrpt::opengl::COpenGLViewport::iterator = CListOpenGLObjects::iterator |
Definition at line 241 of file COpenGLViewport.h.
using mrpt::opengl::COpenGLViewport::Ptr = std::shared_ptr< mrpt::opengl :: COpenGLViewport > |
A type for the associated smart pointer
Definition at line 65 of file COpenGLViewport.h.
using mrpt::opengl::COpenGLViewport::UniquePtr = std::unique_ptr< mrpt::opengl :: COpenGLViewport > |
Definition at line 65 of file COpenGLViewport.h.
|
override |
Destructor: clears all objects.
Definition at line 56 of file COpenGLViewport.cpp.
References clear().
COpenGLViewport::COpenGLViewport | ( | COpenGLScene * | parent = nullptr , |
const std::string & | name = std::string("") |
||
) |
Constructor, invoked from COpenGLScene only.
Definition at line 51 of file COpenGLViewport.cpp.
|
staticprotected |
|
inherited |
Add 2D text messages overlapped to the 3D rendered scene.
overload with more font parameters - refer to mrpt::opengl::gl_utils::glDrawText()
The string will remain displayed in the 3D window until it's changed with subsequent calls to this same method, or all the texts are cleared with clearTextMessages().
x | The X position, interpreted as absolute pixels from the left if X>=1, absolute pixels from the left if X<0 or as a width factor if in the range [0,1[. |
y | The Y position, interpreted as absolute pixels from the bottom if Y>=1, absolute pixels from the top if Y<0 or as a height factor if in the range [0,1[. |
text | The text string to display. |
color | The text color. For example: TColorf(1.0,1.0,1.0) |
unique_index | An "index" for this text message, so that subsequent calls with the same index will overwrite this text message instead of creating new ones. |
You'll need to refresh the display manually with forceRepaint().
Definition at line 64 of file CTextMessageCapable.cpp.
References mrpt::opengl::T2DTextData::text, mrpt::opengl::T2DTextData::x, and mrpt::opengl::T2DTextData::y.
Referenced by serializeFrom().
|
inline |
Definition at line 243 of file COpenGLViewport.h.
References m_objects.
|
inline |
Definition at line 245 of file COpenGLViewport.h.
References m_objects.
void COpenGLViewport::clear | ( | ) |
Delete all internal obejcts.
Definition at line 95 of file COpenGLViewport.cpp.
References m_objects.
Referenced by serializeFrom(), setCloneView(), and ~COpenGLViewport().
|
inherited |
Definition at line 42 of file CTextMessageCapable.cpp.
|
overridevirtual |
Returns a deep copy (clone) of the object, indepently of its class.
Implements mrpt::rtti::CObject.
|
inlinestatic |
Definition at line 65 of file COpenGLViewport.h.
|
inlinestatic |
Definition at line 65 of file COpenGLViewport.h.
|
static |
|
inlinestatic |
Definition at line 65 of file COpenGLViewport.h.
|
protected |
Retrieves a list of all objects in text form.
Definition at line 705 of file COpenGLViewport.cpp.
References CLASS_ID_NAMESPACE, and m_objects.
|
inlineinherited |
Makes a deep copy of the object and returns a smart pointer to it.
Definition at line 204 of file CObject.h.
References mrpt::rtti::CObject::clone().
Referenced by mrpt::obs::CRawlog::insert().
|
inline |
Definition at line 312 of file COpenGLViewport.h.
References m_objects.
Referenced by loadDefaultShaders().
|
inline |
Sets glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST) is enabled, or GL_FASTEST otherwise.
Definition at line 117 of file COpenGLViewport.h.
References m_OpenGL_enablePolygonNicest.
|
inline |
Definition at line 244 of file COpenGLViewport.h.
References m_objects.
|
inline |
Definition at line 246 of file COpenGLViewport.h.
References m_objects.
void COpenGLViewport::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 select 3D objects by clicking onto the 2D image.
x_coord | Horizontal coordinate with the usual meaning (0:left of the viewport, W-1: right border). |
y_coord | Horizontal coordinate with the usual meaning (0:top of the viewport, H-1: right border). |
out_cameraPose | If not nullptr, will have the camera 3D pose as a mrpt::poses::CPose3D. See also |
Definition at line 764 of file COpenGLViewport.cpp.
References ASSERTDEB_, mrpt::opengl::TRenderMatrices::azimuth, mrpt::math::crossProduct3D(), mrpt::DEG2RAD(), mrpt::math::TLine3D::director, mrpt::opengl::TRenderMatrices::elev, mrpt::opengl::TRenderMatrices::eye, mrpt::opengl::TRenderMatrices::eyeDistance, mrpt::opengl::TRenderMatrices::FOV, mrpt::opengl::TRenderMatrices::is_projective, m_state, mrpt::math::TLine3D::pBase, mrpt::math::UNINITIALIZED_MATRIX, mrpt::opengl::TRenderMatrices::viewport_height, mrpt::opengl::TRenderMatrices::viewport_width, mrpt::math::TPoint3D_data< T >::x, mrpt::math::TPoint3D_data< T >::y, and mrpt::math::TPoint3D_data< T >::z.
Referenced by getCurrentCameraPose().
|
inline |
Definition at line 193 of file COpenGLViewport.h.
References m_borderColor.
|
inline |
Definition at line 190 of file COpenGLViewport.h.
References m_borderWidth.
void COpenGLViewport::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 the object parent.
Definition at line 931 of file COpenGLViewport.cpp.
References bb_max, bb_min, mrpt::keep_max(), mrpt::keep_min(), m_objects, mrpt::math::TPoint3D_data< T >::x, mrpt::math::TPoint3D_data< T >::y, and mrpt::math::TPoint3D_data< T >::z.
|
inline |
Returns the i'th object of a given class (or of a descendant class), or nullptr (an empty smart pointer) if not found.
Example:
By default (ith=0), the first observation is returned.
Definition at line 280 of file COpenGLViewport.h.
References CLASS_ID_NAMESPACE, m_objects, MRPT_END, and MRPT_START.
Referenced by renderNormalSceneMode().
CRenderizable::Ptr COpenGLViewport::getByName | ( | const std::string & | str | ) |
Returns the first object with a given name, or nullptr if not found.
Definition at line 681 of file COpenGLViewport.cpp.
References CLASS_ID_NAMESPACE, and m_objects.
|
inline |
Get a reference to the camera associated with this viewport.
Definition at line 314 of file COpenGLViewport.h.
References m_camera.
|
inline |
Get a reference to the camera associated with this viewport.
Definition at line 316 of file COpenGLViewport.h.
References m_camera.
|
inlinestatic |
Definition at line 65 of file COpenGLViewport.h.
void COpenGLViewport::getCurrentCameraPose | ( | mrpt::poses::CPose3D & | out_cameraPose | ) | const |
Compute the current 3D camera pose.
Definition at line 887 of file COpenGLViewport.cpp.
References get3DRayForPixelCoord().
|
inline |
Definition at line 210 of file COpenGLViewport.h.
References m_background_color.
|
inline |
Returns the name of the viewport.
Definition at line 132 of file COpenGLViewport.h.
References m_name.
|
overridevirtual |
Returns information about the class of an object in runtime.
Reimplemented from mrpt::serialization::CSerializable.
|
static |
|
inlineinherited |
Definition at line 73 of file CTextMessageCapable.h.
References mrpt::opengl::CTextMessageCapable::m_2D_texts.
void COpenGLViewport::getViewportClipDistances | ( | float & | clip_min, |
float & | clip_max | ||
) | const |
Get the current min/max clip depth distances of the rendering frustum (default: 0.1 - 10000)
Definition at line 754 of file COpenGLViewport.cpp.
References m_clip_max, and m_clip_min.
void COpenGLViewport::getViewportPosition | ( | double & | x, |
double & | y, | ||
double & | width, | ||
double & | height | ||
) |
Get the current viewport position and dimension on the rendering window.
X & Y coordinates here can have two interpretations:
Definition at line 83 of file COpenGLViewport.cpp.
References m_view_height, m_view_width, m_view_x, and m_view_y.
|
inlineprotectedinherited |
Can be called by a derived class before preparing an event for publishing with publishEvent to determine if there is no one subscribed, so it can save the wasted time preparing an event that will be not read.
Definition at line 53 of file CObservable.h.
References mrpt::system::CObservable::m_subscribers.
Referenced by mrpt::gui::CWindowDialog::OnMouseDown(), mrpt::gui::CWindowDialog::OnMouseMove(), mrpt::gui::CWindowDialog::OnResize(), render(), and renderNormalSceneMode().
|
protected |
Initializes all textures in the scene (See opengl::CTexturedPlane::initializeTextures)
Definition at line 700 of file COpenGLViewport.cpp.
References m_objects.
void COpenGLViewport::insert | ( | const CRenderizable::Ptr & | newObject | ) |
Insert a new object into the list.
The object MUST NOT be deleted, it will be deleted automatically by this object when not required anymore.
Definition at line 99 of file COpenGLViewport.cpp.
References m_objects.
|
protected |
Definition at line 917 of file COpenGLViewport.cpp.
References mrpt::opengl::CTexturedPlane::Create(), m_imageview_plane, and m_isImageView.
Referenced by setImageView().
|
inline |
Definition at line 121 of file COpenGLViewport.h.
References m_OpenGL_enablePolygonNicest.
|
inline |
Return whether the viewport will be rendered transparent over previous viewports.
Definition at line 198 of file COpenGLViewport.h.
References m_isTransparent.
|
inline |
Definition at line 123 of file COpenGLViewport.h.
References m_lights.
|
inline |
Definition at line 124 of file COpenGLViewport.h.
References m_lights.
|
protected |
Load all MPRT predefined shader programs into m_shaders.
Definition at line 187 of file COpenGLViewport.cpp.
References ASSERT_, empty(), mrpt::opengl::LoadDefaultShader(), m_shaders, MRPT_END, MRPT_START, mrpt::opengl::DefaultShaderID::POINTS, mrpt::opengl::DefaultShaderID::TEXT, mrpt::opengl::DefaultShaderID::TEXTURED_TRIANGLES, mrpt::opengl::DefaultShaderID::TRIANGLES, and mrpt::opengl::DefaultShaderID::WIREFRAME.
Referenced by render(), and renderTextMessages().
|
protectedinherited |
Called when you want this object to emit an event to all the observers currently subscribed to this object.
Definition at line 57 of file CObservable.cpp.
References MRPT_END, and MRPT_START.
Referenced by mrpt::gui::CDisplayWindow3D::internal_emitGrabImageEvent(), mrpt::gui::CWindowDialog::OnChar(), mrpt::gui::CWindowDialog::OnClose(), mrpt::gui::C3DWindowDialog::OnClose(), mrpt::gui::CWindowDialog::OnMouseDown(), mrpt::gui::CWindowDialog::OnMouseMove(), mrpt::gui::CWindowDialog::OnResize(), mrpt::gui::C3DWindowDialog::OnResize(), render(), and renderNormalSceneMode().
void COpenGLViewport::removeObject | ( | const CRenderizable::Ptr & | obj | ) |
Removes the given object from the scene (it also deletes the object to free its memory).
Definition at line 731 of file COpenGLViewport.cpp.
References CLASS_ID_NAMESPACE, and m_objects.
void COpenGLViewport::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 at line 458 of file COpenGLViewport.cpp.
References mrpt::img::TColorf::A, mrpt::img::TColorf::B, mrpt::img::TColorf::G, mrpt::system::CObservable::hasSubscribers(), loadDefaultShaders(), m_background_color, m_custom_backgb_color, m_isImageView, m_isTransparent, m_shaders, m_state, m_view_height, m_view_width, m_view_x, m_view_y, MRPT_END, MRPT_START, mrpt::system::CObservable::publishEvent(), mrpt::img::TColorf::R, renderImageMode(), renderNormalSceneMode(), renderTextMessages(), renderViewportBorder(), sizeFromRatio(), startFromRatio(), THROW_EXCEPTION, mrpt::opengl::TRenderMatrices::viewport_height, and mrpt::opengl::TRenderMatrices::viewport_width.
|
protected |
Render in image mode.
Definition at line 129 of file COpenGLViewport.cpp.
References mrpt::opengl::enqueForRendering(), m_imageview_plane, m_lights, m_shaders, m_state, and mrpt::opengl::processRenderQueue().
Referenced by render().
|
protected |
Render a normal scene with 3D objects.
Definition at line 210 of file COpenGLViewport.cpp.
References ASSERT_, mrpt::DEG2RAD(), mrpt::opengl::enqueForRendering(), getByClass(), mrpt::opengl::CRenderizable::getPose(), mrpt::poses::CPose3D::getRotationMatrix(), mrpt::system::CObservable::hasSubscribers(), mrpt::opengl::CCamera::is6DOFMode(), mrpt::opengl::TRenderMatrices::is_projective, mrpt::opengl::CCamera::m_azimuthDeg, m_camera, m_clip_max, m_clip_min, m_clonedViewport, mrpt::opengl::CCamera::m_elevationDeg, mrpt::opengl::CCamera::m_eyeDistance, m_isCloned, m_isClonedCamera, m_lights, m_objects, m_OpenGL_enablePolygonNicest, m_parent, mrpt::opengl::CCamera::m_pointingX, mrpt::opengl::CCamera::m_pointingY, mrpt::opengl::CCamera::m_pointingZ, mrpt::opengl::CCamera::m_projectiveFOVdeg, mrpt::opengl::CCamera::m_projectiveModel, m_shaders, m_state, MRPT_END, MRPT_START, mrpt::opengl::processRenderQueue(), mrpt::system::CObservable::publishEvent(), THROW_EXCEPTION_FMT, mrpt::poses::CPoseOrPoint< DERIVEDCLASS, DIM >::x(), and mrpt::poses::CPoseOrPoint< DERIVEDCLASS, DIM >::y().
Referenced by render().
|
protected |
Renders all messages in the underlying class CTextMessageCapable.
Definition at line 383 of file COpenGLViewport.cpp.
References mrpt::opengl::TFontParams::color, mrpt::opengl::enqueForRendering(), mrpt::opengl::CTextMessageCapable::DataPerText::gl_text, mrpt::opengl::CTextMessageCapable::DataPerText::gl_text_shadow, mrpt::opengl::TRenderMatrices::is_projective, loadDefaultShaders(), mrpt::opengl::CTextMessageCapable::m_2D_texts, m_lights, m_shaders, m_state, mrpt::opengl::CTextMessageCapable::TListTextMessages::messages, MRPT_END, MRPT_START, mrpt::opengl::TRenderMatrices::mv_matrix, mrpt::opengl::TRenderMatrices::p_matrix, mrpt::opengl::processRenderQueue(), mrpt::opengl::CTextMessageCapable::TListTextMessages::regenerateGLobjects(), mrpt::math::MatrixBase< Scalar, Derived >::setIdentity(), mrpt::opengl::TFontParams::shadow_color, mrpt::opengl::T2DTextData::text, mrpt::opengl::TFontParams::vfont_name, mrpt::opengl::TFontParams::vfont_scale, mrpt::opengl::TRenderMatrices::viewport_height, mrpt::opengl::TRenderMatrices::viewport_width, mrpt::opengl::T2DTextData::x, and mrpt::opengl::T2DTextData::y.
Referenced by render().
|
protected |
Render the viewport border, if enabled.
Definition at line 342 of file COpenGLViewport.cpp.
References mrpt::opengl::CSetOfLines::Create(), mrpt::opengl::enqueForRendering(), m_borderColor, m_borderLines, m_borderWidth, m_lights, m_shaders, m_state, MRPT_END, MRPT_START, mrpt::opengl::TRenderMatrices::mv_matrix, mrpt::opengl::processRenderQueue(), and mrpt::math::MatrixBase< Scalar, Derived >::setIdentity().
Referenced by render().
|
inline |
Reset the viewport to normal mode: rendering its own objects.
Definition at line 99 of file COpenGLViewport.h.
References setNormalMode().
|
overrideprotectedvirtual |
Pure virtual method for reading (deserializing) from an abstract archive.
Users don't call this method directly. Instead, use stream >> object;
.
in | The input binary stream where the object data must read from. |
version | The version of the object stored in the stream: use this version number in your code to know how to read the incoming data. |
std::exception | On any I/O error |
Implements mrpt::serialization::CSerializable.
Definition at line 592 of file COpenGLViewport.cpp.
References mrpt::img::TColorf::A, mrpt::opengl::CTextMessageCapable::addTextMessage(), mrpt::img::TColorf::B, clear(), mrpt::opengl::TFontParams::color, mrpt::opengl::TFontParams::draw_shadow, mrpt::img::TColorf::G, mrpt::opengl::CTextMessageCapable::m_2D_texts, m_background_color, m_borderWidth, m_camera, m_clonedViewport, m_custom_backgb_color, m_isCloned, m_isClonedCamera, m_isTransparent, m_lights, m_name, m_objects, m_OpenGL_enablePolygonNicest, m_view_height, m_view_width, m_view_x, m_view_y, mrpt::opengl::CTextMessageCapable::TListTextMessages::messages, MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION, mrpt::img::TColorf::R, mrpt::serialization::CArchive::ReadAs(), mrpt::opengl::TFontParams::shadow_color, mrpt::opengl::TFontParams::vfont_kerning, mrpt::opengl::TFontParams::vfont_name, mrpt::opengl::TFontParams::vfont_scale, mrpt::opengl::TFontParams::vfont_spacing, and mrpt::opengl::TFontParams::vfont_style.
|
inlineprotectedvirtualinherited |
Virtual method for reading (deserializing) from an abstract schema based archive.
Definition at line 74 of file CSerializable.h.
References mrpt::serialization::CSerializable::GetRuntimeClass(), and THROW_EXCEPTION.
|
overrideprotectedvirtual |
Must return the current versioning number of the object.
Start in zero for new classes, and increments each time there is a change in the stored format.
Implements mrpt::serialization::CSerializable.
Definition at line 553 of file COpenGLViewport.cpp.
|
inlineprotectedvirtualinherited |
Virtual method for writing (serializing) to an abstract schema based archive.
Definition at line 64 of file CSerializable.h.
References mrpt::serialization::CSerializable::GetRuntimeClass(), and THROW_EXCEPTION.
|
overrideprotectedvirtual |
Pure virtual method for writing (serializing) to an abstract archive.
Users don't call this method directly. Instead, use stream << object;
.
std::exception | On any I/O error |
Implements mrpt::serialization::CSerializable.
Definition at line 554 of file COpenGLViewport.cpp.
References mrpt::img::TColorf::A, mrpt::img::TColorf::B, mrpt::img::TColorf::G, mrpt::opengl::CTextMessageCapable::m_2D_texts, m_background_color, m_borderWidth, m_camera, m_clonedViewport, m_custom_backgb_color, m_isCloned, m_isClonedCamera, m_isTransparent, m_lights, m_name, m_objects, m_OpenGL_enablePolygonNicest, m_view_height, m_view_width, m_view_x, m_view_y, mrpt::opengl::CTextMessageCapable::TListTextMessages::messages, out, and mrpt::img::TColorf::R.
|
inline |
Definition at line 192 of file COpenGLViewport.h.
References m_borderColor.
|
inline |
Set the border size ("frame") of the viewport (default=0)
Definition at line 186 of file COpenGLViewport.h.
References m_borderWidth.
|
inline |
If set to true, and setCloneView() has been called, this viewport will be rendered using the camera of the cloned viewport.
Definition at line 103 of file COpenGLViewport.h.
References m_isClonedCamera.
void COpenGLViewport::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.
By default, only the objects are cloned, not the camera. See
Definition at line 58 of file COpenGLViewport.cpp.
References clear(), m_clonedViewport, and m_isCloned.
void COpenGLViewport::setCurrentCameraFromPose | ( | mrpt::poses::CPose3D & | p | ) |
Changes the point of view of the camera, from a given pose.
Definition at line 881 of file COpenGLViewport.cpp.
References m_camera, mrpt::opengl::CCamera::set6DOFMode(), and mrpt::opengl::CRenderizable::setPose().
|
inline |
Set a background color different from that of the parent GUI window.
Definition at line 204 of file COpenGLViewport.h.
References m_background_color, and m_custom_backgb_color.
void COpenGLViewport::setImageView | ( | const mrpt::img::CImage & | img | ) |
Set this viewport into "image view"-mode, where an image is efficiently drawn (fitting the viewport area) using an OpenGL textured quad.
Call this method with the new image to update the displayed image (but recall to first lock the parent openglscene's critical section, then do the update, then release the lock, and then issue a window repaint). Internally, the texture is drawn using a mrpt::opengl::CTexturedPlane The viewport can be reverted to behave like a normal viewport by calling setNormalMode()
Definition at line 906 of file COpenGLViewport.cpp.
References internal_enableImageView(), and m_imageview_plane.
void COpenGLViewport::setImageView | ( | mrpt::img::CImage && | img | ) |
Just like setImageView but moves the internal image memory instead of making a copy, so it's faster but empties the input image.
Definition at line 911 of file COpenGLViewport.cpp.
References internal_enableImageView(), and m_imageview_plane.
void COpenGLViewport::setNormalMode | ( | ) |
Resets the viewport to a normal 3D viewport.
Definition at line 896 of file COpenGLViewport.cpp.
References m_imageview_plane, m_isCloned, m_isClonedCamera, and m_isImageView.
Referenced by resetCloneView().
|
inline |
Set the transparency, that is, whether the viewport will be rendered transparent over previous viewports (default=false).
Definition at line 202 of file COpenGLViewport.h.
References m_isTransparent.
void COpenGLViewport::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 at line 745 of file COpenGLViewport.cpp.
References ASSERT_ABOVE_, m_clip_max, and m_clip_min.
void COpenGLViewport::setViewportPosition | ( | const double | x, |
const double | y, | ||
const double | width, | ||
const double | height | ||
) |
Change the viewport position and dimension on the rendering window.
X & Y coordinates here can have two interpretations:
width & height can be interpreted as:
Definition at line 65 of file COpenGLViewport.cpp.
References ASSERT_, m_view_height, m_view_width, m_view_x, m_view_y, MRPT_END, and MRPT_START.
|
inline |
Number of objects contained.
Definition at line 311 of file COpenGLViewport.h.
References m_objects.
|
protected |
Unload shader programs in m_shaders.
Definition at line 185 of file COpenGLViewport.cpp.
References m_shaders.
|
inherited |
Just updates the text of a given text message, without touching the other parameters.
Definition at line 48 of file CTextMessageCapable.cpp.
|
inlinevirtualinherited |
Introduces a pure virtual method responsible for writing to a mxArray
Matlab object, typically a MATLAB struct
whose contents are documented in each derived class.
mxArray
(caller is responsible of memory freeing) or nullptr is class does not support conversion to MATLAB. Definition at line 90 of file CSerializable.h.
|
friend |
Definition at line 66 of file COpenGLViewport.h.
|
static |
Definition at line 65 of file COpenGLViewport.h.
|
protectedinherited |
Definition at line 76 of file CTextMessageCapable.h.
Referenced by mrpt::opengl::CTextMessageCapable::getTextMessages(), renderTextMessages(), serializeFrom(), and serializeTo().
|
protected |
used only if m_custom_backgb_color
Definition at line 383 of file COpenGLViewport.h.
Referenced by getCustomBackgroundColor(), render(), serializeFrom(), serializeTo(), and setCustomBackgroundColor().
|
protected |
Definition at line 375 of file COpenGLViewport.h.
Referenced by getBorderColor(), renderViewportBorder(), and setBorderColor().
|
mutableprotected |
Definition at line 390 of file COpenGLViewport.h.
Referenced by renderViewportBorder().
|
protected |
Default=0, the border around the viewport.
Definition at line 373 of file COpenGLViewport.h.
Referenced by getBorderSize(), renderViewportBorder(), serializeFrom(), serializeTo(), and setBorderSize().
|
protected |
The camera associated to the viewport.
Definition at line 359 of file COpenGLViewport.h.
Referenced by getCamera(), renderNormalSceneMode(), serializeFrom(), serializeTo(), and setCurrentCameraFromPose().
|
protected |
Definition at line 380 of file COpenGLViewport.h.
Referenced by getViewportClipDistances(), renderNormalSceneMode(), and setViewportClipDistances().
|
protected |
The min/max clip depth distances (default: 0.1 - 10000)
Definition at line 380 of file COpenGLViewport.h.
Referenced by getViewportClipDistances(), renderNormalSceneMode(), and setViewportClipDistances().
|
protected |
Only if m_isCloned=true.
Definition at line 367 of file COpenGLViewport.h.
Referenced by renderNormalSceneMode(), serializeFrom(), serializeTo(), and setCloneView().
|
protected |
Definition at line 381 of file COpenGLViewport.h.
Referenced by render(), serializeFrom(), serializeTo(), and setCustomBackgroundColor().
|
protected |
The image to display, after calling setImageView()
Definition at line 388 of file COpenGLViewport.h.
Referenced by internal_enableImageView(), renderImageMode(), setImageView(), and setNormalMode().
|
protected |
Set by setCloneView.
Definition at line 363 of file COpenGLViewport.h.
Referenced by renderNormalSceneMode(), serializeFrom(), serializeTo(), setCloneView(), and setNormalMode().
|
protected |
Set by setCloneCamera.
Definition at line 365 of file COpenGLViewport.h.
Referenced by renderNormalSceneMode(), serializeFrom(), serializeTo(), setCloneCamera(), and setNormalMode().
|
protected |
Set by setImageView.
Definition at line 385 of file COpenGLViewport.h.
Referenced by internal_enableImageView(), render(), and setNormalMode().
|
protected |
Whether to clear color buffer.
Definition at line 371 of file COpenGLViewport.h.
Referenced by isTransparent(), render(), serializeFrom(), serializeTo(), and setTransparent().
|
protected |
Definition at line 415 of file COpenGLViewport.h.
Referenced by lightParameters(), renderImageMode(), renderNormalSceneMode(), renderTextMessages(), renderViewportBorder(), serializeFrom(), and serializeTo().
|
protected |
The viewport's name.
Definition at line 369 of file COpenGLViewport.h.
Referenced by getName(), serializeFrom(), and serializeTo().
|
protected |
The list of objects that comprise the 3D scene.
Objects are automatically deleted when calling "clear" or in the destructor.
Definition at line 408 of file COpenGLViewport.h.
Referenced by begin(), clear(), dumpListOfObjects(), empty(), end(), getBoundingBox(), getByClass(), getByName(), initializeTextures(), insert(), removeObject(), renderNormalSceneMode(), serializeFrom(), serializeTo(), and size().
|
protected |
Definition at line 413 of file COpenGLViewport.h.
Referenced by enablePolygonNicest(), isPolygonNicestEnabled(), renderNormalSceneMode(), serializeFrom(), and serializeTo().
|
protected |
The scene that contains this viewport.
Definition at line 361 of file COpenGLViewport.h.
Referenced by renderNormalSceneMode().
|
mutableprotected |
Default shader program.
Definition at line 396 of file COpenGLViewport.h.
Referenced by loadDefaultShaders(), render(), renderImageMode(), renderNormalSceneMode(), renderTextMessages(), renderViewportBorder(), and unloadShaders().
|
mutableprotected |
Info updated with each "render()" and used in "get3DRayForPixelCoord".
Definition at line 393 of file COpenGLViewport.h.
Referenced by get3DRayForPixelCoord(), render(), renderImageMode(), renderNormalSceneMode(), renderTextMessages(), and renderViewportBorder().
|
protected |
Definition at line 378 of file COpenGLViewport.h.
Referenced by getViewportPosition(), render(), serializeFrom(), serializeTo(), and setViewportPosition().
|
protected |
Definition at line 378 of file COpenGLViewport.h.
Referenced by getViewportPosition(), render(), serializeFrom(), serializeTo(), and setViewportPosition().
|
protected |
The viewport position [0,1].
Definition at line 378 of file COpenGLViewport.h.
Referenced by getViewportPosition(), render(), serializeFrom(), serializeTo(), and setViewportPosition().
|
protected |
Definition at line 378 of file COpenGLViewport.h.
Referenced by getViewportPosition(), render(), serializeFrom(), serializeTo(), and setViewportPosition().
|
staticprotected |
Definition at line 65 of file COpenGLViewport.h.
Page generated by Doxygen 1.8.14 for MRPT 2.0.4 Git: 33de1d0ad Sat Jun 20 11:02:42 2020 +0200 at sáb jun 20 17:35:17 CEST 2020 |