Skip to content

Commit 2d823b6

Browse files
committed
WIP: new mrpt-viz library
1 parent 2270811 commit 2d823b6

File tree

111 files changed

+18018
-236
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+18018
-236
lines changed

libs/opengl/include/mrpt/opengl/CPointCloud.h

-10
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@ class CPointCloud :
5454
* to have an easy to use name. */
5555
std::vector<mrpt::math::TPoint3Df>& m_points = CRenderizableShaderPoints::m_vertex_buffer_data;
5656

57-
/** Default: false */
58-
bool m_pointSmooth = false;
59-
6057
mutable size_t m_last_rendered_count{0}, m_last_rendered_count_ongoing{0};
6158

6259
/** Do needed internal work if all points are new (octree rebuilt,...) */
@@ -285,13 +282,6 @@ class CPointCloud :
285282
CRenderizable::notifyChange();
286283
}
287284

288-
void enablePointSmooth(bool enable = true)
289-
{
290-
m_pointSmooth = enable;
291-
CRenderizable::notifyChange();
292-
}
293-
void disablePointSmooth() { m_pointSmooth = false; }
294-
bool isPointSmoothEnabled() const { return m_pointSmooth; }
295285
/** Sets the colors used as extremes when colorFromDepth is enabled. */
296286
void setGradientColors(const mrpt::img::TColorf& colorMin, const mrpt::img::TColorf& colorMax);
297287

libs/opengl/include/mrpt/opengl/CRenderizableShaderTriangles.h

-17
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,6 @@ class CRenderizableShaderTriangles : public virtual CRenderizable
5050
m_vao.destroy();
5151
}
5252

53-
bool isLightEnabled() const { return m_enableLight; }
54-
void enableLight(bool enable = true) { m_enableLight = enable; }
55-
56-
/** Control whether to render the FRONT, BACK, or BOTH (default) set of
57-
* faces. Refer to docs for glCullFace().
58-
* Example: If set to `cullFaces(TCullFace::BACK);`, back faces will not be
59-
* drawn ("culled")
60-
*/
61-
void cullFaces(const TCullFace& cf) { m_cullface = cf; }
62-
TCullFace cullFaces() const { return m_cullface; }
63-
6453
/** @name Raw access to triangle shader buffer data
6554
* @{ */
6655
const auto& shaderTrianglesBuffer() const { return m_triangles; }
@@ -75,15 +64,9 @@ class CRenderizableShaderTriangles : public virtual CRenderizable
7564
/** Returns the bounding box of m_triangles, or (0,0,0)-(0,0,0) if empty. */
7665
const mrpt::math::TBoundingBoxf trianglesBoundingBox() const;
7766

78-
void params_serialize(mrpt::serialization::CArchive& out) const;
79-
void params_deserialize(mrpt::serialization::CArchive& in);
80-
8167
private:
8268
mutable Buffer m_trianglesBuffer;
8369
mutable VertexArrayObject m_vao;
84-
85-
bool m_enableLight = true;
86-
TCullFace m_cullface = TCullFace::NONE;
8770
};
8871

8972
} // namespace mrpt::opengl

libs/opengl/include/mrpt/opengl/CRenderizableShaderWireFrame.h

-16
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,6 @@ class CRenderizableShaderWireFrame : public virtual CRenderizable
3939
* to be drawn in "m_*_buffer" fields. */
4040
virtual void onUpdateBuffers_Wireframe() = 0;
4141

42-
void setLineWidth(float w)
43-
{
44-
m_lineWidth = w;
45-
CRenderizable::notifyChange();
46-
}
47-
float getLineWidth() const { return m_lineWidth; }
48-
void enableAntiAliasing(bool enable = true)
49-
{
50-
m_antiAliasing = enable;
51-
CRenderizable::notifyChange();
52-
}
53-
bool isAntiAliasingEnabled() const { return m_antiAliasing; }
54-
5542
// See base docs
5643
void freeOpenGLResources() override
5744
{
@@ -73,9 +60,6 @@ class CRenderizableShaderWireFrame : public virtual CRenderizable
7360
mutable std::vector<mrpt::img::TColor> m_color_buffer_data;
7461
mutable mrpt::containers::NonCopiableData<std::shared_mutex> m_wireframeMtx;
7562

76-
float m_lineWidth = 1.0f;
77-
bool m_antiAliasing = false;
78-
7963
/** Returns the bounding box of m_vertex_buffer_data, or (0,0,0)-(0,0,0) if
8064
* empty. */
8165
const mrpt::math::TBoundingBox wireframeVerticesBoundingBox() const;

libs/opengl/src/CPointCloud.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@ void CPointCloud::serializeTo(mrpt::serialization::CSchemeArchiveBase& out) cons
202202
out["colorFromDepth_max"]["R"] = m_colorFromDepth_max.R;
203203
out["colorFromDepth_max"]["G"] = m_colorFromDepth_max.G;
204204
out["colorFromDepth_max"]["B"] = m_colorFromDepth_max.B;
205-
out["pointSmooth"] = m_pointSmooth;
206205
}
207206
void CPointCloud::serializeFrom(mrpt::serialization::CSchemeArchiveBase& in)
208207
{
@@ -232,7 +231,6 @@ void CPointCloud::serializeFrom(mrpt::serialization::CSchemeArchiveBase& in)
232231
m_colorFromDepth_max.R = static_cast<float>(in["colorFromDepth_max"]["R"]);
233232
m_colorFromDepth_max.G = static_cast<float>(in["colorFromDepth_max"]["G"]);
234233
m_colorFromDepth_max.B = static_cast<float>(in["colorFromDepth_max"]["B"]);
235-
m_pointSmooth = static_cast<bool>(in["pointSmooth"]);
236234
}
237235
break;
238236
default:

libs/opengl/src/CRenderizableShaderPoints.cpp

-15
Original file line numberDiff line numberDiff line change
@@ -132,18 +132,3 @@ void CRenderizableShaderPoints::params_deserialize(mrpt::serialization::CArchive
132132
MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(version);
133133
};
134134
}
135-
136-
const mrpt::math::TBoundingBoxf CRenderizableShaderPoints::verticesBoundingBox() const
137-
{
138-
std::shared_lock<std::shared_mutex> wfReadLock(CRenderizableShaderPoints::m_pointsMtx.data);
139-
140-
mrpt::math::TBoundingBoxf bb;
141-
142-
if (m_vertex_buffer_data.empty()) return bb;
143-
144-
bb = mrpt::math::TBoundingBoxf::PlusMinusInfinity();
145-
146-
for (const auto& p : m_vertex_buffer_data) bb.updateWithPoint(p);
147-
148-
return bb;
149-
}

libs/opengl/src/CRenderizableShaderTexturedTriangles.cpp

-148
Original file line numberDiff line numberDiff line change
@@ -185,74 +185,6 @@ void CRenderizableShaderTexturedTriangles::render(const RenderContext& rc) const
185185
#endif
186186
}
187187

188-
void CRenderizableShaderTexturedTriangles::assignImage(const CImage& img, const CImage& imgAlpha)
189-
{
190-
MRPT_START
191-
192-
CRenderizable::notifyChange();
193-
194-
m_glTexture.unloadTexture();
195-
196-
// Make a copy:
197-
m_textureImage = img;
198-
m_textureImageAlpha = imgAlpha;
199-
m_textureImageAssigned = true;
200-
201-
m_enableTransparency = true;
202-
203-
MRPT_END
204-
}
205-
206-
void CRenderizableShaderTexturedTriangles::assignImage(const CImage& img)
207-
{
208-
MRPT_START
209-
210-
CRenderizable::notifyChange();
211-
212-
m_glTexture.unloadTexture();
213-
214-
// Make a shallow copy:
215-
m_textureImage = img;
216-
m_textureImageAssigned = true;
217-
218-
m_enableTransparency = false;
219-
220-
MRPT_END
221-
}
222-
223-
void CRenderizableShaderTexturedTriangles::assignImage(CImage&& img, CImage&& imgAlpha)
224-
{
225-
MRPT_START
226-
227-
CRenderizable::notifyChange();
228-
229-
m_glTexture.unloadTexture();
230-
231-
m_textureImage = std::move(img);
232-
m_textureImageAlpha = std::move(imgAlpha);
233-
m_textureImageAssigned = true;
234-
235-
m_enableTransparency = true;
236-
237-
MRPT_END
238-
}
239-
240-
void CRenderizableShaderTexturedTriangles::assignImage(CImage&& img)
241-
{
242-
MRPT_START
243-
244-
CRenderizable::notifyChange();
245-
246-
m_glTexture.unloadTexture();
247-
248-
m_textureImage = std::move(img);
249-
m_textureImageAssigned = true;
250-
251-
m_enableTransparency = false;
252-
253-
MRPT_END
254-
}
255-
256188
void CRenderizableShaderTexturedTriangles::initializeTextures() const
257189
{
258190
#if MRPT_HAS_OPENGL_GLUT || MRPT_HAS_EGL
@@ -298,83 +230,3 @@ CRenderizableShaderTexturedTriangles::~CRenderizableShaderTexturedTriangles()
298230
<< mrpt::exception_to_str(e);
299231
}
300232
}
301-
302-
void CRenderizableShaderTexturedTriangles::writeToStreamTexturedObject(
303-
mrpt::serialization::CArchive& out) const
304-
{
305-
uint8_t ver = 3;
306-
307-
out << ver;
308-
out << m_enableTransparency << m_textureInterpolate << m_textureUseMipMaps;
309-
out << m_textureImage;
310-
if (m_enableTransparency) out << m_textureImageAlpha;
311-
out << m_textureImageAssigned;
312-
out << m_enableLight << static_cast<uint8_t>(m_cullface); // v2
313-
}
314-
315-
void CRenderizableShaderTexturedTriangles::readFromStreamTexturedObject(
316-
mrpt::serialization::CArchive& in)
317-
{
318-
uint8_t version;
319-
in >> version;
320-
321-
switch (version)
322-
{
323-
case 0:
324-
case 1:
325-
case 2:
326-
case 3:
327-
{
328-
in >> m_enableTransparency >> m_textureInterpolate;
329-
if (version >= 3)
330-
{
331-
in >> m_textureUseMipMaps;
332-
}
333-
else
334-
{
335-
m_textureUseMipMaps = true;
336-
}
337-
in >> m_textureImage;
338-
if (m_enableTransparency)
339-
{
340-
in >> m_textureImageAlpha;
341-
assignImage(m_textureImage, m_textureImageAlpha);
342-
}
343-
else
344-
{
345-
assignImage(m_textureImage);
346-
}
347-
if (version >= 1)
348-
in >> m_textureImageAssigned;
349-
else
350-
m_textureImageAssigned = true;
351-
352-
if (version >= 2)
353-
{
354-
in >> m_enableLight;
355-
m_cullface = static_cast<TCullFace>(in.ReadAs<uint8_t>());
356-
}
357-
}
358-
break;
359-
default:
360-
MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(version);
361-
};
362-
363-
CRenderizable::notifyChange();
364-
}
365-
366-
const mrpt::math::TBoundingBoxf CRenderizableShaderTexturedTriangles::trianglesBoundingBox() const
367-
{
368-
mrpt::math::TBoundingBoxf bb;
369-
370-
std::shared_lock<std::shared_mutex> readLock(m_trianglesMtx.data);
371-
372-
if (m_triangles.empty()) return bb;
373-
374-
bb = mrpt::math::TBoundingBoxf::PlusMinusInfinity();
375-
376-
for (const auto& t : m_triangles)
377-
for (int i = 0; i < 3; i++) bb.updateWithPoint(t.vertices[i].xyzrgba.pt);
378-
379-
return bb;
380-
}

libs/opengl/src/CRenderizableShaderTriangles.cpp

-20
Original file line numberDiff line numberDiff line change
@@ -185,23 +185,3 @@ const math::TBoundingBoxf CRenderizableShaderTriangles::trianglesBoundingBox() c
185185

186186
return bb;
187187
}
188-
189-
void CRenderizableShaderTriangles::params_serialize(mrpt::serialization::CArchive& out) const
190-
{
191-
out.WriteAs<uint8_t>(0); // serialization version
192-
out << m_enableLight << static_cast<uint8_t>(m_cullface);
193-
}
194-
void CRenderizableShaderTriangles::params_deserialize(mrpt::serialization::CArchive& in)
195-
{
196-
const auto version = in.ReadAs<uint8_t>();
197-
198-
switch (version)
199-
{
200-
case 0:
201-
in >> m_enableLight;
202-
m_cullface = static_cast<TCullFace>(in.ReadAs<uint8_t>());
203-
break;
204-
default:
205-
MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(version);
206-
};
207-
}

libs/viz/CMakeLists.txt

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Lists of directories with source files:
2+
# See "DeclareMRPTLib.cmake" for explanations
3+
# -------------------------------------------------
4+
5+
#---------------------------------------------
6+
# Macro declared in "DeclareMRPTLib.cmake":
7+
#---------------------------------------------
8+
define_mrpt_lib(
9+
# Lib name
10+
viz
11+
# Dependencies:
12+
mrpt-poses
13+
mrpt-img
14+
)
15+
16+
if(NOT BUILD_mrpt-viz)
17+
return()
18+
endif()
19+

0 commit comments

Comments
 (0)