26 class COpenGLViewport;
29 struct TLightParameters;
405 std::map<shader_id_t, mrpt::opengl::Program::Ptr>& shaders,
virtual void renderUpdateBuffers() const =0
Called whenever m_outdatedBuffers is true: used to re-generate OpenGL vertex buffers, etc.
A 2D text (bitmap rendering): it always "faces the observer" despite it's at some 3D location...
void setName(const std::string &n)
Changes the name of the object.
const mrpt::opengl::Program * shader
float getColorA() const
Color components in the range [0,1].
double getPosePitch() const
Rotation relative to parent coordinate origin, in DEGREES.
virtual void render(const RenderContext &rc) const =0
Implements the rendering of 3D objects in each class derived from CRenderizable.
const mrpt::opengl::TRenderMatrices * state
float getScaleX() const
Get the current scaling factor in one axis.
virtual void initializeTextures() const
Initializes all textures (loads them into opengl memory).
A set of object, which are referenced to the coordinates framework established in this object...
#define THROW_EXCEPTION(msg)
virtual CRenderizable & setColorA_u8(const uint8_t a)
Color components in the range [0,255].
bool hasToUpdateBuffers() const
Returns whether notifyChange() has been invoked since the last call to renderUpdateBuffers(), meaning the latter needs to be called again before rendering.
~CRenderizable() override
CRenderizable & setLocation(const mrpt::math::TPoint3D &p)
Changes the location of the object, keeping untouched the orientation.
void notifyChange() const
Call to enable calling renderUpdateBuffers() before the next render() rendering iteration.
std::deque< CRenderizable::Ptr > CListOpenGLObjects
A list of smart pointers to renderizable objects.
CRenderizable & setColorB(const float b)
Color components in the range [0,1].
virtual bool traceRay(const mrpt::poses::CPose3D &o, double &dist) const
Simulation of ray-trace, given a pose.
double getPosePitchRad() const
Rotation relative to parent coordinate origin, in radians.
CRenderizable & setColorR(const float r)
Color components in the range [0,1].
mrpt::opengl::shader_id_t shader_id
void processRenderQueue(const RenderQueue &rq, std::map< shader_id_t, mrpt::opengl::Program::Ptr > &shaders, const mrpt::opengl::TLightParameters &lights)
After enqueForRendering(), actually executes the rendering tasks, grouped shader by shader...
uint8_t getColorR_u8() const
Color components in the range [0,255].
The base class of 3D objects that can be directly rendered through OpenGL.
const mrpt::opengl::TLightParameters * lights
virtual void getBoundingBox(mrpt::math::TPoint3D &bb_min, mrpt::math::TPoint3D &bb_max) const =0
Evaluates the bounding box of this object (including possible children) in the coordinate frame of th...
double pitch() const
Get the PITCH angle (in radians)
CRenderizable & setLocation(double x, double y, double z)
Changes the location of the object, keeping untouched the orientation.
float getColorB() const
Color components in the range [0,1].
double yaw() const
Get the YAW angle (in radians)
double getPoseX() const
Translation relative to parent coordinate origin.
virtual CRenderizable & setColorR_u8(const uint8_t r)
Color components in the range [0,255].
virtual void enqueForRenderRecursive([[maybe_unused]] const mrpt::opengl::TRenderMatrices &state, [[maybe_unused]] RenderQueue &rq) const
Process all children objects recursively, if the object is a container.
void enableShowName(bool showName=true)
Enables or disables showing the name of the object as a label when rendering.
mrpt::opengl::CText & labelObject() const
Returns or constructs (in its first invokation) the associated mrpt::opengl::CText object representin...
double getPoseZ() const
Translation relative to parent coordinate origin.
uint8_t getColorA_u8() const
Color components in the range [0,255].
double getPoseRoll() const
Rotation relative to parent coordinate origin, in DEGREES.
mrpt::poses::CPose3D m_pose
6D pose wrt the parent coordinate reference.
A viewport within a COpenGLScene, containing a set of OpenGL objects to render.
std::vector< shader_id_t > shader_list_t
A list of shader IDs.
std::shared_ptr< mrpt::opengl::CText > m_label_obj
Optional pointer to a mrpt::opengl::CText.
Context for calls to render()
const mrpt::img::TColor & getColor_u8() const
Returns the object color property as a TColor.
#define DEFINE_VIRTUAL_SERIALIZABLE(class_name)
This declaration must be inserted in virtual CSerializable classes definition:
CRenderizable & setColor(const mrpt::img::TColorf &c)
Changes the default object color.
float m_scale_x
Scale components to apply to the object (default=1)
virtual mrpt::math::TPoint3Df getLocalRepresentativePoint() const
Provide a representative point (in object local coordinates), used to sort objects by eye-distance wh...
virtual CRenderizable & setColorB_u8(const uint8_t b)
Color components in the range [0,255].
virtual CRenderizable & setColor_u8(const mrpt::img::TColor &c)
void writeToStreamRender(mrpt::serialization::CArchive &out) const
uint8_t getColorG_u8() const
Color components in the range [0,255].
void enqueForRendering(const mrpt::opengl::CListOpenGLObjects &objs, const mrpt::opengl::TRenderMatrices &state, RenderQueue &rq)
Processes, recursively, all objects in the list, classifying them by shader programs into a list suit...
CRenderizable & setColor_u8(uint8_t R, uint8_t G, uint8_t B, uint8_t A=255)
Set the color components of this object (R,G,B,Alpha, in the range 0-255)
virtual CRenderizable & setColorG_u8(const uint8_t g)
Color components in the range [0,255].
bool isVisible() const
Is the object visible?
uint8_t shader_id_t
Type for IDs of shaders.
CRenderizable & setColorG(const float g)
Color components in the range [0,1].
CRenderizable & setColorA(const float a)
Color components in the range [0,1].
CRenderizable & setScale(float sx, float sy, float sz)
Scale to apply to the object in each axis (default=1)
const std::string & getName() const
Returns the name of the object.
void setLocalRepresentativePoint(const mrpt::math::TPoint3Df &p)
See getLocalRepresentativePoint()
virtual void freeOpenGLResources()=0
Free opengl buffers.
double x() const
Common members of all points & poses classes.
CRenderizable & setScale(float s)
Scale to apply to the object, in all three axes (default=1)
Rendering state related to the projection and model-view matrices.
A class used to store a 2D point.
A class used to store a 3D point.
double roll() const
Get the ROLL angle (in radians)
double getPoseYawRad() const
Rotation relative to parent coordinate origin, in radians.
float getColorR() const
Color components in the range [0,1].
mrpt::img::TColor m_color
Color components in the range [0,255].
double getPoseY() const
Translation relative to parent coordinate origin.
virtual shader_list_t requiredShaders() const
Returns the ID of the OpenGL shader program required to render this class.
bool isShowNameEnabled() const
uint8_t f2u8(const float f)
converts a float [0,1] into an uint8_t [0,255] (without checking for out of bounds) ...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Virtual base class for "archives": classes abstracting I/O streams.
void setVisibility(bool visible=true)
Set object visibility (default=true)
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle...
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
mrpt::vision::TStereoCalibResults out
double getPoseYaw() const
Rotation relative to parent coordinate origin, in DEGREES.
constexpr double RAD2DEG(const double x)
Radians to degrees.
mrpt::img::TColorf getColor() const
Returns the object color property as a TColorf.
An RGBA color - floats in the range [0,1].
float u8tof(const uint8_t v)
converts a uint8_t [0,255] into a float [0,1]
Lightweight 3D pose (three spatial coordinates, plus three angular coordinates).
The namespace for 3D scene representation and rendering.
The virtual base class which provides a unified interface for all persistent objects in MRPT...
mrpt::math::TPoint3Df m_representativePoint
CRenderizable & setPose(const mrpt::poses::CPose3D &o)
Set the 3D pose from a mrpt::poses::CPose3D object (return a ref to this)
double getPoseRollRad() const
Rotation relative to parent coordinate origin, in radians.
const mrpt::poses::CPose3D & getPoseRef() const
Returns a const ref to the 3D pose of the object as mrpt::poses::CPose3D (which explicitly contains t...
float getScaleY() const
Get the current scaling factor in one axis.
void readFromStreamRender(mrpt::serialization::CArchive &in)
A resource handling helper for OpenGL Shader "programs".
uint8_t getColorB_u8() const
Color components in the range [0,255].
bool m_visible
Is the object visible? (default=true)
float getColorG() const
Color components in the range [0,1].
CRenderizable()
Default constructor:
void updateBuffers() const
Calls renderUpdateBuffers() and clear the flag that is set with notifyChange()
mrpt::math::TPose3D getPose() const
Returns the 3D pose of the object as TPose3D.
Lighting parameters, mostly for triangle shaders.
float getScaleZ() const
Get the current scaling factor in one axis.
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...
CRenderizable & setColor(float R, float G, float B, float A=1)
Set the color components of this object (R,G,B,Alpha, in the range 0-1)