Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed OBJ textures #239

Merged
merged 5 commits into from
Feb 11, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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