Showing the changes to interface/src/ModelPackager.cpp (1 of 1046 files). Show all
Unified · Split
| @@ -85,7 +85,7 @@ bool ModelPackager::loadModel() { · 84 unmodified lines | |||
| 85 | qWarning() << QString("ModelPackager::loadModel(): Could not open FST file %1").arg(_modelFile.filePath()); | 85 | qWarning() << QString("ModelPackager::loadModel(): Could not open FST file %1").arg(_modelFile.filePath()); |
| 86 | return false; | 86 | return false; |
| 87 | } | 87 | } |
| 88 | qCDebug(interfaceapp) << "Reading FST file : " << _modelFile.filePath(); | 88 | qCDebug(interfaceapp) << "Reading FST file"; |
| 89 | _mapping = FSTReader::readMapping(fst.readAll()); | 89 | _mapping = FSTReader::readMapping(fst.readAll()); |
| 90 | fst.close(); | 90 | fst.close(); |
| 91 | 91 | ||
| @@ -101,19 +101,19 @@ bool ModelPackager::loadModel() { · 9 unmodified lines | |||
| 101 | QString("ModelPackager::loadModel()"), | 101 | QString("ModelPackager::loadModel()"), |
| 102 | QString("Could not open FBX file %1").arg(_fbxInfo.filePath()), | 102 | QString("Could not open FBX file %1").arg(_fbxInfo.filePath()), |
| 103 | QMessageBox::Ok); | 103 | QMessageBox::Ok); |
| 104 | qWarning() << QString("ModelPackager::loadModel(): Could not open FBX file %1").arg(_fbxInfo.filePath()); | 104 | qWarning() << "ModelPackager::loadModel(): Could not open FBX file"; |
| 105 | return false; | 105 | return false; |
| 106 | } | 106 | } |
| 107 | try { | 107 | try { |
| 108 | qCDebug(interfaceapp) << "Reading FBX file : " << _fbxInfo.filePath(); | 108 | qCDebug(interfaceapp) << "Reading FBX file : " << _fbxInfo.filePath(); |
| 109 | QByteArray fbxContents = fbx.readAll(); | 109 | QByteArray fbxContents = fbx.readAll(); |
| 110 | 110 | ||
| 111 | _geometry.reset(readFBX(fbxContents, QVariantHash(), _fbxInfo.filePath())); | 111 | _hfmModel.reset(readFBX(fbxContents, QVariantHash(), _fbxInfo.filePath())); |
| 112 | 112 | ||
| 113 | // make sure we have some basic mappings | 113 | // make sure we have some basic mappings |
| 114 | populateBasicMapping(_mapping, _fbxInfo.filePath(), *_geometry); | 114 | populateBasicMapping(_mapping, _fbxInfo.filePath(), *_hfmModel); |
| 115 | } catch (const QString& error) { | 115 | } catch (const QString& error) { |
| 116 | qCDebug(interfaceapp) << "Error reading " << _fbxInfo.filePath() << ": " << error; | 116 | qCDebug(interfaceapp) << "Error reading: " << error; |
| 117 | return false; | 117 | return false; |
| 118 | } | 118 | } |
| 119 | return true; | 119 | return true; |
| @@ -121,7 +121,7 @@ bool ModelPackager::loadModel() { · 1 unmodified line | |||
| 121 | 121 | ||
| 122 | bool ModelPackager::editProperties() { | 122 | bool ModelPackager::editProperties() { |
| 123 | // open the dialog to configure the rest | 123 | // open the dialog to configure the rest |
| 124 | ModelPropertiesDialog properties(_mapping, _modelFile.path(), *_geometry); | 124 | ModelPropertiesDialog properties(_mapping, _modelFile.path(), *_hfmModel); |
| 125 | if (properties.exec() == QDialog::Rejected) { | 125 | if (properties.exec() == QDialog::Rejected) { |
| 126 | return false; | 126 | return false; |
| 127 | } | 127 | } |
| @@ -130,7 +130,7 @@ bool ModelPackager::editProperties() { · 2 unmodified lines | |||
| 130 | // Make sure that a mapping for the root joint has been specified | 130 | // Make sure that a mapping for the root joint has been specified |
| 131 | QVariantHash joints = _mapping.value(JOINT_FIELD).toHash(); | 131 | QVariantHash joints = _mapping.value(JOINT_FIELD).toHash(); |
| 132 | if (!joints.contains("jointRoot")) { | 132 | if (!joints.contains("jointRoot")) { |
| 133 | qWarning() << QString("%1 root joint not configured for skeleton.").arg(_modelFile.fileName()); | 133 | qWarning() << "root joint not configured for skeleton."; |
| 134 | 134 | ||
| 135 | QString message = "Your did not configure a root joint for your skeleton model.\n\nPackaging will be canceled."; | 135 | QString message = "Your did not configure a root joint for your skeleton model.\n\nPackaging will be canceled."; |
| 136 | QMessageBox msgBox; | 136 | QMessageBox msgBox; |
| @@ -232,16 +232,16 @@ bool ModelPackager::zipModel() { · 95 unmodified lines | |||
| 232 | return true; | 232 | return true; |
| 233 | } | 233 | } |
| 234 | 234 | ||
| 235 | void ModelPackager::populateBasicMapping(QVariantHash& mapping, QString filename, const FBXGeometry& geometry) { | 235 | void ModelPackager::populateBasicMapping(QVariantHash& mapping, QString filename, const hfm::Model& hfmModel) { |
| 236 | 236 | ||
| 237 | // mixamo files - in the event that a mixamo file was edited by some other tool, it's likely the applicationName will | 237 | // mixamo files - in the event that a mixamo file was edited by some other tool, it's likely the applicationName will |
| 238 | // be rewritten, so we detect the existence of several different blendshapes which indicate we're likely a mixamo file | 238 | // be rewritten, so we detect the existence of several different blendshapes which indicate we're likely a mixamo file |
| 239 | bool likelyMixamoFile = geometry.applicationName == "mixamo.com" || | 239 | bool likelyMixamoFile = hfmModel.applicationName == "mixamo.com" || |
| 240 | (geometry.blendshapeChannelNames.contains("BrowsDown_Right") && | 240 | (hfmModel.blendshapeChannelNames.contains("BrowsDown_Right") && |
| 241 | geometry.blendshapeChannelNames.contains("MouthOpen") && | 241 | hfmModel.blendshapeChannelNames.contains("MouthOpen") && |
| 242 | geometry.blendshapeChannelNames.contains("Blink_Left") && | 242 | hfmModel.blendshapeChannelNames.contains("Blink_Left") && |
| 243 | geometry.blendshapeChannelNames.contains("Blink_Right") && | 243 | hfmModel.blendshapeChannelNames.contains("Blink_Right") && |
| 244 | geometry.blendshapeChannelNames.contains("Squint_Right")); | 244 | hfmModel.blendshapeChannelNames.contains("Squint_Right")); |
| 245 | 245 | ||
| 246 | if (!mapping.contains(NAME_FIELD)) { | 246 | if (!mapping.contains(NAME_FIELD)) { |
| 247 | mapping.insert(NAME_FIELD, QFileInfo(filename).baseName()); | 247 | mapping.insert(NAME_FIELD, QFileInfo(filename).baseName()); |
| @@ -263,15 +263,15 @@ void ModelPackager::populateBasicMapping(QVariantHash& mapping, QString filename · 15 unmodified lines | |||
| 263 | } | 263 | } |
| 264 | QVariantHash joints = mapping.value(JOINT_FIELD).toHash(); | 264 | QVariantHash joints = mapping.value(JOINT_FIELD).toHash(); |
| 265 | if (!joints.contains("jointEyeLeft")) { | 265 | if (!joints.contains("jointEyeLeft")) { |
| 266 | joints.insert("jointEyeLeft", geometry.jointIndices.contains("jointEyeLeft") ? "jointEyeLeft" : | 266 | joints.insert("jointEyeLeft", hfmModel.jointIndices.contains("jointEyeLeft") ? "jointEyeLeft" : |
| 267 | (geometry.jointIndices.contains("EyeLeft") ? "EyeLeft" : "LeftEye")); | 267 | (hfmModel.jointIndices.contains("EyeLeft") ? "EyeLeft" : "LeftEye")); |
| 268 | } | 268 | } |
| 269 | if (!joints.contains("jointEyeRight")) { | 269 | if (!joints.contains("jointEyeRight")) { |
| 270 | joints.insert("jointEyeRight", geometry.jointIndices.contains("jointEyeRight") ? "jointEyeRight" : | 270 | joints.insert("jointEyeRight", hfmModel.jointIndices.contains("jointEyeRight") ? "jointEyeRight" : |
| 271 | geometry.jointIndices.contains("EyeRight") ? "EyeRight" : "RightEye"); | 271 | hfmModel.jointIndices.contains("EyeRight") ? "EyeRight" : "RightEye"); |
| 272 | } | 272 | } |
| 273 | if (!joints.contains("jointNeck")) { | 273 | if (!joints.contains("jointNeck")) { |
| 274 | joints.insert("jointNeck", geometry.jointIndices.contains("jointNeck") ? "jointNeck" : "Neck"); | 274 | joints.insert("jointNeck", hfmModel.jointIndices.contains("jointNeck") ? "jointNeck" : "Neck"); |
| 275 | } | 275 | } |
| 276 | 276 | ||
| 277 | if (!joints.contains("jointRoot")) { | 277 | if (!joints.contains("jointRoot")) { |
| @@ -289,7 +289,7 @@ void ModelPackager::populateBasicMapping(QVariantHash& mapping, QString filename · 11 unmodified lines | |||
| 289 | 289 | ||
| 290 | if (!joints.contains("jointHead")) { | 290 | if (!joints.contains("jointHead")) { |
| 291 | const char* topName = likelyMixamoFile ? "HeadTop_End" : "HeadEnd"; | 291 | const char* topName = likelyMixamoFile ? "HeadTop_End" : "HeadEnd"; |
| 292 | joints.insert("jointHead", geometry.jointIndices.contains(topName) ? topName : "Head"); | 292 | joints.insert("jointHead", hfmModel.jointIndices.contains(topName) ? topName : "Head"); |
| 293 | } | 293 | } |
| 294 | 294 | ||
| 295 | mapping.insert(JOINT_FIELD, joints); | 295 | mapping.insert(JOINT_FIELD, joints); |
| @@ -361,7 +361,7 @@ void ModelPackager::populateBasicMapping(QVariantHash& mapping, QString filename · 65 unmodified lines | |||
| 361 | 361 | ||
| 362 | void ModelPackager::listTextures() { | 362 | void ModelPackager::listTextures() { |
| 363 | _textures.clear(); | 363 | _textures.clear(); |
| 364 | foreach (const FBXMaterial mat, _geometry->materials) { | 364 | foreach (const HFMMaterial mat, _hfmModel->materials) { |
| 365 | if (!mat.albedoTexture.filename.isEmpty() && mat.albedoTexture.content.isEmpty() && | 365 | if (!mat.albedoTexture.filename.isEmpty() && mat.albedoTexture.content.isEmpty() && |
| 366 | !_textures.contains(mat.albedoTexture.filename)) { | 366 | !_textures.contains(mat.albedoTexture.filename)) { |
| 367 | _textures << mat.albedoTexture.filename; | 367 | _textures << mat.albedoTexture.filename; |