| 61 | } |
| 62 | |
| 63 | void EmbedTexturesProcess::Execute(aiScene* pScene) { |
| 64 | if (pScene == nullptr || pScene->mRootNode == nullptr || mIOHandler == nullptr){ |
| 65 | return; |
| 66 | } |
| 67 | |
| 68 | aiString path; |
| 69 | uint32_t embeddedTexturesCount = 0u; |
| 70 | for (auto matId = 0u; matId < pScene->mNumMaterials; ++matId) { |
| 71 | auto material = pScene->mMaterials[matId]; |
| 72 | |
| 73 | for (auto ttId = 1u; ttId < AI_TEXTURE_TYPE_MAX; ++ttId) { |
| 74 | auto tt = static_cast<aiTextureType>(ttId); |
| 75 | auto texturesCount = material->GetTextureCount(tt); |
| 76 | |
| 77 | for (auto texId = 0u; texId < texturesCount; ++texId) { |
| 78 | material->GetTexture(tt, texId, &path); |
| 79 | if (path.data[0] == '*') continue; // Already embedded |
| 80 | |
| 81 | // Indeed embed |
| 82 | if (addTexture(pScene, path.data)) { |
| 83 | auto embeddedTextureId = pScene->mNumTextures - 1u; |
| 84 | path.length = ::ai_snprintf(path.data, 1024, "*%u", embeddedTextureId); |
| 85 | material->AddProperty(&path, AI_MATKEY_TEXTURE(tt, texId)); |
| 86 | embeddedTexturesCount++; |
| 87 | } |
| 88 | } |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | ASSIMP_LOG_INFO("EmbedTexturesProcess finished. Embedded ", embeddedTexturesCount, " textures." ); |
| 93 | } |
| 94 | |
| 95 | std::string EmbedTexturesProcess::tryToFindValidPath(const std::string &imagePath) const |
| 96 | { |
nothing calls this directly
no test coverage detected