Showing the changes to interface/src/ModelPropertiesDialog.cpp (1 of 6 files). Show all
Unified · Split
| @@ -26,9 +26,8 @@ · 25 unmodified lines | |||
| 26 | #include <OffscreenUi.h> | 26 | #include <OffscreenUi.h> |
| 27 | 27 | ||
| 28 | 28 | ||
| 29 | ModelPropertiesDialog::ModelPropertiesDialog(FSTReader::ModelType modelType, const QVariantHash& originalMapping, | 29 | ModelPropertiesDialog::ModelPropertiesDialog(const QVariantHash& originalMapping, |
| 30 | const QString& basePath, const FBXGeometry& geometry) : | 30 | const QString& basePath, const FBXGeometry& geometry) : |
| 31 | _modelType(modelType), | ||
| 32 | _originalMapping(originalMapping), | 31 | _originalMapping(originalMapping), |
| 33 | _basePath(basePath), | 32 | _basePath(basePath), |
| 34 | _geometry(geometry) | 33 | _geometry(geometry) |
| @@ -50,36 +49,19 @@ _geometry(geometry) · 15 unmodified lines | |||
| 50 | _scale->setMaximum(FLT_MAX); | 49 | _scale->setMaximum(FLT_MAX); |
| 51 | _scale->setSingleStep(0.01); | 50 | _scale->setSingleStep(0.01); |
| 52 | 51 | ||
| 53 | if (_modelType != FSTReader::ENTITY_MODEL) { | 52 | form->addRow("Left Eye Joint:", _leftEyeJoint = createJointBox()); |
| 54 | if (_modelType == FSTReader::ATTACHMENT_MODEL) { | 53 | form->addRow("Right Eye Joint:", _rightEyeJoint = createJointBox()); |
| 55 | QHBoxLayout* translation = new QHBoxLayout(); | 54 | form->addRow("Neck Joint:", _neckJoint = createJointBox()); |
| 56 | form->addRow("Translation:", translation); | 55 | form->addRow("Root Joint:", _rootJoint = createJointBox()); |
| 57 | translation->addWidget(_translationX = createTranslationBox()); | 56 | form->addRow("Lean Joint:", _leanJoint = createJointBox()); |
| 58 | translation->addWidget(_translationY = createTranslationBox()); | 57 | form->addRow("Head Joint:", _headJoint = createJointBox()); |
| 59 | translation->addWidget(_translationZ = createTranslationBox()); | 58 | form->addRow("Left Hand Joint:", _leftHandJoint = createJointBox()); |
| 60 | form->addRow("Pivot About Center:", _pivotAboutCenter = new QCheckBox()); | 59 | form->addRow("Right Hand Joint:", _rightHandJoint = createJointBox()); |
| 61 | form->addRow("Pivot Joint:", _pivotJoint = createJointBox()); | 60 | |
| 62 | connect(_pivotAboutCenter, SIGNAL(toggled(bool)), SLOT(updatePivotJoint())); | 61 | form->addRow("Free Joints:", _freeJoints = new QVBoxLayout()); |
| 63 | _pivotAboutCenter->setChecked(true); | 62 | QPushButton* newFreeJoint = new QPushButton("New Free Joint"); |
| 64 | 63 | _freeJoints->addWidget(newFreeJoint); | |
| 65 | } else { | 64 | connect(newFreeJoint, SIGNAL(clicked(bool)), SLOT(createNewFreeJoint())); |
| 66 | form->addRow("Left Eye Joint:", _leftEyeJoint = createJointBox()); | ||
| 67 | form->addRow("Right Eye Joint:", _rightEyeJoint = createJointBox()); | ||
| 68 | form->addRow("Neck Joint:", _neckJoint = createJointBox()); | ||
| 69 | } | ||
| 70 | if (_modelType == FSTReader::BODY_ONLY_MODEL || _modelType == FSTReader::HEAD_AND_BODY_MODEL) { | ||
| 71 | form->addRow("Root Joint:", _rootJoint = createJointBox()); | ||
| 72 | form->addRow("Lean Joint:", _leanJoint = createJointBox()); | ||
| 73 | form->addRow("Head Joint:", _headJoint = createJointBox()); | ||
| 74 | form->addRow("Left Hand Joint:", _leftHandJoint = createJointBox()); | ||
| 75 | form->addRow("Right Hand Joint:", _rightHandJoint = createJointBox()); | ||
| 76 | |||
| 77 | form->addRow("Free Joints:", _freeJoints = new QVBoxLayout()); | ||
| 78 | QPushButton* newFreeJoint = new QPushButton("New Free Joint"); | ||
| 79 | _freeJoints->addWidget(newFreeJoint); | ||
| 80 | connect(newFreeJoint, SIGNAL(clicked(bool)), SLOT(createNewFreeJoint())); | ||
| 81 | } | ||
| 82 | } | ||
| 83 | 65 | ||
| 84 | QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | | 66 | QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | |
| 85 | QDialogButtonBox::Cancel | QDialogButtonBox::Reset); | 67 | QDialogButtonBox::Cancel | QDialogButtonBox::Reset); |
| @@ -93,14 +75,9 @@ _geometry(geometry) · 7 unmodified lines | |||
| 93 | reset(); | 75 | reset(); |
| 94 | } | 76 | } |
| 95 | 77 | ||
| 96 | |||
| 97 | QString ModelPropertiesDialog::getType() const { | ||
| 98 | return FSTReader::getNameFromType(_modelType); | ||
| 99 | } | ||
| 100 | |||
| 101 | QVariantHash ModelPropertiesDialog::getMapping() const { | 78 | QVariantHash ModelPropertiesDialog::getMapping() const { |
| 102 | QVariantHash mapping = _originalMapping; | 79 | QVariantHash mapping = _originalMapping; |
| 103 | mapping.insert(TYPE_FIELD, getType()); | 80 | mapping.insert(TYPE_FIELD, FSTReader::getNameFromType(FSTReader::HEAD_AND_BODY_MODEL)); |
| 104 | mapping.insert(NAME_FIELD, _name->text()); | 81 | mapping.insert(NAME_FIELD, _name->text()); |
| 105 | mapping.insert(TEXDIR_FIELD, _textureDirectory->text()); | 82 | mapping.insert(TEXDIR_FIELD, _textureDirectory->text()); |
| 106 | mapping.insert(SCRIPT_FIELD, _scriptDirectory->text()); | 83 | mapping.insert(SCRIPT_FIELD, _scriptDirectory->text()); |
| @@ -113,42 +90,24 @@ QVariantHash ModelPropertiesDialog::getMapping() const { · 6 unmodified lines | |||
| 113 | } | 90 | } |
| 114 | mapping.insert(JOINT_INDEX_FIELD, jointIndices); | 91 | mapping.insert(JOINT_INDEX_FIELD, jointIndices); |
| 115 | 92 | ||
| 116 | if (_modelType != FSTReader::ENTITY_MODEL) { | 93 | QVariantHash joints = mapping.value(JOINT_FIELD).toHash(); |
| 117 | QVariantHash joints = mapping.value(JOINT_FIELD).toHash(); | 94 | insertJointMapping(joints, "jointEyeLeft", _leftEyeJoint->currentText()); |
| 118 | if (_modelType == FSTReader::ATTACHMENT_MODEL) { | 95 | insertJointMapping(joints, "jointEyeRight", _rightEyeJoint->currentText()); |
| 119 | glm::vec3 pivot; | 96 | insertJointMapping(joints, "jointNeck", _neckJoint->currentText()); |
| 120 | if (_pivotAboutCenter->isChecked()) { | ||
| 121 | pivot = (_geometry.meshExtents.minimum + _geometry.meshExtents.maximum) * 0.5f; | ||
| 122 | |||
| 123 | } else if (_pivotJoint->currentIndex() != 0) { | ||
| 124 | pivot = extractTranslation(_geometry.joints.at(_pivotJoint->currentIndex() - 1).transform); | ||
| 125 | } | ||
| 126 | mapping.insert(TRANSLATION_X_FIELD, -pivot.x * (float)_scale->value() + (float)_translationX->value()); | ||
| 127 | mapping.insert(TRANSLATION_Y_FIELD, -pivot.y * (float)_scale->value() + (float)_translationY->value()); | ||
| 128 | mapping.insert(TRANSLATION_Z_FIELD, -pivot.z * (float)_scale->value() + (float)_translationZ->value()); | ||
| 129 | |||
| 130 | } else { | ||
| 131 | insertJointMapping(joints, "jointEyeLeft", _leftEyeJoint->currentText()); | ||
| 132 | insertJointMapping(joints, "jointEyeRight", _rightEyeJoint->currentText()); | ||
| 133 | insertJointMapping(joints, "jointNeck", _neckJoint->currentText()); | ||
| 134 | } | ||
| 135 | 97 | ||
| 136 | 98 | ||
| 137 | if (_modelType == FSTReader::BODY_ONLY_MODEL || _modelType == FSTReader::HEAD_AND_BODY_MODEL) { | 99 | insertJointMapping(joints, "jointRoot", _rootJoint->currentText()); |
| 138 | insertJointMapping(joints, "jointRoot", _rootJoint->currentText()); | 100 | insertJointMapping(joints, "jointLean", _leanJoint->currentText()); |
| 139 | insertJointMapping(joints, "jointLean", _leanJoint->currentText()); | 101 | insertJointMapping(joints, "jointHead", _headJoint->currentText()); |
| 140 | insertJointMapping(joints, "jointHead", _headJoint->currentText()); | 102 | insertJointMapping(joints, "jointLeftHand", _leftHandJoint->currentText()); |
| 141 | insertJointMapping(joints, "jointLeftHand", _leftHandJoint->currentText()); | 103 | insertJointMapping(joints, "jointRightHand", _rightHandJoint->currentText()); |
| 142 | insertJointMapping(joints, "jointRightHand", _rightHandJoint->currentText()); | ||
| 143 | 104 | ||
| 144 | mapping.remove(FREE_JOINT_FIELD); | 105 | mapping.remove(FREE_JOINT_FIELD); |
| 145 | for (int i = 0; i < _freeJoints->count() - 1; i++) { | 106 | for (int i = 0; i < _freeJoints->count() - 1; i++) { |
| 146 | QComboBox* box = static_cast<QComboBox*>(_freeJoints->itemAt(i)->widget()->layout()->itemAt(0)->widget()); | 107 | QComboBox* box = static_cast<QComboBox*>(_freeJoints->itemAt(i)->widget()->layout()->itemAt(0)->widget()); |
| 147 | mapping.insertMulti(FREE_JOINT_FIELD, box->currentText()); | 108 | mapping.insertMulti(FREE_JOINT_FIELD, box->currentText()); |
| 148 | } | ||
| 149 | } | ||
| 150 | mapping.insert(JOINT_FIELD, joints); | ||
| 151 | } | 109 | } |
| 110 | mapping.insert(JOINT_FIELD, joints); | ||
| 152 | 111 | ||
| 153 | return mapping; | 112 | return mapping; |
| 154 | } | 113 | } |
| @@ -165,36 +124,23 @@ void ModelPropertiesDialog::reset() { · 10 unmodified lines | |||
| 165 | 124 | ||
| 166 | QVariantHash jointHash = _originalMapping.value(JOINT_FIELD).toHash(); | 125 | QVariantHash jointHash = _originalMapping.value(JOINT_FIELD).toHash(); |
| 167 | 126 | ||
| 168 | if (_modelType != FSTReader::ENTITY_MODEL) { | 127 | setJointText(_leftEyeJoint, jointHash.value("jointEyeLeft").toString()); |
| 169 | if (_modelType == FSTReader::ATTACHMENT_MODEL) { | 128 | setJointText(_rightEyeJoint, jointHash.value("jointEyeRight").toString()); |
| 170 | _translationX->setValue(_originalMapping.value(TRANSLATION_X_FIELD).toDouble()); | 129 | setJointText(_neckJoint, jointHash.value("jointNeck").toString()); |
| 171 | _translationY->setValue(_originalMapping.value(TRANSLATION_Y_FIELD).toDouble()); | 130 | |
| 172 | _translationZ->setValue(_originalMapping.value(TRANSLATION_Z_FIELD).toDouble()); | 131 | setJointText(_rootJoint, jointHash.value("jointRoot").toString()); |
| 173 | _pivotAboutCenter->setChecked(true); | 132 | setJointText(_leanJoint, jointHash.value("jointLean").toString()); |
| 174 | _pivotJoint->setCurrentIndex(0); | 133 | setJointText(_headJoint, jointHash.value("jointHead").toString()); |
| 175 | 134 | setJointText(_leftHandJoint, jointHash.value("jointLeftHand").toString()); | |
| 176 | } else { | 135 | setJointText(_rightHandJoint, jointHash.value("jointRightHand").toString()); |
| 177 | setJointText(_leftEyeJoint, jointHash.value("jointEyeLeft").toString()); | ||
| 178 | setJointText(_rightEyeJoint, jointHash.value("jointEyeRight").toString()); | ||
| 179 | setJointText(_neckJoint, jointHash.value("jointNeck").toString()); | ||
| 180 | } | ||
| 181 | 136 | ||
| 182 | if (_modelType == FSTReader::BODY_ONLY_MODEL || _modelType == FSTReader::HEAD_AND_BODY_MODEL) { | 137 | while (_freeJoints->count() > 1) { |
| 183 | setJointText(_rootJoint, jointHash.value("jointRoot").toString()); | 138 | delete _freeJoints->itemAt(0)->widget(); |
| 184 | setJointText(_leanJoint, jointHash.value("jointLean").toString()); | 139 | } |
| 185 | setJointText(_headJoint, jointHash.value("jointHead").toString()); | 140 | foreach (const QVariant& joint, _originalMapping.values(FREE_JOINT_FIELD)) { |
| 186 | setJointText(_leftHandJoint, jointHash.value("jointLeftHand").toString()); | 141 | QString jointName = joint.toString(); |
| 187 | setJointText(_rightHandJoint, jointHash.value("jointRightHand").toString()); | 142 | if (_geometry.jointIndices.contains(jointName)) { |
| 188 | 143 | createNewFreeJoint(jointName); | |
| 189 | while (_freeJoints->count() > 1) { | ||
| 190 | delete _freeJoints->itemAt(0)->widget(); | ||
| 191 | } | ||
| 192 | foreach (const QVariant& joint, _originalMapping.values(FREE_JOINT_FIELD)) { | ||
| 193 | QString jointName = joint.toString(); | ||
| 194 | if (_geometry.jointIndices.contains(jointName)) { | ||
| 195 | createNewFreeJoint(jointName); | ||
| 196 | } | ||
| 197 | } | ||
| 198 | } | 144 | } |
| 199 | } | 145 | } |
| 200 | } | 146 | } |