-
Notifications
You must be signed in to change notification settings - Fork 634
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
106 changed files
with
20,635 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Lists of directories with source files: | ||
# See "DeclareMRPTLib.cmake" for explanations | ||
# ------------------------------------------------- | ||
|
||
#--------------------------------------------- | ||
# Macro declared in "DeclareMRPTLib.cmake": | ||
#--------------------------------------------- | ||
define_mrpt_lib( | ||
# Lib name | ||
viz | ||
# Dependencies: | ||
mrpt-poses | ||
mrpt-img | ||
) | ||
|
||
if(NOT BUILD_mrpt-viz) | ||
return() | ||
endif() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
/* +------------------------------------------------------------------------+ | ||
| Mobile Robot Programming Toolkit (MRPT) | | ||
| https://www.mrpt.org/ | | ||
| | | ||
| Copyright (c) 2005-2024, Individual contributors, see AUTHORS file | | ||
| See: https://www.mrpt.org/Authors - All rights reserved. | | ||
| Released under BSD License. See: https://www.mrpt.org/License | | ||
+------------------------------------------------------------------------+ */ | ||
#pragma once | ||
|
||
#include <mrpt/viz/CVisualObject.h> | ||
|
||
namespace mrpt::viz | ||
{ | ||
/** A 3D arrow | ||
* | ||
* ![mrpt::viz::CArrow](preview_CArrow.png) | ||
* | ||
* \sa opengl::Scene | ||
* \ingroup mrpt_viz_grp | ||
*/ | ||
class CArrow : virtual public CVisualObject, public VisualObjectParams_Triangles | ||
{ | ||
DEFINE_SERIALIZABLE(CArrow, mrpt::viz) | ||
DEFINE_SCHEMA_SERIALIZABLE() | ||
|
||
public: | ||
void setArrowEnds(float x0, float y0, float z0, float x1, float y1, float z1) | ||
{ | ||
m_x0 = x0; | ||
m_y0 = y0; | ||
m_z0 = z0; | ||
m_x1 = x1; | ||
m_y1 = y1; | ||
m_z1 = z1; | ||
CVisualObject::notifyChange(); | ||
} | ||
template <typename Vector3Like> | ||
void setArrowEnds(const Vector3Like& start, const Vector3Like& end) | ||
{ | ||
m_x0 = start[0]; | ||
m_y0 = start[1]; | ||
m_z0 = start[2]; | ||
m_x1 = end[0]; | ||
m_y1 = end[1]; | ||
m_z1 = end[2]; | ||
CVisualObject::notifyChange(); | ||
} | ||
void setHeadRatio(float rat) | ||
{ | ||
m_headRatio = rat; | ||
CVisualObject::notifyChange(); | ||
} | ||
void setSmallRadius(float rat) | ||
{ | ||
m_smallRadius = rat; | ||
CVisualObject::notifyChange(); | ||
} | ||
void setLargeRadius(float rat) | ||
{ | ||
m_largeRadius = rat; | ||
CVisualObject::notifyChange(); | ||
} | ||
/** Number of radial divisions */ | ||
void setSlicesCount(uint32_t slices) | ||
{ | ||
m_slices = slices; | ||
CVisualObject::notifyChange(); | ||
} | ||
|
||
/** Number of radial divisions */ | ||
uint32_t getSlicesCount() const { return m_slices; } | ||
|
||
mrpt::math::TBoundingBoxf internalBoundingBoxLocal() const override; | ||
|
||
/** Constructor */ | ||
CArrow( | ||
float x0 = 0, | ||
float y0 = 0, | ||
float z0 = 0, | ||
float x1 = 1, | ||
float y1 = 1, | ||
float z1 = 1, | ||
float headRatio = 0.2f, | ||
float smallRadius = 0.05f, | ||
float largeRadius = 0.2f) : | ||
m_x0(x0), | ||
m_y0(y0), | ||
m_z0(z0), | ||
m_x1(x1), | ||
m_y1(y1), | ||
m_z1(z1), | ||
m_headRatio(headRatio), | ||
m_smallRadius(smallRadius), | ||
m_largeRadius(largeRadius) | ||
{ | ||
} | ||
|
||
CArrow( | ||
const mrpt::math::TPoint3Df& from, | ||
const mrpt::math::TPoint3Df& to, | ||
float headRatio = 0.2f, | ||
float smallRadius = 0.05f, | ||
float largeRadius = 0.2f) : | ||
m_x0(from.x), | ||
m_y0(from.y), | ||
m_z0(from.z), | ||
m_x1(to.x), | ||
m_y1(to.y), | ||
m_z1(to.z), | ||
m_headRatio(headRatio), | ||
m_smallRadius(smallRadius), | ||
m_largeRadius(largeRadius) | ||
{ | ||
} | ||
~CArrow() override = default; | ||
|
||
protected: | ||
mutable float m_x0, m_y0, m_z0; | ||
mutable float m_x1, m_y1, m_z1; | ||
float m_headRatio; | ||
float m_smallRadius, m_largeRadius; | ||
/** Number of radial divisions. */ | ||
uint32_t m_slices = 10; | ||
}; | ||
|
||
} // namespace mrpt::viz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
/* +------------------------------------------------------------------------+ | ||
| Mobile Robot Programming Toolkit (MRPT) | | ||
| https://www.mrpt.org/ | | ||
| | | ||
| Copyright (c) 2005-2024, Individual contributors, see AUTHORS file | | ||
| See: https://www.mrpt.org/Authors - All rights reserved. | | ||
| Released under BSD License. See: https://www.mrpt.org/License | | ||
+------------------------------------------------------------------------+ */ | ||
#pragma once | ||
|
||
#include <mrpt/img/CImage.h> | ||
#include <mrpt/viz/CVisualObject.h> | ||
|
||
#include <map> | ||
#include <optional> | ||
|
||
namespace mrpt::viz | ||
{ | ||
/** This class can load & render 3D models in a number of different formats | ||
* (requires the library assimp). | ||
* - All supported formats: | ||
* http://assimp.sourceforge.net/main_features_formats.html | ||
* - Most common ones: AutoCAD DXF ( .dxf ), Collada ( .dae ), Blender 3D ( | ||
* .blend ), 3ds Max 3DS ( .3ds ), 3ds Max ASE ( .ase ), Quake I ( .mdl ), Quake | ||
* II ( .md2 ), Quake III Mesh ( .md3 ), etc. | ||
* | ||
* Models are loaded via CAssimpModel::loadScene() | ||
* | ||
* ![mrpt::viz::CAssimpModel](preview_CAssimpModel.png) | ||
* | ||
* \sa opengl::Scene | ||
* \ingroup mrpt_viz_grp | ||
*/ | ||
class CAssimpModel : public CVisualObject | ||
{ | ||
DEFINE_SERIALIZABLE(CAssimpModel, mrpt::viz) | ||
|
||
public: | ||
CAssimpModel(); | ||
virtual ~CAssimpModel() override; | ||
|
||
/** Import flags for loadScene | ||
* \note Not defined as ``enum class`` to allow C++-valid or-wise combinations | ||
*/ | ||
struct LoadFlags | ||
{ | ||
enum flags_t : uint32_t | ||
{ | ||
/** See: aiProcessPreset_TargetRealtime_Fast */ | ||
RealTimeFast = 0x0001, | ||
|
||
/** See: aiProcessPreset_TargetRealtime_Quality */ | ||
RealTimeQuality = 0x0002, | ||
|
||
/** See: aiProcessPreset_TargetRealtime_MaxQuality */ | ||
RealTimeMaxQuality = 0x0004, | ||
|
||
/** See: aiProcess_FlipUVs */ | ||
FlipUVs = 0x0010, | ||
|
||
/** MRPT-specific: ignore materials and replace by the base class | ||
CRenderizable uniform color that was defined before calling | ||
loadScene(). \note (New in MRPT 2.5.0) */ | ||
IgnoreMaterialColor = 0x0100, | ||
|
||
/** Displays messages on loaded textures, etc. */ | ||
Verbose = 0x1000 | ||
}; | ||
}; | ||
|
||
using filepath_t = std::string; | ||
|
||
/** Loads a scene from a file in any supported file. | ||
* \exception std::runtime_error On any error during loading or importing | ||
* the file. | ||
*/ | ||
void loadScene( | ||
const std::string& file_name, | ||
const int flags = LoadFlags::RealTimeMaxQuality | LoadFlags::FlipUVs | LoadFlags::Verbose); | ||
|
||
/** Empty the object */ | ||
void clear(); | ||
|
||
/* Simulation of ray-trace. */ | ||
bool traceRay(const mrpt::poses::CPose3D& o, double& dist) const override; | ||
|
||
mrpt::math::TBoundingBoxf internalBoundingBoxLocal() const override; | ||
|
||
/** Enable (or disable if set to .0f) a feature in which textured triangles | ||
* are split into different renderizable smaller objects. | ||
* This is required only for semitransparent objects with overlaping regions. | ||
*/ | ||
void split_triangles_rendering_bbox(const float bbox_size); | ||
|
||
[[nodiscard]] float split_triangles_rendering_bbox() const | ||
{ | ||
return m_split_triangles_rendering_bbox; | ||
} | ||
|
||
private: | ||
filepath_t m_modelPath; | ||
uint32_t m_modelLoadFlags = 0; | ||
float m_split_triangles_rendering_bbox = .0f; | ||
}; | ||
|
||
} // namespace mrpt::viz |
Oops, something went wrong.