10 #include <mrpt/core/get_env.h> 16 #include <mrpt/version.h> 25 using namespace mvsim;
31 using namespace std::string_literals;
58 glBox->setWireframe(
true);
72 std::map<std::string, mrpt::opengl::CAssimpModel::Ptr>
gModelsCache;
80 if (visual_node ==
nullptr)
return false;
83 double modelScale = 1.0;
85 bool initialShowBoundingBox =
false;
89 params[
"model_scale"] =
TParamEntry(
"%lf", &modelScale);
90 params[
"model_offset_x"] =
TParamEntry(
"%lf", &modelPose.
x);
91 params[
"model_offset_y"] =
TParamEntry(
"%lf", &modelPose.
y);
92 params[
"model_offset_z"] =
TParamEntry(
"%lf", &modelPose.
z);
96 params[
"show_bounding_box"] =
TParamEntry(
"%bool", &initialShowBoundingBox);
101 if (modelURI.empty())
return false;
106 auto glGroup = mrpt::opengl::CSetOfObjects::Create();
108 auto glModel = [&]() {
115 mrpt::opengl::CAssimpModel::Create();
119 mrpt::opengl::CAssimpModel::LoadFlags::RealTimeMaxQuality |
120 mrpt::opengl::CAssimpModel::LoadFlags::FlipUVs;
122 if (mrpt::get_env<bool>(
"MVSIM_LOAD_MODELS_VERBOSE",
false))
123 loadFlags |= mrpt::opengl::CAssimpModel::LoadFlags::Verbose;
125 m->loadScene(localFileName, loadFlags);
131 #if MRPT_VERSION >= 0x218 132 const auto bb = glModel->getBoundingBox();
136 glModel->getBoundingBox(bbmin, bbmax);
138 glGroup->insert(glModel);
140 glGroup->setScale(modelScale);
141 glGroup->setPose(modelPose);
142 glGroup->setName(
"group");
151 viz_bbmin_ = modelPose.composePoint(bbmin * modelScale);
152 viz_bbmax_ = modelPose.composePoint(bbmax * modelScale);
This file contains rapidxml parser and DOM implementation.
std::shared_ptr< mrpt::opengl::CSetOfObjects > m_glBoundingBox
std::map< std::string, TParamEntry > TParameterDefinitions
std::map< std::string, mrpt::opengl::CAssimpModel::Ptr > gModelsCache
void parse_xmlnode_children_as_param(const rapidxml::xml_node< char > &xml_node, const TParameterDefinitions ¶ms, const std::map< std::string, std::string > &variableNamesValues={}, const char *functionNameContext="")
std::string xmlPathToActualPath(const std::string &modelURI) const
virtual void guiUpdate(mrpt::opengl::COpenGLScene &scene)
std::shared_ptr< mrpt::opengl::CSetOfObjects > m_glCustomVisual
int32_t m_glCustomVisualId
virtual mrpt::poses::CPose3D internalGuiGetVisualPose()
void insert(const CRenderizablePtr &newObject, const std::string &viewportName=std::string("main"))
GLuint const GLchar * name
mrpt::math::TPoint3D viz_bbmin_
static std::atomic_int32_t g_uniqueCustomVisualId
void showBoundingBox(bool show)
#define ASSERT_FILE_EXISTS_(FIL)
bool parseVisual(const rapidxml::xml_node< char > *visual_node)
mrpt::math::TPoint3D viz_bbmax_
static CBoxPtr Create(const mrpt::math::TPoint3D &corner1, const mrpt::math::TPoint3D &corner2, bool is_wireframe=false, float lineWidth=1.0)
virtual void internalGuiUpdate(mrpt::opengl::COpenGLScene &scene, bool childrenOnly=false)=0