53 insert(objs.begin(), objs.end());
75 void render(
const RenderContext& rc)
const override;
83 if (o) o->freeOpenGLResources();
88 if (o) o->initializeTextures();
113 template <
typename T>
114 typename T::Ptr
getByClass(
size_t ith = 0)
const;
186 o->insertCollection(v);
192 template <
typename T>
196 size_t foundCount = 0;
197 const auto class_ID = &T::GetRuntimeClassIdStatic();
199 if (o && o->GetRuntimeClass()->derivedFrom(class_ID))
200 if (foundCount++ == ith)
return std::dynamic_pointer_cast<T>(o);
205 if (o && o->GetRuntimeClass() ==
208 typename T::Ptr obj = std::dynamic_pointer_cast<
CSetOfObjects>(o)
209 ->
template getByClass<T>(ith);
214 return typename T::Ptr();
void clear()
Clear the list of objects in the scene, deleting objects' memory.
A set of object, which are referenced to the coordinates framework established in this object...
void initializeTextures() const override
Initializes all textures (loads them into opengl memory).
void insertCollection(const T &objs)
Inserts a set of objects into the list.
CListOpenGLObjects::const_iterator const_iterator
std::deque< CRenderizable::Ptr > CListOpenGLObjects
A list of smart pointers to renderizable objects.
bool contains(const CRenderizable::Ptr &obj) const
CListOpenGLObjects m_objects
The list of child objects.
std::shared_ptr< mrpt::opengl ::CSetOfObjects > Ptr
bool traceRay(const mrpt::poses::CPose3D &o, double &dist) const override
Simulation of ray-trace, given a pose.
COpenGLScene::Ptr & operator<<(COpenGLScene::Ptr &s, const CRenderizable::Ptr &r)
Inserts an openGL object into a scene.
The base class of 3D objects that can be directly rendered through OpenGL.
bool empty() const
Returns true if there are no objects.
std::shared_ptr< CRenderizable > Ptr
CRenderizable & setColorR_u8(const uint8_t r) override
Color components in the range [0,255].
std::vector< shader_id_t > shader_list_t
A list of shader IDs.
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...
CRenderizable & setColorG_u8(const uint8_t g) override
Color components in the range [0,255].
void insert(const T_it &begin, const T_it &end)
Inserts a set of objects, bounded by iterators, into the list.
const_iterator end() const
void renderUpdateBuffers() const override
Called whenever m_outdatedBuffers is true: used to re-generate OpenGL vertex buffers, etc.
size_t size()
Returns number of objects.
CRenderizable & setColorA_u8(const uint8_t a) override
Color components in the range [0,255].
static constexpr shader_id_t WIREFRAME
virtual ~CSetOfObjects() override=default
Rendering state related to the projection and model-view matrices.
Declares a class that represents a probability density function (pdf) of a 2D pose (x...
const_iterator begin() const
CListOpenGLObjects::iterator iterator
void removeObject(const CRenderizable::Ptr &obj)
Removes the given object from the scene (it also deletes the object to free its memory).
#define CLASS_ID_NAMESPACE(class_name, namespaceName)
static CSetOfObjects::Ptr posePDF2opengl(const mrpt::poses::CPosePDF &o)
Returns a representation of a the PDF - this is just an auxiliary function, it's more natural to call...
void freeOpenGLResources() override
Free opengl buffers.
void dumpListOfObjects(std::vector< std::string > &lst)
Retrieves a list of all objects in text form.
Declares a class that represents a Probability Density Function (PDF) of a 3D pose (6D actually)...
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
void render(const RenderContext &rc) const override
Implements the rendering of 3D objects in each class derived from CRenderizable.
The namespace for 3D scene representation and rendering.
void enqueForRenderRecursive(const mrpt::opengl::TRenderMatrices &state, RenderQueue &rq) const override
#define DEFINE_SERIALIZABLE(class_name, NS)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
CRenderizable & setColor_u8(const mrpt::img::TColor &c) override
Declares a class that represents a Probability Distribution function (PDF) of a 3D point (x...
CRenderizable::Ptr getByName(const std::string &str)
Returns the first object with a given name, or a nullptr pointer if not found.
void insert(const CRenderizable::Ptr &newObject)
Insert a new object to the list.
CRenderizable & setColorB_u8(const uint8_t b) override
Color components in the range [0,255].
Declares a class that represents a Probability Density Function (PDF) of a 3D pose (6D actually)...
void getBoundingBox(mrpt::math::TPoint3D &bb_min, mrpt::math::TPoint3D &bb_max) const override
Evaluates the bounding box of this object (including possible children) in the coordinate frame of th...
shader_list_t requiredShaders() const override
Returns the ID of the OpenGL shader program required to render this class.
std::map< shader_id_t, std::multimap< float, RenderQueueElement > > RenderQueue
A queue for rendering, sorted by shader program to minimize changes of OpenGL shader programs while r...