9 #ifndef opengl_CRenderizable_H
10 #define opengl_CRenderizable_H
25 class COpenGLViewport;
54 mrpt::utils::TColor m_color;
55 mrpt::poses::CPose3D m_pose;
56 float m_scale_x, m_scale_y, m_scale_z;
63 void setName(const std::
string &n) { m_name=n; }
64 const std::string &
getName()
const {
return m_name; }
87 inline double getPoseX()
const {
return m_pose.x(); }
88 inline double getPoseY()
const {
return m_pose.y(); }
89 inline double getPoseZ()
const {
return m_pose.z(); }
97 inline double getColorR()
const {
return m_color.R/255.; }
98 inline double getColorG()
const {
return m_color.G/255.; }
99 inline double getColorB()
const {
return m_color.B/255.; }
100 inline double getColorA()
const {
return m_color.A/255.; }
118 inline CRenderizable&
setScale(
float sx,
float sy,
float sz) { m_scale_x=sx; m_scale_y=sy; m_scale_z = sz;
return *
this; }
131 inline CRenderizable&
setColor(
double R,
double G,
double B,
double A=1) {
return setColor_u8(R*255,G*255,B*255,A*255); }
169 const std::string &str,
180 const std::string &str,
#define DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
#define DEFINE_VIRTUAL_SERIALIZABLE(class_name)
This declaration must be inserted in virtual CSerializable classes definition:
#define DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
This declaration must be inserted in all CSerializable classes definition, before the class declarati...
A viewport within a COpenGLScene, containing a set of OpenGL objects to render.
The base class of 3D objects that can be directly rendered through OpenGL.
void writeToStreamRender(utils::CStream &out) const
bool isVisible() const
Is the object visible?
uint8_t getColorB_u8() const
Color components in the range [0,255].
double getPoseRollRad() const
Rotation relative to parent coordinate origin, in radians.
virtual CRenderizable & setColorG_u8(const uint8_t g)
Color components in the range [0,255].
double getColorR() const
Color components in the range [0,1].
CRenderizable & setColor(double R, double G, double B, double A=1)
Set the color components of this object (R,G,B,Alpha, in the range 0-1)
virtual CRenderizable & setColorR_u8(const uint8_t r)
Color components in the range [0,255].
static void checkOpenGLError()
Checks glGetError and throws an exception if an error situation is found.
double getColorB() const
Color components in the range [0,1].
void setVisibility(bool visible=true)
Set object visibility (default=true)
CRenderizable & setPose(const mrpt::math::TPose3D &o)
Set the 3D pose from a mrpt::math::TPose3D object (return a ref to this)
const mrpt::utils::TColor & getColor_u8() const
Returns the object color property as a TColor.
static void releaseTextureName(unsigned int i)
CRenderizable & setColorG(const double g)
Color components in the range [0,1].
CRenderizable & setLocation(const mrpt::math::TPoint3D &p)
Changes the location of the object, keeping untouched the orientation.
CRenderizable & setColor(const mrpt::utils::TColorf &c)
static void renderTextBitmap(int screen_x, int screen_y, const std::string &str, float color_r=1, float color_g=1, float color_b=1, mrpt::opengl::TOpenGLFont font=mrpt::opengl::MRPT_GLUT_BITMAP_TIMES_ROMAN_24)
Render a text message in the current rendering context, creating a glViewport in the way (do not call...
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...
double getColorG() const
Color components in the range [0,1].
virtual CRenderizable & setColorA_u8(const uint8_t a)
Color components in the range [0,255].
virtual CRenderizable & setColor_u8(const mrpt::utils::TColor &c)
double getPosePitchRad() const
Rotation relative to parent coordinate origin, in radians.
CRenderizable & setPose(const mrpt::poses::CPoint3D &o)
Set the 3D pose from a mrpt::poses::CPose3D object (return a ref to this)
virtual bool traceRay(const mrpt::poses::CPose3D &o, double &dist) const
Simulation of ray-trace, given a pose.
double getPoseZ() const
Translation relative to parent coordinate origin.
double getPoseRoll() const
Rotation relative to parent coordinate origin, in DEGREES.
CRenderizable & setPose(const mrpt::poses::CPose3D &o)
Set the 3D pose from a mrpt::poses::CPose3D object (return a ref to this)
CRenderizable * clone() const
Interface for the stlplus smart pointer class.
uint8_t getColorA_u8() const
Color components in the range [0,255].
static int textBitmapWidth(const std::string &str, mrpt::opengl::TOpenGLFont font=mrpt::opengl::MRPT_GLUT_BITMAP_TIMES_ROMAN_24)
Return the exact width in pixels for a given string, as will be rendered by renderTextBitmap().
float getScaleZ() const
Get the current scaling factor in one axis.
virtual void render() const =0
Implements the rendering of 3D objects in each class derived from CRenderizable.
uint8_t getColorG_u8() const
Color components in the range [0,255].
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-1)
CRenderizable & setLocation(double x, double y, double z)
Changes the location of the object, keeping untouched the orientation.
float getScaleX() const
Get the current scaling factor in one axis.
void readFromStreamRender(utils::CStream &in)
mrpt::math::TPose3D getPose() const
Returns the 3D pose of the object as TPose3D.
virtual CRenderizable & setColorB_u8(const uint8_t b)
Color components in the range [0,255].
bool isShowNameEnabled() const
static void renderTextBitmap(const char *str, void *fontStyle)
This method is safe for calling from within ::render() methods.
float getScaleY() const
Get the current scaling factor in one axis.
double getPoseY() const
Translation relative to parent coordinate origin.
double getPoseYawRad() const
Rotation relative to parent coordinate origin, in radians.
CRenderizable & setColorB(const double b)
Color components in the range [0,1].
const std::string & getName() const
Returns the name of the object.
void enableShowName(bool showName=true)
Enables or disables showing the name of the object as a label when rendering.
CRenderizable & setColorR(const double r)
Color components in the range [0,1].
uint8_t getColorR_u8() const
Color components in the range [0,255].
CRenderizable & setColorA(const double a)
Color components in the range [0,1].
double getPoseYaw() const
Rotation relative to parent coordinate origin, in DEGREES.
double getColorA() const
Color components in the range [0,1].
mrpt::utils::TColorf getColor() const
Returns the object color property as a TColorf.
CRenderizable & setScale(float sx, float sy, float sz)
Scale to apply to the object in each axis (default=1)
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...
CRenderizable & setPose(const mrpt::poses::CPoint2D &o)
Set the 3D pose from a mrpt::poses::CPose3D object (return a ref to this)
CRenderizable()
Default constructor:
static unsigned int getNewTextureNumber()
Returns the lowest next free texture name (avoid using OpenGL's own function since we may call them f...
double getPosePitch() const
Rotation relative to parent coordinate origin, in DEGREES.
CRenderizable & setScale(float s)
Scale to apply to the object, in all three axes (default=1)
double getPoseX() const
Translation relative to parent coordinate origin.
A set of object, which are referenced to the coordinates framework established in this object.
A class used to store a 2D point.
A class used to store a 3D point.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
The virtual base class which provides a unified interface for all persistent objects in MRPT.
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
TOpenGLFont
Existing fonts for 2D texts in mrpt::opengl methods.
@ MRPT_GLUT_BITMAP_TIMES_ROMAN_24
std::deque< CRenderizablePtr > CListOpenGLObjects
A list of objects pointers, automatically managing memory free at destructor, and managing copies cor...
double RAD2DEG(const double x)
Radians to degrees.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
double z
X,Y,Z coordinates.
Lightweight 3D pose (three spatial coordinates, plus three angular coordinates).
A RGB color - floats in the range [0,1].