Merge pull request #14251 from humbletim/fb18302-deprecated-package-model

FB18302 Remove deprecated Package Model functionality
This commit is contained in:
Jamil Akram 2018-11-15 15:52:04 -08:00 committed by GitHub
commit 35ec0b60ab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 77 additions and 165 deletions

View file

@ -141,7 +141,7 @@ Menu::Menu() {
assetServerAction->setEnabled(nodeList->getThisNodeCanWriteAssets()); assetServerAction->setEnabled(nodeList->getThisNodeCanWriteAssets());
} }
// Edit > Package Model as .fst... // Edit > Package Avatar as .fst...
addActionToQMenuAndActionHash(editMenu, MenuOption::PackageModel, 0, addActionToQMenuAndActionHash(editMenu, MenuOption::PackageModel, 0,
qApp, SLOT(packageModel())); qApp, SLOT(packageModel()));

View file

@ -141,7 +141,7 @@ namespace MenuOption {
const QString OpenVrThreadedSubmit = "OpenVR Threaded Submit"; const QString OpenVrThreadedSubmit = "OpenVR Threaded Submit";
const QString OutputMenu = "Display"; const QString OutputMenu = "Display";
const QString Overlays = "Show Overlays"; const QString Overlays = "Show Overlays";
const QString PackageModel = "Package Model as .fst..."; const QString PackageModel = "Package Avatar as .fst...";
const QString Pair = "Pair"; const QString Pair = "Pair";
const QString PhysicsShowOwned = "Highlight Simulation Ownership"; const QString PhysicsShowOwned = "Highlight Simulation Ownership";
const QString VerboseLogging = "Verbose Logging"; const QString VerboseLogging = "Verbose Logging";

View file

@ -68,7 +68,6 @@ bool ModelPackager::selectModel() {
ModelSelector selector; ModelSelector selector;
if(selector.exec() == QDialog::Accepted) { if(selector.exec() == QDialog::Accepted) {
_modelFile = selector.getFileInfo(); _modelFile = selector.getFileInfo();
_modelType = selector.getModelType();
return true; return true;
} }
return false; return false;
@ -122,28 +121,26 @@ bool ModelPackager::loadModel() {
bool ModelPackager::editProperties() { bool ModelPackager::editProperties() {
// open the dialog to configure the rest // open the dialog to configure the rest
ModelPropertiesDialog properties(_modelType, _mapping, _modelFile.path(), *_hfmModel); ModelPropertiesDialog properties(_mapping, _modelFile.path(), *_hfmModel);
if (properties.exec() == QDialog::Rejected) { if (properties.exec() == QDialog::Rejected) {
return false; return false;
} }
_mapping = properties.getMapping(); _mapping = properties.getMapping();
if (_modelType == FSTReader::BODY_ONLY_MODEL || _modelType == FSTReader::HEAD_AND_BODY_MODEL) { // Make sure that a mapping for the root joint has been specified
// Make sure that a mapping for the root joint has been specified QVariantHash joints = _mapping.value(JOINT_FIELD).toHash();
QVariantHash joints = _mapping.value(JOINT_FIELD).toHash(); if (!joints.contains("jointRoot")) {
if (!joints.contains("jointRoot")) { qWarning() << "root joint not configured for skeleton.";
qWarning() << "root joint not configured for skeleton.";
QString message = "Your did not configure a root joint for your skeleton model.\n\nPackaging will be canceled."; QString message = "Your did not configure a root joint for your skeleton model.\n\nPackaging will be canceled.";
QMessageBox msgBox; QMessageBox msgBox;
msgBox.setWindowTitle("Model Packager"); msgBox.setWindowTitle("Model Packager");
msgBox.setText(message); msgBox.setText(message);
msgBox.setStandardButtons(QMessageBox::Ok); msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setIcon(QMessageBox::Warning); msgBox.setIcon(QMessageBox::Warning);
msgBox.exec(); msgBox.exec();
return false; return false;
}
} }
return true; return true;
@ -237,8 +234,6 @@ bool ModelPackager::zipModel() {
void ModelPackager::populateBasicMapping(QVariantHash& mapping, QString filename, const hfm::Model& hfmModel) { void ModelPackager::populateBasicMapping(QVariantHash& mapping, QString filename, const hfm::Model& hfmModel) {
bool isBodyType = _modelType == FSTReader::BODY_ONLY_MODEL || _modelType == FSTReader::HEAD_AND_BODY_MODEL;
// mixamo files - in the event that a mixamo file was edited by some other tool, it's likely the applicationName will // mixamo files - in the event that a mixamo file was edited by some other tool, it's likely the applicationName will
// be rewritten, so we detect the existence of several different blendshapes which indicate we're likely a mixamo file // be rewritten, so we detect the existence of several different blendshapes which indicate we're likely a mixamo file
bool likelyMixamoFile = hfmModel.applicationName == "mixamo.com" || bool likelyMixamoFile = hfmModel.applicationName == "mixamo.com" ||
@ -279,19 +274,17 @@ void ModelPackager::populateBasicMapping(QVariantHash& mapping, QString filename
joints.insert("jointNeck", hfmModel.jointIndices.contains("jointNeck") ? "jointNeck" : "Neck"); joints.insert("jointNeck", hfmModel.jointIndices.contains("jointNeck") ? "jointNeck" : "Neck");
} }
if (isBodyType) { if (!joints.contains("jointRoot")) {
if (!joints.contains("jointRoot")) { joints.insert("jointRoot", "Hips");
joints.insert("jointRoot", "Hips"); }
} if (!joints.contains("jointLean")) {
if (!joints.contains("jointLean")) { joints.insert("jointLean", "Spine");
joints.insert("jointLean", "Spine"); }
} if (!joints.contains("jointLeftHand")) {
if (!joints.contains("jointLeftHand")) { joints.insert("jointLeftHand", "LeftHand");
joints.insert("jointLeftHand", "LeftHand"); }
} if (!joints.contains("jointRightHand")) {
if (!joints.contains("jointRightHand")) { joints.insert("jointRightHand", "RightHand");
joints.insert("jointRightHand", "RightHand");
}
} }
if (!joints.contains("jointHead")) { if (!joints.contains("jointHead")) {
@ -301,13 +294,11 @@ void ModelPackager::populateBasicMapping(QVariantHash& mapping, QString filename
mapping.insert(JOINT_FIELD, joints); mapping.insert(JOINT_FIELD, joints);
if (isBodyType) { if (!mapping.contains(FREE_JOINT_FIELD)) {
if (!mapping.contains(FREE_JOINT_FIELD)) { mapping.insertMulti(FREE_JOINT_FIELD, "LeftArm");
mapping.insertMulti(FREE_JOINT_FIELD, "LeftArm"); mapping.insertMulti(FREE_JOINT_FIELD, "LeftForeArm");
mapping.insertMulti(FREE_JOINT_FIELD, "LeftForeArm"); mapping.insertMulti(FREE_JOINT_FIELD, "RightArm");
mapping.insertMulti(FREE_JOINT_FIELD, "RightArm"); mapping.insertMulti(FREE_JOINT_FIELD, "RightForeArm");
mapping.insertMulti(FREE_JOINT_FIELD, "RightForeArm");
}
} }
// If there are no blendshape mappings, and we detect that this is likely a mixamo file, // If there are no blendshape mappings, and we detect that this is likely a mixamo file,

View file

@ -41,7 +41,6 @@ private:
QFileInfo _modelFile; QFileInfo _modelFile;
QFileInfo _fbxInfo; QFileInfo _fbxInfo;
FSTReader::ModelType _modelType;
QString _texDir; QString _texDir;
QString _scriptDir; QString _scriptDir;

View file

@ -26,9 +26,8 @@
#include <OffscreenUi.h> #include <OffscreenUi.h>
ModelPropertiesDialog::ModelPropertiesDialog(FSTReader::ModelType modelType, const QVariantHash& originalMapping, ModelPropertiesDialog::ModelPropertiesDialog(const QVariantHash& originalMapping,
const QString& basePath, const HFMModel& hfmModel) : const QString& basePath, const HFMModel& hfmModel) :
_modelType(modelType),
_originalMapping(originalMapping), _originalMapping(originalMapping),
_basePath(basePath), _basePath(basePath),
_hfmModel(hfmModel) _hfmModel(hfmModel)
@ -50,36 +49,19 @@ _hfmModel(hfmModel)
_scale->setMaximum(FLT_MAX); _scale->setMaximum(FLT_MAX);
_scale->setSingleStep(0.01); _scale->setSingleStep(0.01);
if (_modelType != FSTReader::ENTITY_MODEL) { form->addRow("Left Eye Joint:", _leftEyeJoint = createJointBox());
if (_modelType == FSTReader::ATTACHMENT_MODEL) { form->addRow("Right Eye Joint:", _rightEyeJoint = createJointBox());
QHBoxLayout* translation = new QHBoxLayout(); form->addRow("Neck Joint:", _neckJoint = createJointBox());
form->addRow("Translation:", translation); form->addRow("Root Joint:", _rootJoint = createJointBox());
translation->addWidget(_translationX = createTranslationBox()); form->addRow("Lean Joint:", _leanJoint = createJointBox());
translation->addWidget(_translationY = createTranslationBox()); form->addRow("Head Joint:", _headJoint = createJointBox());
translation->addWidget(_translationZ = createTranslationBox()); form->addRow("Left Hand Joint:", _leftHandJoint = createJointBox());
form->addRow("Pivot About Center:", _pivotAboutCenter = new QCheckBox()); form->addRow("Right Hand Joint:", _rightHandJoint = createJointBox());
form->addRow("Pivot Joint:", _pivotJoint = createJointBox());
connect(_pivotAboutCenter, SIGNAL(toggled(bool)), SLOT(updatePivotJoint()));
_pivotAboutCenter->setChecked(true);
} else { form->addRow("Free Joints:", _freeJoints = new QVBoxLayout());
form->addRow("Left Eye Joint:", _leftEyeJoint = createJointBox()); QPushButton* newFreeJoint = new QPushButton("New Free Joint");
form->addRow("Right Eye Joint:", _rightEyeJoint = createJointBox()); _freeJoints->addWidget(newFreeJoint);
form->addRow("Neck Joint:", _neckJoint = createJointBox()); connect(newFreeJoint, SIGNAL(clicked(bool)), SLOT(createNewFreeJoint()));
}
if (_modelType == FSTReader::BODY_ONLY_MODEL || _modelType == FSTReader::HEAD_AND_BODY_MODEL) {
form->addRow("Root Joint:", _rootJoint = createJointBox());
form->addRow("Lean Joint:", _leanJoint = createJointBox());
form->addRow("Head Joint:", _headJoint = createJointBox());
form->addRow("Left Hand Joint:", _leftHandJoint = createJointBox());
form->addRow("Right Hand Joint:", _rightHandJoint = createJointBox());
form->addRow("Free Joints:", _freeJoints = new QVBoxLayout());
QPushButton* newFreeJoint = new QPushButton("New Free Joint");
_freeJoints->addWidget(newFreeJoint);
connect(newFreeJoint, SIGNAL(clicked(bool)), SLOT(createNewFreeJoint()));
}
}
QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok |
QDialogButtonBox::Cancel | QDialogButtonBox::Reset); QDialogButtonBox::Cancel | QDialogButtonBox::Reset);
@ -93,14 +75,9 @@ _hfmModel(hfmModel)
reset(); reset();
} }
QString ModelPropertiesDialog::getType() const {
return FSTReader::getNameFromType(_modelType);
}
QVariantHash ModelPropertiesDialog::getMapping() const { QVariantHash ModelPropertiesDialog::getMapping() const {
QVariantHash mapping = _originalMapping; QVariantHash mapping = _originalMapping;
mapping.insert(TYPE_FIELD, getType()); mapping.insert(TYPE_FIELD, FSTReader::getNameFromType(FSTReader::HEAD_AND_BODY_MODEL));
mapping.insert(NAME_FIELD, _name->text()); mapping.insert(NAME_FIELD, _name->text());
mapping.insert(TEXDIR_FIELD, _textureDirectory->text()); mapping.insert(TEXDIR_FIELD, _textureDirectory->text());
mapping.insert(SCRIPT_FIELD, _scriptDirectory->text()); mapping.insert(SCRIPT_FIELD, _scriptDirectory->text());
@ -113,42 +90,24 @@ QVariantHash ModelPropertiesDialog::getMapping() const {
} }
mapping.insert(JOINT_INDEX_FIELD, jointIndices); mapping.insert(JOINT_INDEX_FIELD, jointIndices);
if (_modelType != FSTReader::ENTITY_MODEL) { QVariantHash joints = mapping.value(JOINT_FIELD).toHash();
QVariantHash joints = mapping.value(JOINT_FIELD).toHash(); insertJointMapping(joints, "jointEyeLeft", _leftEyeJoint->currentText());
if (_modelType == FSTReader::ATTACHMENT_MODEL) { insertJointMapping(joints, "jointEyeRight", _rightEyeJoint->currentText());
glm::vec3 pivot; insertJointMapping(joints, "jointNeck", _neckJoint->currentText());
if (_pivotAboutCenter->isChecked()) {
pivot = (_hfmModel.meshExtents.minimum + _hfmModel.meshExtents.maximum) * 0.5f;
} else if (_pivotJoint->currentIndex() != 0) {
pivot = extractTranslation(_hfmModel.joints.at(_pivotJoint->currentIndex() - 1).transform);
}
mapping.insert(TRANSLATION_X_FIELD, -pivot.x * (float)_scale->value() + (float)_translationX->value());
mapping.insert(TRANSLATION_Y_FIELD, -pivot.y * (float)_scale->value() + (float)_translationY->value());
mapping.insert(TRANSLATION_Z_FIELD, -pivot.z * (float)_scale->value() + (float)_translationZ->value());
} else {
insertJointMapping(joints, "jointEyeLeft", _leftEyeJoint->currentText());
insertJointMapping(joints, "jointEyeRight", _rightEyeJoint->currentText());
insertJointMapping(joints, "jointNeck", _neckJoint->currentText());
}
if (_modelType == FSTReader::BODY_ONLY_MODEL || _modelType == FSTReader::HEAD_AND_BODY_MODEL) { insertJointMapping(joints, "jointRoot", _rootJoint->currentText());
insertJointMapping(joints, "jointRoot", _rootJoint->currentText()); insertJointMapping(joints, "jointLean", _leanJoint->currentText());
insertJointMapping(joints, "jointLean", _leanJoint->currentText()); insertJointMapping(joints, "jointHead", _headJoint->currentText());
insertJointMapping(joints, "jointHead", _headJoint->currentText()); insertJointMapping(joints, "jointLeftHand", _leftHandJoint->currentText());
insertJointMapping(joints, "jointLeftHand", _leftHandJoint->currentText()); insertJointMapping(joints, "jointRightHand", _rightHandJoint->currentText());
insertJointMapping(joints, "jointRightHand", _rightHandJoint->currentText());
mapping.remove(FREE_JOINT_FIELD); mapping.remove(FREE_JOINT_FIELD);
for (int i = 0; i < _freeJoints->count() - 1; i++) { for (int i = 0; i < _freeJoints->count() - 1; i++) {
QComboBox* box = static_cast<QComboBox*>(_freeJoints->itemAt(i)->widget()->layout()->itemAt(0)->widget()); QComboBox* box = static_cast<QComboBox*>(_freeJoints->itemAt(i)->widget()->layout()->itemAt(0)->widget());
mapping.insertMulti(FREE_JOINT_FIELD, box->currentText()); mapping.insertMulti(FREE_JOINT_FIELD, box->currentText());
}
}
mapping.insert(JOINT_FIELD, joints);
} }
mapping.insert(JOINT_FIELD, joints);
return mapping; return mapping;
} }
@ -165,36 +124,23 @@ void ModelPropertiesDialog::reset() {
QVariantHash jointHash = _originalMapping.value(JOINT_FIELD).toHash(); QVariantHash jointHash = _originalMapping.value(JOINT_FIELD).toHash();
if (_modelType != FSTReader::ENTITY_MODEL) { setJointText(_leftEyeJoint, jointHash.value("jointEyeLeft").toString());
if (_modelType == FSTReader::ATTACHMENT_MODEL) { setJointText(_rightEyeJoint, jointHash.value("jointEyeRight").toString());
_translationX->setValue(_originalMapping.value(TRANSLATION_X_FIELD).toDouble()); setJointText(_neckJoint, jointHash.value("jointNeck").toString());
_translationY->setValue(_originalMapping.value(TRANSLATION_Y_FIELD).toDouble());
_translationZ->setValue(_originalMapping.value(TRANSLATION_Z_FIELD).toDouble());
_pivotAboutCenter->setChecked(true);
_pivotJoint->setCurrentIndex(0);
} else { setJointText(_rootJoint, jointHash.value("jointRoot").toString());
setJointText(_leftEyeJoint, jointHash.value("jointEyeLeft").toString()); setJointText(_leanJoint, jointHash.value("jointLean").toString());
setJointText(_rightEyeJoint, jointHash.value("jointEyeRight").toString()); setJointText(_headJoint, jointHash.value("jointHead").toString());
setJointText(_neckJoint, jointHash.value("jointNeck").toString()); setJointText(_leftHandJoint, jointHash.value("jointLeftHand").toString());
} setJointText(_rightHandJoint, jointHash.value("jointRightHand").toString());
if (_modelType == FSTReader::BODY_ONLY_MODEL || _modelType == FSTReader::HEAD_AND_BODY_MODEL) { while (_freeJoints->count() > 1) {
setJointText(_rootJoint, jointHash.value("jointRoot").toString()); delete _freeJoints->itemAt(0)->widget();
setJointText(_leanJoint, jointHash.value("jointLean").toString()); }
setJointText(_headJoint, jointHash.value("jointHead").toString()); foreach (const QVariant& joint, _originalMapping.values(FREE_JOINT_FIELD)) {
setJointText(_leftHandJoint, jointHash.value("jointLeftHand").toString()); QString jointName = joint.toString();
setJointText(_rightHandJoint, jointHash.value("jointRightHand").toString()); if (_hfmModel.jointIndices.contains(jointName)) {
createNewFreeJoint(jointName);
while (_freeJoints->count() > 1) {
delete _freeJoints->itemAt(0)->widget();
}
foreach (const QVariant& joint, _originalMapping.values(FREE_JOINT_FIELD)) {
QString jointName = joint.toString();
if (_hfmModel.jointIndices.contains(jointName)) {
createNewFreeJoint(jointName);
}
}
} }
} }
} }

View file

@ -29,7 +29,7 @@ class ModelPropertiesDialog : public QDialog {
Q_OBJECT Q_OBJECT
public: public:
ModelPropertiesDialog(FSTReader::ModelType modelType, const QVariantHash& originalMapping, ModelPropertiesDialog(const QVariantHash& originalMapping,
const QString& basePath, const HFMModel& hfmModel); const QString& basePath, const HFMModel& hfmModel);
QVariantHash getMapping() const; QVariantHash getMapping() const;
@ -45,9 +45,7 @@ private:
QComboBox* createJointBox(bool withNone = true) const; QComboBox* createJointBox(bool withNone = true) const;
QDoubleSpinBox* createTranslationBox() const; QDoubleSpinBox* createTranslationBox() const;
void insertJointMapping(QVariantHash& joints, const QString& joint, const QString& name) const; void insertJointMapping(QVariantHash& joints, const QString& joint, const QString& name) const;
QString getType() const;
FSTReader::ModelType _modelType;
QVariantHash _originalMapping; QVariantHash _originalMapping;
QString _basePath; QString _basePath;
HFMModel _hfmModel; HFMModel _hfmModel;
@ -71,4 +69,4 @@ private:
QVBoxLayout* _freeJoints = nullptr; QVBoxLayout* _freeJoints = nullptr;
}; };
#endif // hifi_ModelPropertiesDialog_h #endif // hifi_ModelPropertiesDialog_h

View file

@ -27,18 +27,11 @@ ModelSelector::ModelSelector() {
setWindowTitle("Select Model"); setWindowTitle("Select Model");
setLayout(form); setLayout(form);
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
_browseButton = new QPushButton("Browse", this); _browseButton = new QPushButton("Browse", this);
connect(_browseButton, &QPushButton::clicked, this, &ModelSelector::browse); connect(_browseButton, &QPushButton::clicked, this, &ModelSelector::browse);
form->addRow("Model File:", _browseButton); form->addRow("Model File:", _browseButton);
_modelType = new QComboBox(this);
_modelType->addItem(AVATAR_HEAD_AND_BODY_STRING);
_modelType->addItem(AVATAR_ATTACHEMENT_STRING);
_modelType->addItem(ENTITY_MODEL_STRING);
form->addRow("Model Type:", _modelType);
QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this); QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
connect(buttons, &QDialogButtonBox::accepted, this, &ModelSelector::accept); connect(buttons, &QDialogButtonBox::accepted, this, &ModelSelector::accept);
connect(buttons, &QDialogButtonBox::rejected, this, &QDialog::reject); connect(buttons, &QDialogButtonBox::rejected, this, &QDialog::reject);
@ -49,19 +42,6 @@ QFileInfo ModelSelector::getFileInfo() const {
return _modelFile; return _modelFile;
} }
FSTReader::ModelType ModelSelector::getModelType() const {
QString text = _modelType->currentText();
if (text == AVATAR_HEAD_AND_BODY_STRING) {
return FSTReader::HEAD_AND_BODY_MODEL;
} else if (text == AVATAR_ATTACHEMENT_STRING) {
return FSTReader::ATTACHMENT_MODEL;
} else if (text == ENTITY_MODEL_STRING) {
return FSTReader::ENTITY_MODEL;
}
Q_UNREACHABLE();
}
void ModelSelector::accept() { void ModelSelector::accept() {
if (!_modelFile.isFile()) { if (!_modelFile.isFile()) {
return; return;

View file

@ -29,7 +29,6 @@ public:
ModelSelector(); ModelSelector();
QFileInfo getFileInfo() const; QFileInfo getFileInfo() const;
FSTReader::ModelType getModelType() const;
public slots: public slots:
virtual void accept() override; virtual void accept() override;
@ -40,7 +39,6 @@ public:
private: private:
QFileInfo _modelFile; QFileInfo _modelFile;
QPushButton* _browseButton; QPushButton* _browseButton;
QComboBox* _modelType;
}; };
#endif // hifi_ModelSelector_h #endif // hifi_ModelSelector_h