Skip to content

Commit

Permalink
fixup ros-visualization#1365: use default material for STL meshes
Browse files Browse the repository at this point in the history
  • Loading branch information
rhaschke committed Sep 20, 2019
1 parent d6d4b6d commit 06539cb
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/rviz/mesh_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <resource_retriever/retriever.h>

#include <boost/filesystem.hpp>
#include <boost/algorithm/string.hpp>

#include <OgreMeshManager.h>
#include <OgreTextureManager.h>
Expand Down Expand Up @@ -435,6 +436,18 @@ void loadMaterials(const std::string& resource_path,
const aiScene* scene,
std::vector<Ogre::MaterialPtr>& material_table_out )
{
#if BOOST_FILESYSTEM_VERSION == 3
std::string ext = fs::path(resource_path).extension().string();
#else
std::string ext = fs::path(resource_path).extension();
#endif
boost::algorithm::to_lower(ext);
if (ext == ".stl" || ext == ".stlb") // STL meshes don't support proper materials: use Ogre's default material
{
material_table_out.push_back(Ogre::MaterialManager::getSingleton().getByName("BaseWhiteNoLighting"));
return;
}

for (uint32_t i = 0; i < scene->mNumMaterials; i++)
{
std::stringstream ss;
Expand Down Expand Up @@ -662,7 +675,8 @@ Ogre::MeshPtr loadMeshFromResource(const std::string& resource_path)
#else
std::string ext = model_path.extension();
#endif
if (ext == ".mesh" || ext == ".MESH")
boost::algorithm::to_lower(ext);
if (ext == ".mesh")
{
resource_retriever::Retriever retriever;
resource_retriever::MemoryResource res;
Expand Down

0 comments on commit 06539cb

Please sign in to comment.