Add a test before generating the txture folder

This commit is contained in:
Kim Kulling
2023-12-29 16:30:42 +01:00
committed by Kim Kulling
parent 5d5496f1ad
commit 263bebb5ba
3 changed files with 85 additions and 4 deletions

View File

@@ -97,13 +97,23 @@ void ExportScenePbrt (
){
std::string path = DefaultIOSystem::absolutePath(std::string(pFile));
std::string file = DefaultIOSystem::completeBaseName(std::string(pFile));
path = path + file + ".brt";
// initialize the exporter
PbrtExporter exporter(pScene, pIOSystem, path, file);
}
} // end of namespace Assimp
static void create_embedded_textures_folder(const aiScene *scene, IOSystem *pIOSystem) {
if (scene->mNumTextures > 0) {
if (!pIOSystem->Exists("textures")) {
if (!pIOSystem->CreateDirectory("textures")) {
throw DeadlyExportError("Could not create textures/ directory.");
}
}
}
}
// Constructor
PbrtExporter::PbrtExporter(
const aiScene *pScene, IOSystem *pIOSystem,
@@ -127,10 +137,10 @@ PbrtExporter::PbrtExporter(
0.f, 0.f, 1.f, 0.f, //
0.f, 0.f, 0.f, 1.f //
) * mRootTransform;
// Export embedded textures.
if (mScene->mNumTextures > 0)
if (!mIOSystem->CreateDirectory("textures"))
throw DeadlyExportError("Could not create textures/ directory.");
create_embedded_textures_folder(mScene, mIOSystem);
for (unsigned int i = 0; i < mScene->mNumTextures; ++i) {
aiTexture* tex = mScene->mTextures[i];
std::string fn = CleanTextureFilename(tex->mFilename, false);