35 m_color(255, 255, 255, 255),
42 CRenderizable::~CRenderizable() =
default;
44 void CRenderizable::writeToStreamRender(
58 const uint8_t serialization_version = 1;
60 const bool all_scales_equal =
61 (m_scale_x == m_scale_y && m_scale_z == m_scale_x);
62 const bool all_scales_unity = (all_scales_equal && m_scale_x == 1.0f);
64 const uint8_t magic_signature[2] = {
70 serialization_version |
71 (all_scales_unity ? 0xC0 : (all_scales_equal ? 0xA0 : 0x80)))};
73 out << magic_signature[0] << magic_signature[1];
76 const auto nameLen =
static_cast<uint16_t
>(m_name.size());
78 if (nameLen)
out.WriteBuffer(m_name.c_str(), m_name.size());
81 out << m_color.R << m_color.G << m_color.B << m_color.A;
84 out << (float)m_pose.x() << (float)m_pose.y() << (float)m_pose.z()
85 << (float)m_pose.yaw() << (float)m_pose.pitch() << (float)m_pose.roll();
87 if (!all_scales_unity)
92 out << m_scale_x << m_scale_y << m_scale_z;
95 out << m_show_name << m_visible;
96 out << m_representativePoint;
114 uint8_t magic_signature[2];
116 in >> magic_signature[0] >> magic_signature[1];
118 const bool is_new_format =
119 (magic_signature[0] == 0xFF) && ((magic_signature[1] & 0x80) != 0);
124 uint8_t serialization_version = (magic_signature[1] & 0x1F);
125 const bool all_scales_unity = ((magic_signature[1] & 0x40) != 0);
126 const bool all_scales_equal_but_not_unity =
127 ((magic_signature[1] & 0x20) != 0);
129 switch (serialization_version)
137 m_name.resize(nameLen);
138 if (nameLen) in.
ReadBuffer((
void*)(&m_name[0]), m_name.size());
141 in >> m_color.R >> m_color.G >> m_color.B >> m_color.A;
145 in >> x >> y >> z >> yaw >>
pitch >>
roll;
149 m_pose.setYawPitchRoll(yaw,
pitch,
roll);
151 if (all_scales_unity)
152 m_scale_x = m_scale_y = m_scale_z = 1;
155 if (all_scales_equal_but_not_unity)
158 m_scale_y = m_scale_z = m_scale_x;
161 in >> m_scale_x >> m_scale_y >> m_scale_z;
164 in >> m_show_name >> m_visible;
165 if (serialization_version >= 1)
166 in >> m_representativePoint;
173 "Can't parse CRenderizable standard data field: corrupt "
174 "data stream or format in a newer MRPT format? "
175 "(serialization version=%u)",
176 static_cast<unsigned int>(serialization_version));
213 m_pose.setFromValues(o.
x(), o.
y(), o.z(), 0, 0, 0);
219 m_pose.setFromValues(o.
x(), o.
y(), 0, 0, 0, 0);
238 CText& CRenderizable::labelObject()
const
242 m_label_obj = std::make_shared<mrpt::opengl::CText>();
243 m_label_obj->setString(m_name);