fixed names of protected members according to naming conventions

This commit is contained in:
utkarshgautamnyu 2017-10-25 17:10:12 -07:00
parent 8d3f11a990
commit 854c190f32
5 changed files with 77 additions and 77 deletions

View file

@ -39,7 +39,7 @@ FBXBaker::FBXBaker(const QUrl& fbxURL, TextureBakerThreadGetter textureThreadGet
{ {
} }
FBXBaker::~FBXBaker() { FBXBaker::~FBXBaker() {
if (_tempDir.exists()) { if (_tempDir.exists()) {
if (!_tempDir.remove(_originalFBXFilePath)) { if (!_tempDir.remove(_originalFBXFilePath)) {
@ -62,7 +62,7 @@ void FBXBaker::abort() {
} }
void FBXBaker::bake() { void FBXBaker::bake() {
qDebug() << "FBXBaker" << _modelURL << "bake starting"; qDebug() << "FBXBaker" << modelURL << "bake starting";
auto tempDir = PathUtils::generateTemporaryDir(); auto tempDir = PathUtils::generateTemporaryDir();
@ -73,7 +73,7 @@ void FBXBaker::bake() {
_tempDir = tempDir; _tempDir = tempDir;
_originalFBXFilePath = _tempDir.filePath(_modelURL.fileName()); _originalFBXFilePath = _tempDir.filePath(modelURL.fileName());
qDebug() << "Made temporary dir " << _tempDir; qDebug() << "Made temporary dir " << _tempDir;
qDebug() << "Origin file path: " << _originalFBXFilePath; qDebug() << "Origin file path: " << _originalFBXFilePath;
@ -124,19 +124,19 @@ void FBXBaker::bakeSourceCopy() {
void FBXBaker::setupOutputFolder() { void FBXBaker::setupOutputFolder() {
// make sure there isn't already an output directory using the same name // make sure there isn't already an output directory using the same name
if (QDir(_bakedOutputDir).exists()) { if (QDir(bakedOutputDir).exists()) {
qWarning() << "Output path" << _bakedOutputDir << "already exists. Continuing."; qWarning() << "Output path" << bakedOutputDir << "already exists. Continuing.";
} else { } else {
qCDebug(model_baking) << "Creating FBX output folder" << _bakedOutputDir; qCDebug(model_baking) << "Creating FBX output folder" << bakedOutputDir;
// attempt to make the output folder // attempt to make the output folder
if (!QDir().mkpath(_bakedOutputDir)) { if (!QDir().mkpath(bakedOutputDir)) {
handleError("Failed to create FBX output folder " + _bakedOutputDir); handleError("Failed to create FBX output folder " + bakedOutputDir);
return; return;
} }
// attempt to make the output folder // attempt to make the output folder
if (!QDir().mkpath(_originalOutputDir)) { if (!QDir().mkpath(originalOutputDir)) {
handleError("Failed to create FBX output folder " + _bakedOutputDir); handleError("Failed to create FBX output folder " + bakedOutputDir);
return; return;
} }
} }
@ -144,22 +144,22 @@ void FBXBaker::setupOutputFolder() {
void FBXBaker::loadSourceFBX() { void FBXBaker::loadSourceFBX() {
// check if the FBX is local or first needs to be downloaded // check if the FBX is local or first needs to be downloaded
if (_modelURL.isLocalFile()) { if (modelURL.isLocalFile()) {
// load up the local file // load up the local file
QFile localFBX { _modelURL.toLocalFile() }; QFile localFBX { modelURL.toLocalFile() };
qDebug() << "Local file url: " << _modelURL << _modelURL.toString() << _modelURL.toLocalFile() << ", copying to: " << _originalFBXFilePath; qDebug() << "Local file url: " << modelURL << modelURL.toString() << modelURL.toLocalFile() << ", copying to: " << _originalFBXFilePath;
if (!localFBX.exists()) { if (!localFBX.exists()) {
//QMessageBox::warning(this, "Could not find " + _fbxURL.toString(), ""); //QMessageBox::warning(this, "Could not find " + _fbxURL.toString(), "");
handleError("Could not find " + _modelURL.toString()); handleError("Could not find " + modelURL.toString());
return; return;
} }
// make a copy in the output folder // make a copy in the output folder
if (!_originalOutputDir.isEmpty()) { if (!originalOutputDir.isEmpty()) {
qDebug() << "Copying to: " << _originalOutputDir << "/" << _modelURL.fileName(); qDebug() << "Copying to: " << originalOutputDir << "/" << modelURL.fileName();
localFBX.copy(_originalOutputDir + "/" + _modelURL.fileName()); localFBX.copy(originalOutputDir + "/" + modelURL.fileName());
} }
localFBX.copy(_originalFBXFilePath); localFBX.copy(_originalFBXFilePath);
@ -177,9 +177,9 @@ void FBXBaker::loadSourceFBX() {
networkRequest.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::AlwaysNetwork); networkRequest.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::AlwaysNetwork);
networkRequest.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT); networkRequest.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT);
networkRequest.setUrl(_modelURL); networkRequest.setUrl(modelURL);
qCDebug(model_baking) << "Downloading" << _modelURL; qCDebug(model_baking) << "Downloading" << modelURL;
auto networkReply = networkAccessManager.get(networkRequest); auto networkReply = networkAccessManager.get(networkRequest);
connect(networkReply, &QNetworkReply::finished, this, &FBXBaker::handleFBXNetworkReply); connect(networkReply, &QNetworkReply::finished, this, &FBXBaker::handleFBXNetworkReply);
@ -190,7 +190,7 @@ void FBXBaker::handleFBXNetworkReply() {
auto requestReply = qobject_cast<QNetworkReply*>(sender()); auto requestReply = qobject_cast<QNetworkReply*>(sender());
if (requestReply->error() == QNetworkReply::NoError) { if (requestReply->error() == QNetworkReply::NoError) {
qCDebug(model_baking) << "Downloaded" << _modelURL; qCDebug(model_baking) << "Downloaded" << modelURL;
// grab the contents of the reply and make a copy in the output folder // grab the contents of the reply and make a copy in the output folder
QFile copyOfOriginal(_originalFBXFilePath); QFile copyOfOriginal(_originalFBXFilePath);
@ -199,26 +199,26 @@ void FBXBaker::handleFBXNetworkReply() {
if (!copyOfOriginal.open(QIODevice::WriteOnly)) { if (!copyOfOriginal.open(QIODevice::WriteOnly)) {
// add an error to the error list for this FBX stating that a duplicate of the original FBX could not be made // add an error to the error list for this FBX stating that a duplicate of the original FBX could not be made
handleError("Could not create copy of " + _modelURL.toString() + " (Failed to open " + _originalFBXFilePath + ")"); handleError("Could not create copy of " + modelURL.toString() + " (Failed to open " + _originalFBXFilePath + ")");
return; return;
} }
if (copyOfOriginal.write(requestReply->readAll()) == -1) { if (copyOfOriginal.write(requestReply->readAll()) == -1) {
handleError("Could not create copy of " + _modelURL.toString() + " (Failed to write)"); handleError("Could not create copy of " + modelURL.toString() + " (Failed to write)");
return; return;
} }
// close that file now that we are done writing to it // close that file now that we are done writing to it
copyOfOriginal.close(); copyOfOriginal.close();
if (!_originalOutputDir.isEmpty()) { if (!originalOutputDir.isEmpty()) {
copyOfOriginal.copy(_originalOutputDir + "/" + _modelURL.fileName()); copyOfOriginal.copy(originalOutputDir + "/" + modelURL.fileName());
} }
// emit our signal to start the import of the FBX source copy // emit our signal to start the import of the FBX source copy
emit sourceCopyReadyToLoad(); emit sourceCopyReadyToLoad();
} else { } else {
// add an error to our list stating that the FBX could not be downloaded // add an error to our list stating that the FBX could not be downloaded
handleError("Failed to download " + _modelURL.toString()); handleError("Failed to download " + modelURL.toString());
} }
} }
@ -233,10 +233,10 @@ void FBXBaker::importScene() {
FBXReader reader; FBXReader reader;
qCDebug(model_baking) << "Parsing" << _modelURL; qCDebug(model_baking) << "Parsing" << modelURL;
_rootNode = reader._rootNode = reader.parseFBX(&fbxFile); _rootNode = reader._rootNode = reader.parseFBX(&fbxFile);
_geometry = reader.extractFBXGeometry({}, _modelURL.toString()); _geometry = reader.extractFBXGeometry({}, modelURL.toString());
_textureContent = reader._textureContent; textureContentMap = reader._textureContent;
} }
void FBXBaker::rewriteAndBakeSceneModels() { void FBXBaker::rewriteAndBakeSceneModels() {
@ -398,11 +398,11 @@ void FBXBaker::rewriteAndBakeSceneTextures() {
void FBXBaker::exportScene() { void FBXBaker::exportScene() {
// save the relative path to this FBX inside our passed output folder // save the relative path to this FBX inside our passed output folder
auto fileName = _modelURL.fileName(); auto fileName = modelURL.fileName();
auto baseName = fileName.left(fileName.lastIndexOf('.')); auto baseName = fileName.left(fileName.lastIndexOf('.'));
auto bakedFilename = baseName + BAKED_FBX_EXTENSION; auto bakedFilename = baseName + BAKED_FBX_EXTENSION;
_bakedFBXFilePath = _bakedOutputDir + "/" + bakedFilename; _bakedFBXFilePath = bakedOutputDir + "/" + bakedFilename;
auto fbxData = FBXWriter::encodeFBX(_rootNode); auto fbxData = FBXWriter::encodeFBX(_rootNode);
@ -417,5 +417,5 @@ void FBXBaker::exportScene() {
_outputFiles.push_back(_bakedFBXFilePath); _outputFiles.push_back(_bakedFBXFilePath);
qCDebug(model_baking) << "Exported" << _modelURL << "with re-written paths to" << _bakedFBXFilePath; qCDebug(model_baking) << "Exported" << modelURL << "with re-written paths to" << _bakedFBXFilePath;
} }

View file

@ -37,7 +37,7 @@ public:
const QString& bakedOutputDir, const QString& originalOutputDir = ""); const QString& bakedOutputDir, const QString& originalOutputDir = "");
~FBXBaker() override; ~FBXBaker() override;
QUrl getFBXUrl() const { return _modelURL; } QUrl getFBXUrl() const { return modelURL; }
QString getBakedFBXFilePath() const { return _bakedFBXFilePath; } QString getBakedFBXFilePath() const { return _bakedFBXFilePath; }
public slots: public slots:

View file

@ -31,10 +31,10 @@
ModelBaker::ModelBaker(const QUrl& modelURL, TextureBakerThreadGetter textureThreadGetter, ModelBaker::ModelBaker(const QUrl& modelURL, TextureBakerThreadGetter textureThreadGetter,
const QString& bakedOutputDir, const QString& originalOutputDir) : const QString& bakedOutputDir, const QString& originalOutputDir) :
_modelURL(modelURL), modelURL(modelURL),
_textureThreadGetter(textureThreadGetter), textureThreadGetter(textureThreadGetter),
_bakedOutputDir(bakedOutputDir), bakedOutputDir(bakedOutputDir),
_originalOutputDir(originalOutputDir) originalOutputDir(originalOutputDir)
{ {
} }
@ -244,7 +244,7 @@ QByteArray* ModelBaker::compressTexture(QString modelTextureFileName, getTexture
// figure out the URL to this texture, embedded or external // figure out the URL to this texture, embedded or external
if (!modelTextureFileInfo.filePath().isEmpty()) { if (!modelTextureFileInfo.filePath().isEmpty()) {
textureContent = _textureContent.value(modelTextureFileName.toLocal8Bit()); textureContent = textureContentMap.value(modelTextureFileName.toLocal8Bit());
} }
auto urlToTexture = getTextureURL(modelTextureFileInfo, modelTextureFileName, !textureContent.isNull()); auto urlToTexture = getTextureURL(modelTextureFileInfo, modelTextureFileName, !textureContent.isNull());
@ -263,7 +263,7 @@ QByteArray* ModelBaker::compressTexture(QString modelTextureFileName, getTexture
<< "to" << bakedTextureFileName; << "to" << bakedTextureFileName;
QString bakedTextureFilePath{ QString bakedTextureFilePath{
_bakedOutputDir + "/" + bakedTextureFileName bakedOutputDir + "/" + bakedTextureFileName
}; };
textureChild = bakedTextureFileName.toLocal8Bit(); textureChild = bakedTextureFileName.toLocal8Bit();
@ -272,7 +272,7 @@ QByteArray* ModelBaker::compressTexture(QString modelTextureFileName, getTexture
_outputFiles.push_back(bakedTextureFilePath); _outputFiles.push_back(bakedTextureFilePath);
// bake this texture asynchronously // bake this texture asynchronously
bakeTexture(urlToTexture, textureType, _bakedOutputDir, bakedTextureFileName, textureContent); bakeTexture(urlToTexture, textureType, bakedOutputDir, bakedTextureFileName, textureContent);
} }
} }
@ -286,7 +286,7 @@ QUrl ModelBaker::getTextureURL(const QFileInfo& textureFileInfo, QString relativ
auto apparentRelativePath = QFileInfo(relativeFileName.replace("\\", "/")); auto apparentRelativePath = QFileInfo(relativeFileName.replace("\\", "/"));
if (isEmbedded) { if (isEmbedded) {
urlToTexture = _modelURL.toString() + "/" + apparentRelativePath.filePath(); urlToTexture = modelURL.toString() + "/" + apparentRelativePath.filePath();
} else { } else {
if (textureFileInfo.exists() && textureFileInfo.isFile()) { if (textureFileInfo.exists() && textureFileInfo.isFile()) {
// set the texture URL to the local texture that we have confirmed exists // set the texture URL to the local texture that we have confirmed exists
@ -296,14 +296,14 @@ QUrl ModelBaker::getTextureURL(const QFileInfo& textureFileInfo, QString relativ
// this is a relative file path which will require different handling // this is a relative file path which will require different handling
// depending on the location of the original model // depending on the location of the original model
if (_modelURL.isLocalFile() && apparentRelativePath.exists() && apparentRelativePath.isFile()) { if (modelURL.isLocalFile() && apparentRelativePath.exists() && apparentRelativePath.isFile()) {
// the absolute path we ran into for the texture in the model exists on this machine // the absolute path we ran into for the texture in the model exists on this machine
// so use that file // so use that file
urlToTexture = QUrl::fromLocalFile(apparentRelativePath.absoluteFilePath()); urlToTexture = QUrl::fromLocalFile(apparentRelativePath.absoluteFilePath());
} else { } else {
// we didn't find the texture on this machine at the absolute path // we didn't find the texture on this machine at the absolute path
// so assume that it is right beside the model to match the behaviour of interface // so assume that it is right beside the model to match the behaviour of interface
urlToTexture = _modelURL.resolved(apparentRelativePath.fileName()); urlToTexture = modelURL.resolved(apparentRelativePath.fileName());
} }
} }
} }
@ -328,7 +328,7 @@ void ModelBaker::bakeTexture(const QUrl& textureURL, image::TextureUsage::Type t
_bakingTextures.insert(textureURL, bakingTexture); _bakingTextures.insert(textureURL, bakingTexture);
// start baking the texture on one of our available worker threads // start baking the texture on one of our available worker threads
bakingTexture->moveToThread(_textureThreadGetter()); bakingTexture->moveToThread(textureThreadGetter());
QMetaObject::invokeMethod(bakingTexture.data(), "bake"); QMetaObject::invokeMethod(bakingTexture.data(), "bake");
} }
@ -339,7 +339,7 @@ void ModelBaker::handleBakedTexture() {
if (bakedTexture) { if (bakedTexture) {
if (!shouldStop()) { if (!shouldStop()) {
if (!bakedTexture->hasErrors()) { if (!bakedTexture->hasErrors()) {
if (!_originalOutputDir.isEmpty()) { if (!originalOutputDir.isEmpty()) {
// we've been asked to make copies of the originals, so we need to make copies of this if it is a linked texture // we've been asked to make copies of the originals, so we need to make copies of this if it is a linked texture
// use the path to the texture being baked to determine if this was an embedded or a linked texture // use the path to the texture being baked to determine if this was an embedded or a linked texture
@ -347,16 +347,16 @@ void ModelBaker::handleBakedTexture() {
// it is embeddded if the texure being baked was inside a folder with the name of the model // it is embeddded if the texure being baked was inside a folder with the name of the model
// since that is the fake URL we provide when baking external textures // since that is the fake URL we provide when baking external textures
if (!_modelURL.isParentOf(bakedTexture->getTextureURL())) { if (!modelURL.isParentOf(bakedTexture->getTextureURL())) {
// for linked textures we want to save a copy of original texture beside the original model // for linked textures we want to save a copy of original texture beside the original model
qCDebug(model_baking) << "Saving original texture for" << bakedTexture->getTextureURL(); qCDebug(model_baking) << "Saving original texture for" << bakedTexture->getTextureURL();
// check if we have a relative path to use for the texture // check if we have a relative path to use for the texture
auto relativeTexturePath = texturePathRelativeToModel(_modelURL, bakedTexture->getTextureURL()); auto relativeTexturePath = texturePathRelativeToModel(modelURL, bakedTexture->getTextureURL());
QFile originalTextureFile{ QFile originalTextureFile{
_originalOutputDir + "/" + relativeTexturePath + bakedTexture->getTextureURL().fileName() originalOutputDir + "/" + relativeTexturePath + bakedTexture->getTextureURL().fileName()
}; };
if (relativeTexturePath.length() > 0) { if (relativeTexturePath.length() > 0) {
@ -365,10 +365,10 @@ void ModelBaker::handleBakedTexture() {
if (originalTextureFile.open(QIODevice::WriteOnly) && originalTextureFile.write(bakedTexture->getOriginalTexture()) != -1) { if (originalTextureFile.open(QIODevice::WriteOnly) && originalTextureFile.write(bakedTexture->getOriginalTexture()) != -1) {
qCDebug(model_baking) << "Saved original texture file" << originalTextureFile.fileName() qCDebug(model_baking) << "Saved original texture file" << originalTextureFile.fileName()
<< "for" << _modelURL; << "for" << modelURL;
} else { } else {
handleError("Could not save original external texture " + originalTextureFile.fileName() handleError("Could not save original external texture " + originalTextureFile.fileName()
+ " for " + _modelURL.toString()); + " for " + modelURL.toString());
return; return;
} }
} }
@ -435,7 +435,7 @@ void ModelBaker::checkIfTexturesFinished() {
return; return;
} else { } else {
qCDebug(model_baking) << "Finished baking, emitting finished" << _modelURL; qCDebug(model_baking) << "Finished baking, emitting finished" << modelURL;
setIsFinished(true); setIsFinished(true);
} }
@ -487,7 +487,7 @@ void ModelBaker::setWasAborted(bool wasAborted) {
Baker::setWasAborted(wasAborted); Baker::setWasAborted(wasAborted);
if (wasAborted) { if (wasAborted) {
qCDebug(model_baking) << "Aborted baking" << _modelURL; qCDebug(model_baking) << "Aborted baking" << modelURL;
} }
} }
} }

View file

@ -43,11 +43,11 @@ public:
protected: protected:
void checkIfTexturesFinished(); void checkIfTexturesFinished();
QHash<QByteArray, QByteArray> _textureContent; QHash<QByteArray, QByteArray> textureContentMap;
QString _bakedOutputDir; QString bakedOutputDir;
QString _originalOutputDir; QString originalOutputDir;
TextureBakerThreadGetter _textureThreadGetter; TextureBakerThreadGetter textureThreadGetter;
QUrl _modelURL; QUrl modelURL;
public slots: public slots:
virtual void bake() override; virtual void bake() override;

View file

@ -53,7 +53,7 @@ OBJBaker::~OBJBaker() {
} }
void OBJBaker::bake() { void OBJBaker::bake() {
qDebug() << "OBJBaker" << _modelURL << "bake starting"; qDebug() << "OBJBaker" << modelURL << "bake starting";
auto tempDir = PathUtils::generateTemporaryDir(); auto tempDir = PathUtils::generateTemporaryDir();
@ -64,7 +64,7 @@ void OBJBaker::bake() {
_tempDir = tempDir; _tempDir = tempDir;
_originalOBJFilePath = _tempDir.filePath(_modelURL.fileName()); _originalOBJFilePath = _tempDir.filePath(modelURL.fileName());
qDebug() << "Made temporary dir " << _tempDir; qDebug() << "Made temporary dir " << _tempDir;
qDebug() << "Origin file path: " << _originalOBJFilePath; qDebug() << "Origin file path: " << _originalOBJFilePath;
@ -77,21 +77,21 @@ void OBJBaker::bake() {
void OBJBaker::loadOBJ() { void OBJBaker::loadOBJ() {
// check if the OBJ is local or it needs to be downloaded // check if the OBJ is local or it needs to be downloaded
if (_modelURL.isLocalFile()) { if (modelURL.isLocalFile()) {
// loading the local OBJ // loading the local OBJ
QFile localOBJ{ _modelURL.toLocalFile() }; QFile localOBJ{ modelURL.toLocalFile() };
qDebug() << "Local file url: " << _modelURL << _modelURL.toString() << _modelURL.toLocalFile() << ", copying to: " << _originalOBJFilePath; qDebug() << "Local file url: " << modelURL << modelURL.toString() << modelURL.toLocalFile() << ", copying to: " << _originalOBJFilePath;
if (!localOBJ.exists()) { if (!localOBJ.exists()) {
handleError("Could not find " + _modelURL.toString()); handleError("Could not find " + modelURL.toString());
return; return;
} }
// make a copy in the output folder // make a copy in the output folder
if (!_originalOutputDir.isEmpty()) { if (!originalOutputDir.isEmpty()) {
qDebug() << "Copying to: " << _originalOutputDir << "/" << _modelURL.fileName(); qDebug() << "Copying to: " << originalOutputDir << "/" << modelURL.fileName();
localOBJ.copy(_originalOutputDir + "/" + _modelURL.fileName()); localOBJ.copy(originalOutputDir + "/" + modelURL.fileName());
} }
localOBJ.copy(_originalOBJFilePath); localOBJ.copy(_originalOBJFilePath);
@ -108,9 +108,9 @@ void OBJBaker::loadOBJ() {
networkRequest.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true); networkRequest.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true);
networkRequest.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::AlwaysNetwork); networkRequest.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::AlwaysNetwork);
networkRequest.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT); networkRequest.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT);
networkRequest.setUrl(_modelURL); networkRequest.setUrl(modelURL);
qCDebug(model_baking) << "Downloading" << _modelURL; qCDebug(model_baking) << "Downloading" << modelURL;
auto networkReply = networkAccessManager.get(networkRequest); auto networkReply = networkAccessManager.get(networkRequest);
connect(networkReply, &QNetworkReply::finished, this, &OBJBaker::handleOBJNetworkReply); connect(networkReply, &QNetworkReply::finished, this, &OBJBaker::handleOBJNetworkReply);
@ -121,7 +121,7 @@ void OBJBaker::handleOBJNetworkReply() {
auto requestReply = qobject_cast<QNetworkReply*>(sender()); auto requestReply = qobject_cast<QNetworkReply*>(sender());
if (requestReply->error() == QNetworkReply::NoError) { if (requestReply->error() == QNetworkReply::NoError) {
qCDebug(model_baking) << "Downloaded" << _modelURL; qCDebug(model_baking) << "Downloaded" << modelURL;
// grab the contents of the reply and make a copy in the output folder // grab the contents of the reply and make a copy in the output folder
QFile copyOfOriginal(_originalOBJFilePath); QFile copyOfOriginal(_originalOBJFilePath);
@ -130,26 +130,26 @@ void OBJBaker::handleOBJNetworkReply() {
if (!copyOfOriginal.open(QIODevice::WriteOnly)) { if (!copyOfOriginal.open(QIODevice::WriteOnly)) {
// add an error to the error list for this obj stating that a duplicate of the original obj could not be made // add an error to the error list for this obj stating that a duplicate of the original obj could not be made
handleError("Could not create copy of " + _modelURL.toString() + " (Failed to open " + _originalOBJFilePath + ")"); handleError("Could not create copy of " + modelURL.toString() + " (Failed to open " + _originalOBJFilePath + ")");
return; return;
} }
if (copyOfOriginal.write(requestReply->readAll()) == -1) { if (copyOfOriginal.write(requestReply->readAll()) == -1) {
handleError("Could not create copy of " + _modelURL.toString() + " (Failed to write)"); handleError("Could not create copy of " + modelURL.toString() + " (Failed to write)");
return; return;
} }
// close that file now that we are done writing to it // close that file now that we are done writing to it
copyOfOriginal.close(); copyOfOriginal.close();
if (!_originalOutputDir.isEmpty()) { if (!originalOutputDir.isEmpty()) {
copyOfOriginal.copy(_originalOutputDir + "/" + _modelURL.fileName()); copyOfOriginal.copy(originalOutputDir + "/" + modelURL.fileName());
} }
// remote OBJ is loaded emit signal to trigger its baking // remote OBJ is loaded emit signal to trigger its baking
emit OBJLoaded(); emit OBJLoaded();
} else { } else {
// add an error to our list stating that the OBJ could not be downloaded // add an error to our list stating that the OBJ could not be downloaded
handleError("Failed to download " + _modelURL.toString()); handleError("Failed to download " + modelURL.toString());
} }
} }
@ -166,7 +166,7 @@ void OBJBaker::bakeOBJ() {
bool combineParts = true; // set true so that OBJReader reads material info from material library bool combineParts = true; // set true so that OBJReader reads material info from material library
OBJReader reader; OBJReader reader;
FBXGeometry* geometry = reader.readOBJ(objData, QVariantHash(), combineParts, _modelURL); FBXGeometry* geometry = reader.readOBJ(objData, QVariantHash(), combineParts, modelURL);
// Write OBJ Data as FBX tree nodes // Write OBJ Data as FBX tree nodes
FBXNode rootNode; FBXNode rootNode;
@ -176,11 +176,11 @@ void OBJBaker::bakeOBJ() {
auto encodedFBX = FBXWriter::encodeFBX(rootNode); auto encodedFBX = FBXWriter::encodeFBX(rootNode);
// Export as baked FBX // Export as baked FBX
auto fileName = _modelURL.fileName(); auto fileName = modelURL.fileName();
auto baseName = fileName.left(fileName.lastIndexOf('.')); auto baseName = fileName.left(fileName.lastIndexOf('.'));
auto bakedFilename = baseName + ".baked.fbx"; auto bakedFilename = baseName + ".baked.fbx";
_bakedOBJFilePath = _bakedOutputDir + "/" + bakedFilename; _bakedOBJFilePath = bakedOutputDir + "/" + bakedFilename;
QFile bakedFile; QFile bakedFile;
bakedFile.setFileName(_bakedOBJFilePath); bakedFile.setFileName(_bakedOBJFilePath);
@ -193,7 +193,7 @@ void OBJBaker::bakeOBJ() {
// Export successful // Export successful
_outputFiles.push_back(_bakedOBJFilePath); _outputFiles.push_back(_bakedOBJFilePath);
qCDebug(model_baking) << "Exported" << _modelURL << "to" << _bakedOBJFilePath; qCDebug(model_baking) << "Exported" << modelURL << "to" << _bakedOBJFilePath;
// Export done emit finished // Export done emit finished
emit finished(); emit finished();