Go to the documentation of this file.
30 #define MAX_GL_TEXTURE_IDS 0x10000
31 #define MAX_GL_TEXTURE_IDS_MASK 0x0FFFF
45 std::recursive_mutex
cs;
55 CRenderizable::CRenderizable()
58 m_color(255, 255, 255, 255),
77 std::lock_guard<std::recursive_mutex> lock(booker.cs);
79 unsigned int ret = booker.next_free_texture;
80 unsigned int tries = 0;
81 while (ret != 0 && booker.freeTextureNames[ret])
88 "Maximum number of textures (%u) excedeed! (are you deleting "
93 booker.freeTextureNames[ret] =
true;
94 booker.next_free_texture = ret + 1;
102 std::lock_guard<std::recursive_mutex> lock(booker.
cs);
123 const uint8_t serialization_version =
126 const bool all_scales_equal =
128 const bool all_scales_unity = (all_scales_equal &&
m_scale_x == 1.0f);
130 const uint8_t magic_signature[2] = {
136 serialization_version |
137 (all_scales_unity ? 0xC0 : (all_scales_equal ? 0xA0 : 0x80)))};
139 out << magic_signature[0] << magic_signature[1];
153 if (!all_scales_unity)
155 if (all_scales_equal)
173 uint8_t magic_signature[2 + 2];
179 in >> magic_signature[0] >> magic_signature[1];
181 const bool is_new_format =
182 (magic_signature[0] == 0xFF) && ((magic_signature[1] & 0x80) != 0);
187 uint8_t serialization_version = (magic_signature[1] & 0x1F);
188 const bool all_scales_unity = ((magic_signature[1] & 0x40) != 0);
189 const bool all_scales_equal_but_not_unity =
190 ((magic_signature[1] & 0x20) != 0);
192 switch (serialization_version)
213 if (all_scales_unity)
217 if (all_scales_equal_but_not_unity)
231 "Can't parse CRenderizable standard data field: corrupt "
232 "data stream or format in a newer MRPT format? "
233 "(serialization version=%u)",
234 static_cast<unsigned int>(serialization_version))
242 in >> magic_signature[2] >> magic_signature[3];
245 magic_signature_uint32;
252 float yaw_deg, pitch_deg, roll_deg;
255 in >> col.
R >> col.
G >> col.
B >> col.
A;
257 col.
R / 255, col.
G / 255, col.
B / 255,
274 if (f != 16.0f && f != 17.0f)
TOpenGLFont
Existing fonts for 2D texts in mrpt::opengl methods.
static unsigned int getNewTextureNumber()
Returns the lowest next free texture name (avoid using OpenGL's own function since we may call them f...
CRenderizable & setPose(const mrpt::poses::CPose3D &o)
Set the 3D pose from a mrpt::poses::CPose3D object (return a ref to this)
unsigned __int16 uint16_t
double pitch() const
Get the PITCH angle (in radians)
static void renderTextBitmap(const char *str, void *fontStyle)
This method is safe for calling from within ::render() methods.
void readFromStreamRender(mrpt::serialization::CArchive &in)
void renderTextBitmap(const char *str, void *fontStyle)
This method is safe for calling from within ::render() methods.
The base class of 3D objects that can be directly rendered through OpenGL.
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().
void setFromValues(const double x0, const double y0, const double z0, const double yaw=0, const double pitch=0, const double roll=0)
Set the pose from a 3D position (meters) and yaw/pitch/roll angles (radians) - This method recomputes...
static void releaseTextureName(unsigned int i)
virtual bool traceRay(const mrpt::poses::CPose3D &o, double &dist) const
Simulation of ray-trace, given a pose.
std::shared_ptr< CRenderizable > Ptr
#define THROW_EXCEPTION_FMT(_FORMAT_STRING,...)
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Virtual base class for "archives": classes abstracting I/O streams.
void setYawPitchRoll(const double yaw_, const double pitch_, const double roll_)
Set the 3 angles of the 3D pose (in radians) - This method recomputes the internal rotation coordinat...
mrpt::math::TPose3D getPose() const
Returns the 3D pose of the object as TPose3D.
GLdouble GLdouble GLdouble r
#define MAX_GL_TEXTURE_IDS
void WriteBuffer(const void *Buffer, size_t Count)
Writes a block of bytes to the stream from Buffer.
mrpt::poses::CPose3D m_pose
6D pose wrt the parent coordinate reference.
mrpt::img::TColor m_color
Color components in the range [0,255].
void checkOpenGLError()
Checks glGetError and throws an exception if an error situation is found.
static void checkOpenGLError()
Checks glGetError and throws an exception if an error situation is found.
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle.
double x() const
Common members of all points & poses classes.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
mrpt::math::TPose3D asTPose() const
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().
A RGB color - floats in the range [0,1].
double roll() const
Get the ROLL angle (in radians)
Lightweight 3D pose (three spatial coordinates, plus three angular coordinates).
#define IMPLEMENTS_VIRTUAL_SERIALIZABLE( class_name, base_class_name, NameSpace)
This must be inserted as implementation of some required members for virtual CSerializable classes:
#define MAX_GL_TEXTURE_IDS_MASK
float m_scale_x
Scale components to apply to the object (default=1)
mrpt::serialization::CArchive & operator<<(mrpt::serialization::CArchive &out, const mrpt::opengl::CLight &o)
static TOpenGLNameBooker & instance()
bool m_visible
Is the object visible? (default=true)
unsigned int next_free_texture
double yaw() const
Get the YAW angle (in radians)
std::vector< bool > freeTextureNames
GLsizei const GLchar ** string
A class used to store a 2D point.
A class used to store a 3D point.
void writeToStreamRender(mrpt::serialization::CArchive &out) const
virtual CRenderizable & setColor_u8(const mrpt::img::TColor &c)
The namespace for 3D scene representation and rendering.
unsigned __int32 uint32_t
double DEG2RAD(const double x)
Degrees to radians.
Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST | |