26 float xmin,
float ymin,
float zmin,
float xmax,
float ymax,
float zmax,
27 float frecuency,
float lineWidth,
bool marks)
34 m_frequency(frecuency)
41 m_textRot[0][0] = 180.f;
42 m_textRot[0][1] = 0.f;
43 m_textRot[0][2] = 90.f;
45 m_textRot[1][0] = 90.f;
46 m_textRot[1][1] = 0.f;
47 m_textRot[1][2] = 90.f;
49 m_textRot[2][0] = 180.f;
50 m_textRot[2][1] = 0.f;
51 m_textRot[2][2] = 90.f;
71 vbd.emplace_back(m_xmin, 0.0f, 0.0f);
72 vbd.emplace_back(m_xmax, 0.0f, 0.0f);
74 vbd.emplace_back(0.0f, m_ymin, 0.0f);
75 vbd.emplace_back(0.0f, m_ymax, 0.0f);
77 vbd.emplace_back(0.0f, 0.0f, m_zmin);
78 vbd.emplace_back(0.0f, 0.0f, m_zmax);
81 const float ml = m_markLen * m_frequency;
84 const std::array<TPoint3Df, 3> init_trans = {
85 {{m_xmin, .0f, ml}, {.0f, m_ymin, ml}, {.0f, .0f, m_zmin}}};
86 const std::array<std::array<float, 2>, 3> xyz_ranges = {
87 {{m_xmin, m_xmax}, {m_ymin, m_ymax}, {m_zmin, m_zmax}}};
88 const std::array<TPoint3Df, 3> tick0 = {
89 {{0, -ml, -ml}, {-ml, .0f, -ml}, {-ml, .0f, .0f}}};
90 const std::array<TPoint3Df, 3> tick1 = {
91 {{0, ml, -ml}, {ml, .0f, -ml}, {ml, .0f, .0f}}};
92 const std::array<TPoint3Df, 3> endMark = {
93 {{m_xmax + 1.0f * m_frequency, 0, 0},
94 {0, m_ymax + .5f * m_frequency, 0},
95 {0, 0, m_zmax + 0.5f * m_frequency}}};
96 const std::array<const char*, 3> axis2name = {{
"+X",
"+Y",
"+Z"}};
98 for (
unsigned int axis = 0; axis < 3; axis++)
100 if (!m_marks[axis])
continue;
103 tick_incr[axis] = m_frequency;
105 const auto& tf = init_trans[axis];
108 for (
float i = xyz_ranges[axis][0]; i <= xyz_ranges[axis][1];
109 i = i + m_frequency, cur_tf = cur_tf + tick_incr)
112 if (axis != 0 && std::abs(i) < 1e-4f)
continue;
119 label->setScale(m_textScale);
122 cur_tf.x, cur_tf.y, cur_tf.z,
mrpt::DEG2RAD(m_textRot[0][0]),
126 m_gl_labels.emplace_back(label);
129 vbd.emplace_back(cur_tf + tick0[axis]);
130 vbd.emplace_back(cur_tf + tick1[axis]);
135 label->setScale(m_textScale * 1.2f);
137 endMark[axis].x, endMark[axis].y, endMark[axis].z,
140 label->setString(axis2name[axis]);
141 m_gl_labels.emplace_back(label);
144 cbd.assign(vbd.size(), m_color);
146 for (
auto& lb : m_gl_labels) lb->updateBuffers();
168 writeToStreamRender(
out);
169 out << m_xmin << m_ymin << m_zmin;
170 out << m_xmax << m_ymax << m_zmax;
171 out << m_frequency << m_lineWidth;
173 out << m_marks[0] << m_marks[1] << m_marks[2] << m_textScale;
174 for (
auto i : m_textRot)
175 for (
int j = 0; j < 3; j++)
out << i[j];
188 readFromStreamRender(in);
189 in >> m_xmin >> m_ymin >> m_zmin;
190 in >> m_xmax >> m_ymax >> m_zmax;
191 in >> m_frequency >> m_lineWidth;
194 in >> m_marks[0] >> m_marks[1] >> m_marks[2] >> m_textScale;
195 for (
auto& i : m_textRot)
196 for (
int j = 0; j < 3; j++) in >> i[j];
205 if (version >= 2) in >> m_markLen;
257 float xmin,
float ymin,
float zmin,
float xmax,
float ymax,
float zmax)
268 int axis,
float yaw_deg,
float pitch_deg,
float roll_deg)
270 ASSERT_(axis >= 0 && axis < 3);
271 m_textRot[axis][0] = yaw_deg;
272 m_textRot[axis][1] = pitch_deg;
273 m_textRot[axis][2] = roll_deg;
276 int axis,
float& yaw_deg,
float& pitch_deg,
float& roll_deg)
const 278 ASSERT_(axis >= 0 && axis < 3);
279 yaw_deg = m_textRot[axis][0];
280 pitch_deg = m_textRot[axis][1];
281 roll_deg = m_textRot[axis][2];
float getFrequency() const
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
To be added to all CSerializable-classes implementation files.
void notifyChange() const
Call to enable calling renderUpdateBuffers() before the next render() rendering iteration.
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
void setLineWidth(float w)
Context for calls to render()
std::vector< mrpt::math::TPoint3Df > m_vertex_buffer_data
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
float getTextScale() const
#define ASSERT_(f)
Defines an assertion mechanism.
void enableTickMarks(bool v=true)
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...
constexpr double DEG2RAD(const double x)
Degrees to radians.
static Ptr Create(Args &&... args)
Rendering state related to the projection and model-view matrices.
void getTextLabelOrientation(int axis, float &yaw_deg, float &pitch_deg, float &roll_deg) const
axis: {0,1,2}=>{X,Y,Z}
std::vector< mrpt::img::TColor > m_color_buffer_data
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
void setTextLabelOrientation(int axis, float yaw_deg, float pitch_deg, float roll_deg)
axis: {0,1,2}=>{X,Y,Z}
void setTickMarksLength(float len)
As a ratio of "marks frequency" (default: 0.05)
Virtual base class for "archives": classes abstracting I/O streams.
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...
void onUpdateBuffers_Wireframe() override
Must be implemented in derived classes to update the geometric entities to be drawn in "m_*_buffer" f...
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
mrpt::vision::TStereoCalibResults out
void glSetFont(const std::string &fontname)
sets the font to use for future font rendering commands.
Renderizable generic renderer for objects using the wireframe shader.
Draw a 3D world axis, with coordinate marks at some regular interval.
void setFrequency(float f)
Changes the frequency of the "ticks".
The namespace for 3D scene representation and rendering.
void enqueForRenderRecursive(const mrpt::opengl::TRenderMatrices &state, RenderQueue &rq) const override
TPoint3D_< float > TPoint3Df
void setAxisLimits(float xmin, float ymin, float zmin, float xmax, float ymax, float zmax)
void render(const RenderContext &rc) const override
Implements the rendering of 3D objects in each class derived from CRenderizable.
renders glyphs as filled polygons
void render(const RenderContext &rc) const override
Implements the rendering of 3D objects in each class derived from CRenderizable.
void setTextScale(float f)
Changes the size of text labels (default:0.25)
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
int sprintf(char *buf, size_t bufSize, const char *format,...) noexcept MRPT_printf_format_check(3
An OS-independent version of sprintf (Notice the bufSize param, which may be ignored in some compiler...
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
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...