Hello,
I’m trying to load in a .egg file, modify the path to a texture file, and save out a new .egg file. When I load, the file, perform the replacement, then call write_egg, I end up seeing the original texture paths. I’ve tried loading the texture collection a second time and confirmed that the EggData has the correct paths, and it appears to. Here’s my replacement method:
void EggHandler::ReplaceTexturePaths(std::map<std::string, std::string>& map, std::string sModelPath, std::string sOutputPath)
{
EggTextureCollection tc;
tc.find_used_textures(m_pData);
EggTextureCollection::TextureReplacement replacementMap;
for (auto it = tc.begin(); it != tc.end(); it++)
{
Filename fn = (*it)->get_fullpath();
auto outPathIt = map.find(fn);
if (outPathIt == map.end())
{
outPathIt = map.find(sModelPath + "/" + fn.c_str());
if (outPathIt == map.end()) continue;
}
PT(EggTexture) tex = new EggTexture(**it);
tex->set_fullpath(outPathIt->second);
replacementMap.insert(std::pair<PT_EggTexture, PT_EggTexture>(*it, tex));
}
tc.replace_textures(m_pData, replacementMap);
m_pData->write_egg(sOutputPath);
}
m_pData is my only member variable, and it’s defined as PT(EggData). I’m nor sure why I’m getting stale data when I call write_egg, but I consistently see the old paths and not the replacement paths. Any help would be appreciated.
Thanks!