Go to the documentation of this file.
28 #if MRPT_HAS_OPENGL_GLUT
32 #pragma comment(lib, "opengl32.lib")
33 #pragma comment(lib, "GlU32.lib")
36 #endif // MRPT_HAS_OPENGL_GLUT
57 if (v) v->unloadShaders();
81 dynamic_cast<mrpt::opengl::COpenGLViewport*>(ptr->clone()));
94 #if MRPT_HAS_OPENGL_GLUT
98 glGetIntegerv(GL_VIEWPORT, win_dims);
102 m_viewport->render(win_dims[2], win_dims[3]);
105 glViewport(win_dims[0], win_dims[1], win_dims[2], win_dims[3]);
106 CHECK_OPENGL_ERROR();
110 "The MRPT has been compiled with MRPT_HAS_OPENGL_GLUT=0! OpenGL "
111 "functions are not implemented");
143 view->m_objects.resize(n);
145 view->m_objects.begin(), view->m_objects.end(),
157 for (i = 0; i < n; i++)
159 CSerializable::Ptr newObj;
163 std::dynamic_pointer_cast<COpenGLViewport>(newObj);
164 newView->m_parent =
this;
183 if (m_viewport->m_name == viewportName)
185 m_viewport->insert(newObject);
190 "Error: viewport '%s' not found.", viewportName.c_str());
198 const string& str, [[maybe_unused]]
const string& viewportName)
202 if ((obj = m_viewport->getByName(str)))
break;
208 for (
auto& m_viewport :
m_viewports) m_viewport->initializeTextures();
220 lst.emplace_back(
string(
"VIEWPORT: ") + v->m_name);
221 lst.emplace_back(
"============================================");
222 v->dumpListOfObjects(lst);
236 auto theNew = std::make_shared<COpenGLViewport>(
this, viewportName);
247 const std::string& viewportName)
const
251 if (m_viewport->m_name == viewportName)
return m_viewport;
266 view->removeObject(obj);
277 for (
auto it2 = vp->m_objects.begin(); it2 != vp->m_objects.end();
279 if ((*it2)->traceRay(o, tmp))
325 const std::string& vpn)
const
328 ASSERTMSG_(vp,
"No opengl viewport exists with the given name");
336 o->freeOpenGLResources();
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
void insert(const CRenderizable::Ptr &newObject, const std::string &viewportName=std::string("main"))
Insert a new object into the scene, in the given viewport (by default, into the "main" viewport).
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
The base class of 3D objects that can be directly rendered through OpenGL.
This class allows the user to create, load, save, and render 3D scenes using OpenGL primitives.
void unloadShaders()
Ensure all shaders are unloaded in all viewports.
void initializeTextures()
Initializes all textures in the scene (See opengl::CTexturedPlane::initializeTextures)
mrpt::vision::TStereoCalibResults out
std::shared_ptr< CRenderizable > Ptr
#define THROW_EXCEPTION_FMT(_FORMAT_STRING,...)
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
#define THROW_EXCEPTION(msg)
#define ASSERT_(f)
Defines an assertion mechanism.
void dumpListOfObjects(std::vector< std::string > &lst)
Retrieves a list of all objects in text form.
Virtual base class for "archives": classes abstracting I/O streams.
void getBoundingBox(mrpt::math::TPoint3D &bb_min, mrpt::math::TPoint3D &bb_max, const std::string &vpn=std::string("main")) const
Evaluates the bounding box of the scene in the given viewport (default: "main").
TListViewports m_viewports
The list of viewports, indexed by name.
std::shared_ptr< mrpt::opengl ::COpenGLViewport > Ptr
Saves data to a file and transparently compress the data using the given compression level.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
bool loadFromFile(const std::string &fil)
Loads the scene from a 3Dscene file, the format used by the application SceneViewer3D.
COpenGLViewport::Ptr createViewport(const std::string &viewportName)
Creates a new viewport, adding it to the scene and returning a pointer to the new object.
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
To be added to all CSerializable-classes implementation files.
#define ASSERTMSG_(f, __ERROR_MSG)
Defines an assertion mechanism.
bool saveToFile(const std::string &fil) const
Saves the scene to a 3Dscene file, loadable by the application SceneViewer3D.
CArchiveStreamBase< STREAM > archiveFrom(STREAM &s)
Helper function to create a templatized wrapper CArchive object for a: MRPT's CStream,...
void clear(bool createMainViewport=true)
Clear the list of objects and viewports in the scene, deleting objects' memory, and leaving just the ...
COpenGLScene & operator=(const COpenGLScene &obj)
This base provides a set of functions for maths stuff.
void removeObject(const CRenderizable::Ptr &obj, const std::string &viewportName=std::string("main"))
Removes the given object from the scene (it also deletes the object to free its memory).
void freeOpenGLResources()
Ensure all OpenGL buffers are destroyed.
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
COpenGLViewport::Ptr getViewport(const std::string &viewportName=std::string("main")) const
Returns the viewport with the given name, or nullptr if it does not exist; note that the default view...
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
CRenderizable::Ptr getByName(const std::string &str, const std::string &viewportName=std::string("main"))
Returns the first object with a given name, or nullptr (an empty smart pointer) if not found.
The namespace for 3D scene representation and rendering.
void render() const
Render this scene.
void visitAllObjects(FUNCTOR functor) const
Recursive depth-first visit all objects in all viewports of the scene, calling the user-supplied func...
bool traceRay(const mrpt::poses::CPose3D &o, double &dist) const
Traces a ray.
Page generated by Doxygen 1.8.17 for MRPT 2.0.3 at Fri May 29 13:06:46 UTC 2020 | |