28 float xmin,
float ymin,
float zmin,
float xmax,
float ymax,
float zmax,
29 float frecuency,
float lineWidth,
bool marks)
36 m_frequency(frecuency),
37 m_lineWidth(lineWidth)
43 m_textRot[0][0] = 180.f;
44 m_textRot[0][1] = 0.f;
45 m_textRot[0][2] = 90.f;
47 m_textRot[1][0] = 90.f;
48 m_textRot[1][1] = 0.f;
49 m_textRot[1][2] = 90.f;
51 m_textRot[2][0] = 180.f;
52 m_textRot[2][1] = 0.f;
53 m_textRot[2][2] = 90.f;
64 #if MRPT_HAS_OPENGL_GLUT 66 glDisable(GL_LIGHTING);
70 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
75 glLineWidth(m_lineWidth);
78 glColor4ub(m_color.R, m_color.G, m_color.B, m_color.A);
80 glVertex3f(m_xmin, 0.0f, 0.0f);
81 glVertex3f(m_xmax, 0.0f, 0.0f);
83 glVertex3f(0.0f, m_ymin, 0.0f);
84 glVertex3f(0.0f, m_ymax, 0.0f);
86 glVertex3f(0.0f, 0.0f, m_zmin);
87 glVertex3f(0.0f, 0.0f, m_zmax);
99 const float ml = m_markLen * m_frequency;
102 const std::array<mrpt::math::TPoint3Df, 3> init_trans = {
103 {{m_xmin, .0f, ml}, {.0f, m_ymin, ml}, {.0f, .0f, m_zmin}}};
104 const std::array<std::array<float, 2>, 3> xyz_ranges = {
105 {{m_xmin, m_xmax}, {m_ymin, m_ymax}, {m_zmin, m_zmax}}};
106 const std::array<mrpt::math::TPoint3Df, 3> tick0 = {
107 {{0, -ml, -ml}, {-ml, .0f, -ml}, {-ml, .0f, .0f}}};
108 const std::array<mrpt::math::TPoint3Df, 3> tick1 = {
109 {{0, ml, -ml}, {ml, .0f, -ml}, {ml, .0f, .0f}}};
110 const std::array<mrpt::math::TPoint3Df, 3> endMark = {
111 {{m_xmax + 1.0f * m_frequency, 0, 0},
112 {0, m_ymax + .5f * m_frequency, 0},
113 {0, 0, m_zmax + 0.5f * m_frequency}}};
114 const std::array<const char*, 3> axis2name = {{
"+X",
"+Y",
"+Z"}};
116 for (
int axis = 0; axis < 3; axis++)
118 if (!m_marks[axis])
continue;
121 const auto& tf = init_trans[axis];
122 glTranslatef(tf.x, tf.y, tf.z);
123 for (
float i = xyz_ranges[axis][0]; i <= xyz_ranges[axis][1];
127 if (axis == 0 || std::abs(i) > 1e-4)
131 glRotatef(m_textRot[0][0], 0, 0, 1);
132 glRotatef(m_textRot[0][1], 0, 1, 0);
133 glRotatef(m_textRot[0][2], 1, 0, 0);
136 glVertex3f(tick0[axis].x, tick0[axis].y, tick0[axis].z);
137 glVertex3f(tick1[axis].x, tick1[axis].y, tick1[axis].z);
143 axis == 0 ? m_frequency : 0, axis == 1 ? m_frequency : 0,
144 axis == 2 ? m_frequency : 0);
149 glTranslatef(endMark[axis].x, endMark[axis].y, endMark[axis].z);
150 glRotatef(m_textRot[0][0], 0, 0, 1);
151 glRotatef(m_textRot[0][1], 0, 1, 0);
152 glRotatef(m_textRot[0][2], 1, 0, 0);
158 glEnable(GL_LIGHTING);
167 writeToStreamRender(
out);
168 out << m_xmin << m_ymin << m_zmin;
169 out << m_xmax << m_ymax << m_zmax;
170 out << m_frequency << m_lineWidth;
172 out << m_marks[0] << m_marks[1] << m_marks[2] << m_textScale;
173 for (
auto i : m_textRot)
174 for (
int j = 0; j < 3; j++)
out << i[j];
187 readFromStreamRender(in);
188 in >> m_xmin >> m_ymin >> m_zmin;
189 in >> m_xmax >> m_ymax >> m_zmax;
190 in >> m_frequency >> m_lineWidth;
193 in >> m_marks[0] >> m_marks[1] >> m_marks[2] >> m_textScale;
194 for (
auto& i : m_textRot)
195 for (
int j = 0; j < 3; j++) in >> i[j];
204 if (version >= 2) in >> m_markLen;
262 float xmin,
float ymin,
float zmin,
float xmax,
float ymax,
float zmax)
273 int axis,
float yaw_deg,
float pitch_deg,
float roll_deg)
275 ASSERT_(axis >= 0 && axis < 3);
276 m_textRot[axis][0] = yaw_deg;
277 m_textRot[axis][1] = pitch_deg;
278 m_textRot[axis][2] = roll_deg;
281 int axis,
float& yaw_deg,
float& pitch_deg,
float& roll_deg)
const 283 ASSERT_(axis >= 0 && axis < 3);
284 yaw_deg = m_textRot[axis][0];
285 pitch_deg = m_textRot[axis][1];
286 roll_deg = m_textRot[axis][2];
float getFrequency() const
void notifyChange() const
Must be called to notify that the object has changed (so, the display list must be updated) ...
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
To be added to all CSerializable-classes implementation files.
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
mrpt::img::TPixelCoordf glDrawText(const std::string &text, const double textScale, enum TOpenGLFontStyle style=NICE, double spacing=1.5, double kerning=0.1)
renders a string in GL using the current settings.
A renderizable object suitable for rendering with OpenGL's display lists.
#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 setLineWidth(float w)
void render_dl() const override
Render.
void getTextLabelOrientation(int axis, float &yaw_deg, float &pitch_deg, float &roll_deg) const
axis: {0,1,2}=>{X,Y,Z}
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}
float getLineWidth() const
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...
mrpt::vision::TStereoCalibResults out
void checkOpenGLError()
Checks glGetError and throws an exception if an error situation is found.
Draw a 3D world axis, with coordinate marks at some regular interval.
renders glyphs filled with antialiased outlines
void setFrequency(float f)
Changes the frequency of the "ticks".
The namespace for 3D scene representation and rendering.
void setAxisLimits(float xmin, float ymin, float zmin, float xmax, float ymax, float zmax)
renders glyphs as filled polygons
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.