Skip to content

Commit

Permalink
Fixed OBJ textures with the same name (#239)
Browse files Browse the repository at this point in the history
Signed-off-by: Jenn Nguyen <jenn@openrobotics.org>
  • Loading branch information
jennuine authored Feb 11, 2021
1 parent 51d0130 commit 64016f6
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions ogre2/src/Ogre2Material.cc
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,9 @@ Ogre::HlmsPbsDatablock *Ogre2Material::Datablock() const
void Ogre2Material::SetTextureMapImpl(const std::string &_texture,
Ogre::PbsTextureTypes _type)
{
// FIXME(anyone) need to keep baseName = _texture for all meshes. Refer to
// https://github.com/ignitionrobotics/ign-rendering/issues/139
// for more details
std::string baseName = _texture;
if (common::isFile(_texture))
{
Expand All @@ -413,6 +416,18 @@ void Ogre2Material::SetTextureMapImpl(const std::string &_texture,
}
}

// temp workaround check if the model is a OBJ file
{
size_t idx = _texture.rfind("meshes");
if (idx != std::string::npos)
{
std::string objFile =
common::joinPaths(_texture.substr(0, idx), "meshes", "model.obj");
if (common::isFile(objFile))
baseName = _texture;
}
}

Ogre::HlmsTextureManager *hlmsTextureManager =
this->ogreHlmsPbs->getHlmsManager()->getTextureManager();
Ogre::HlmsTextureManager::TextureLocation texLocation =
Expand Down

0 comments on commit 64016f6

Please sign in to comment.