[SOLVED] 1.10 to 1.11 textures not found but image file exists Topic is solved

Problems building or running the engine, queries about how to use features etc.
Post Reply
glennr
Greenskin
Posts: 107
Joined: Thu Jun 05, 2008 3:26 am
Location: Thames, New Zealand
x 3

[SOLVED] 1.10 to 1.11 textures not found but image file exists

Post by glennr » Wed Feb 13, 2019 4:33 am

Ogre Version: :1.11:
Operating System: :Windows 10:
Render System: :D3D9, OpenGL:

In our app we colourise our models by creating textures as PNG files and load them using the code below. This was working in 1.10 but in 1.11 we get FileNotFoundException from the mat->applyTextureAliases(texNameList) call.

Code: Select all

	// Use the original material as a template, clone it and update the texture image
	// http://www.ogre3d.org/forums/viewtopic.php?f=21&t=64635

        Ogre::MaterialManager &mm = Ogre::MaterialManager::getSingleton();

        // Get an existing material
        Ogre::MaterialPtr mat = mm.getByName(materialName);
        if(!mat)
        {
            Ogre::MaterialPtr templateMat = mm.getByName(templateMaterialName);
            assert(templateMat);
            mat = templateMat->clone(materialName);
            m_materialNames.push_back(materialName);

            bool ok = mat->applyTextureAliases(texNameList); // FileNotFoundException here in 1.11
            assert(ok);

            Ogre::TextureManager &tm = Ogre::TextureManager::getSingleton();

            Ogre::AliasTextureNamePairList::iterator iend = texNameList.end();
            for(Ogre::AliasTextureNamePairList::iterator i = texNameList.begin(); i != iend; ++i)
            {
                tm.unload(i->second);
            }
            mat->load();
        }

	return mat;
The directory where the PNG files are created has been added to the resource manager like this:

Code: Select all

ResourceGroupManager::getSingleton().addResourceLocation(mediaPath, "FileSystem", "General");
I suspect this is related to the new behaviour of the resource manager, however setting OGRE_RESOURCEMANGER_STRICT to 0 (LEGACY) from 2 (STRICT) doesn't help.

What do I need to do to make this work again?
Last edited by glennr on Thu Feb 14, 2019 9:33 pm, edited 1 time in total.
0 x

paroj
OGRE Team Member
OGRE Team Member
Posts: 739
Joined: Sun Mar 30, 2014 2:51 pm
x 112
Contact:

Re: 1.10 to 1.11 textures not found but image file exists

Post by paroj » Wed Feb 13, 2019 11:48 am

yes, with 1.11 Ogre only uses the index it creates at addResourceLocation - it does not longer fall back to searching the filesystem again.
Therefore if the texture was not there in the first place it will not be found.

You can re-create the index by removeResourceLocation/ addResourceLocation after you created the file. See the manual for details:
https://ogrecave.github.io/ogre/api/lat ... ement.html
0 x

glennr
Greenskin
Posts: 107
Joined: Thu Jun 05, 2008 3:26 am
Location: Thames, New Zealand
x 3

Re: 1.10 to 1.11 textures not found but image file exists

Post by glennr » Thu Feb 14, 2019 7:45 am

Thanks, that did the trick. It was as easy as doing this prior to a scene load:

Code: Select all

		ResourceGroupManager::getSingleton().removeResourceLocation(mediaPath, "General");
		ResourceGroupManager::getSingleton().addResourceLocation(mediaPath, "FileSystem", "General");
I still have a possibly related issue, but will start a new topic for that.
0 x

Post Reply