add helper to deduce texture relative URL after download

This commit is contained in:
Stephen Birarda 2017-04-05 18:21:53 -07:00
parent e75f17a7f9
commit 1a17da6ecc
2 changed files with 15 additions and 0 deletions

View file

@ -186,6 +186,19 @@ bool FBXBaker::importScene() {
static const QString BAKED_TEXTURE_DIRECTORY = "textures/";
static const QString BAKED_TEXTURE_EXT = ".ktx";
QString texturePathRelativeToFBX(QUrl fbxURL, QUrl textureURL) {
auto fbxPath = fbxURL.toString(QUrl::RemoveFilename | QUrl::RemoveQuery | QUrl::RemoveFragment);
auto texturePath = textureURL.toString(QUrl::RemoveFilename | QUrl::RemoveQuery | QUrl::RemoveFragment);
if (texturePath.startsWith(fbxPath)) {
// texture path is a child of the FBX path, return the texture path without the fbx path
return texturePath.mid(fbxPath.length());
} else {
// the texture path was not a child of the FBX path, return the empty string
return "";
}
}
bool FBXBaker::rewriteAndBakeSceneTextures() {
// get a count of the textures used in the scene
int numTextures = _scene->GetTextureCount();

View file

@ -66,6 +66,8 @@ void TextureBaker::handleTextureNetworkReply() {
if (requestReply->error() == QNetworkReply::NoError) {
qCDebug(model_baking) << "Downloaded texture at" << _textureURL;
// store the original texture so it can be passed along for the bake
_originalTexture = requestReply->readAll();
} else {
qCDebug(model_baking) << "Error downloading texture" << requestReply->errorString();