Showing the changes to interface/src/ModelPropertiesDialog.cpp (1 of 55 files). Show all
Unified · Split
| @@ -33,19 +33,19 @@ _basePath(basePath), · 32 unmodified lines | ||
| 33 | 33 | _geometry(geometry) |
| 34 | 34 | { |
| 35 | 35 | setWindowTitle("Set Model Properties"); |
| 36 | − | |
| 36 | + | |
| 37 | 37 | QFormLayout* form = new QFormLayout(); |
| 38 | 38 | setLayout(form); |
| 39 | − | |
| 39 | + | |
| 40 | 40 | form->addRow("Name:", _name = new QLineEdit()); |
| 41 | − | |
| 41 | + | |
| 42 | 42 | form->addRow("Texture Directory:", _textureDirectory = new QPushButton()); |
| 43 | 43 | connect(_textureDirectory, SIGNAL(clicked(bool)), SLOT(chooseTextureDirectory())); |
| 44 | − | |
| 44 | + | |
| 45 | 45 | form->addRow("Scale:", _scale = new QDoubleSpinBox()); |
| 46 | 46 | _scale->setMaximum(FLT_MAX); |
| 47 | 47 | _scale->setSingleStep(0.01); |
| 48 | − | |
| 48 | + | |
| 49 | 49 | if (_modelType != FSTReader::ENTITY_MODEL) { |
| 50 | 50 | if (_modelType == FSTReader::ATTACHMENT_MODEL) { |
| 51 | 51 | QHBoxLayout* translation = new QHBoxLayout(); |
| @@ -57,7 +57,7 @@ _geometry(geometry) · 5 unmodified lines | ||
| 57 | 57 | form->addRow("Pivot Joint:", _pivotJoint = createJointBox()); |
| 58 | 58 | connect(_pivotAboutCenter, SIGNAL(toggled(bool)), SLOT(updatePivotJoint())); |
| 59 | 59 | _pivotAboutCenter->setChecked(true); |
| 60 | − | |
| 60 | + | |
| 61 | 61 | } else { |
| 62 | 62 | form->addRow("Left Eye Joint:", _leftEyeJoint = createJointBox()); |
| 63 | 63 | form->addRow("Right Eye Joint:", _rightEyeJoint = createJointBox()); |
| @@ -69,22 +69,22 @@ _geometry(geometry) · 5 unmodified lines | ||
| 69 | 69 | form->addRow("Head Joint:", _headJoint = createJointBox()); |
| 70 | 70 | form->addRow("Left Hand Joint:", _leftHandJoint = createJointBox()); |
| 71 | 71 | form->addRow("Right Hand Joint:", _rightHandJoint = createJointBox()); |
| 72 | − | |
| 72 | + | |
| 73 | 73 | form->addRow("Free Joints:", _freeJoints = new QVBoxLayout()); |
| 74 | 74 | QPushButton* newFreeJoint = new QPushButton("New Free Joint"); |
| 75 | 75 | _freeJoints->addWidget(newFreeJoint); |
| 76 | 76 | connect(newFreeJoint, SIGNAL(clicked(bool)), SLOT(createNewFreeJoint())); |
| 77 | 77 | } |
| 78 | 78 | } |
| 79 | − | |
| 79 | + | |
| 80 | 80 | QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | |
| 81 | 81 | QDialogButtonBox::Cancel | QDialogButtonBox::Reset); |
| 82 | 82 | connect(buttons, SIGNAL(accepted()), SLOT(accept())); |
| 83 | 83 | connect(buttons, SIGNAL(rejected()), SLOT(reject())); |
| 84 | 84 | connect(buttons->button(QDialogButtonBox::Reset), SIGNAL(clicked(bool)), SLOT(reset())); |
| 85 | − | |
| 85 | + | |
| 86 | 86 | form->addRow(buttons); |
| 87 | − | |
| 87 | + | |
| 88 | 88 | // reset to initialize the fields |
| 89 | 89 | reset(); |
| 90 | 90 | } |
| @@ -100,42 +100,42 @@ QVariantHash ModelPropertiesDialog::getMapping() const { · 9 unmodified lines | ||
| 100 | 100 | mapping.insert(NAME_FIELD, _name->text()); |
| 101 | 101 | mapping.insert(TEXDIR_FIELD, _textureDirectory->text()); |
| 102 | 102 | mapping.insert(SCALE_FIELD, QString::number(_scale->value())); |
| 103 | − | |
| 103 | + | |
| 104 | 104 | // update the joint indices |
| 105 | 105 | QVariantHash jointIndices; |
| 106 | 106 | for (int i = 0; i < _geometry.joints.size(); i++) { |
| 107 | 107 | jointIndices.insert(_geometry.joints.at(i).name, QString::number(i)); |
| 108 | 108 | } |
| 109 | 109 | mapping.insert(JOINT_INDEX_FIELD, jointIndices); |
| 110 | − | |
| 110 | + | |
| 111 | 111 | if (_modelType != FSTReader::ENTITY_MODEL) { |
| 112 | 112 | QVariantHash joints = mapping.value(JOINT_FIELD).toHash(); |
| 113 | 113 | if (_modelType == FSTReader::ATTACHMENT_MODEL) { |
| 114 | 114 | glm::vec3 pivot; |
| 115 | 115 | if (_pivotAboutCenter->isChecked()) { |
| 116 | 116 | pivot = (_geometry.meshExtents.minimum + _geometry.meshExtents.maximum) * 0.5f; |
| 117 | − | |
| 117 | + | |
| 118 | 118 | } else if (_pivotJoint->currentIndex() != 0) { |
| 119 | 119 | pivot = extractTranslation(_geometry.joints.at(_pivotJoint->currentIndex() - 1).transform); |
| 120 | 120 | } |
| 121 | − mapping.insert(TRANSLATION_X_FIELD, -pivot.x * _scale->value() + _translationX->value()); | |
| 122 | − mapping.insert(TRANSLATION_Y_FIELD, -pivot.y * _scale->value() + _translationY->value()); | |
| 123 | − mapping.insert(TRANSLATION_Z_FIELD, -pivot.z * _scale->value() + _translationZ->value()); | |
| 124 | − | |
| 121 | + mapping.insert(TRANSLATION_X_FIELD, -pivot.x * (float)_scale->value() + (float)_translationX->value()); | |
| 122 | + mapping.insert(TRANSLATION_Y_FIELD, -pivot.y * (float)_scale->value() + (float)_translationY->value()); | |
| 123 | + mapping.insert(TRANSLATION_Z_FIELD, -pivot.z * (float)_scale->value() + (float)_translationZ->value()); | |
| 124 | + | |
| 125 | 125 | } else { |
| 126 | 126 | insertJointMapping(joints, "jointEyeLeft", _leftEyeJoint->currentText()); |
| 127 | 127 | insertJointMapping(joints, "jointEyeRight", _rightEyeJoint->currentText()); |
| 128 | 128 | insertJointMapping(joints, "jointNeck", _neckJoint->currentText()); |
| 129 | 129 | } |
| 130 | − | |
| 131 | − | |
| 130 | + | |
| 131 | + | |
| 132 | 132 | if (_modelType == FSTReader::BODY_ONLY_MODEL || _modelType == FSTReader::HEAD_AND_BODY_MODEL) { |
| 133 | 133 | insertJointMapping(joints, "jointRoot", _rootJoint->currentText()); |
| 134 | 134 | insertJointMapping(joints, "jointLean", _leanJoint->currentText()); |
| 135 | 135 | insertJointMapping(joints, "jointHead", _headJoint->currentText()); |
| 136 | 136 | insertJointMapping(joints, "jointLeftHand", _leftHandJoint->currentText()); |
| 137 | 137 | insertJointMapping(joints, "jointRightHand", _rightHandJoint->currentText()); |
| 138 | − | |
| 138 | + | |
| 139 | 139 | mapping.remove(FREE_JOINT_FIELD); |
| 140 | 140 | for (int i = 0; i < _freeJoints->count() - 1; i++) { |
| 141 | 141 | QComboBox* box = static_cast<QComboBox*>(_freeJoints->itemAt(i)->widget()->layout()->itemAt(0)->widget()); |
| @@ -144,7 +144,7 @@ QVariantHash ModelPropertiesDialog::getMapping() const { · 2 unmodified lines | ||
| 144 | 144 | } |
| 145 | 145 | mapping.insert(JOINT_FIELD, joints); |
| 146 | 146 | } |
| 147 | − | |
| 147 | + | |
| 148 | 148 | return mapping; |
| 149 | 149 | } |
| 150 | 150 | |
| @@ -156,9 +156,9 @@ void ModelPropertiesDialog::reset() { · 5 unmodified lines | ||
| 156 | 156 | _name->setText(_originalMapping.value(NAME_FIELD).toString()); |
| 157 | 157 | _textureDirectory->setText(_originalMapping.value(TEXDIR_FIELD).toString()); |
| 158 | 158 | _scale->setValue(_originalMapping.value(SCALE_FIELD).toDouble()); |
| 159 | − | |
| 159 | + | |
| 160 | 160 | QVariantHash jointHash = _originalMapping.value(JOINT_FIELD).toHash(); |
| 161 | − | |
| 161 | + | |
| 162 | 162 | if (_modelType != FSTReader::ENTITY_MODEL) { |
| 163 | 163 | if (_modelType == FSTReader::ATTACHMENT_MODEL) { |
| 164 | 164 | _translationX->setValue(_originalMapping.value(TRANSLATION_X_FIELD).toDouble()); |
| @@ -166,20 +166,20 @@ void ModelPropertiesDialog::reset() { · 1 unmodified line | ||
| 166 | 166 | _translationZ->setValue(_originalMapping.value(TRANSLATION_Z_FIELD).toDouble()); |
| 167 | 167 | _pivotAboutCenter->setChecked(true); |
| 168 | 168 | _pivotJoint->setCurrentIndex(0); |
| 169 | − | |
| 169 | + | |
| 170 | 170 | } else { |
| 171 | 171 | setJointText(_leftEyeJoint, jointHash.value("jointEyeLeft").toString()); |
| 172 | 172 | setJointText(_rightEyeJoint, jointHash.value("jointEyeRight").toString()); |
| 173 | 173 | setJointText(_neckJoint, jointHash.value("jointNeck").toString()); |
| 174 | 174 | } |
| 175 | − | |
| 175 | + | |
| 176 | 176 | if (_modelType == FSTReader::BODY_ONLY_MODEL || _modelType == FSTReader::HEAD_AND_BODY_MODEL) { |
| 177 | 177 | setJointText(_rootJoint, jointHash.value("jointRoot").toString()); |
| 178 | 178 | setJointText(_leanJoint, jointHash.value("jointLean").toString()); |
| 179 | 179 | setJointText(_headJoint, jointHash.value("jointHead").toString()); |
| 180 | 180 | setJointText(_leftHandJoint, jointHash.value("jointLeftHand").toString()); |
| 181 | 181 | setJointText(_rightHandJoint, jointHash.value("jointRightHand").toString()); |
| 182 | − | |
| 182 | + | |
| 183 | 183 | while (_freeJoints->count() > 1) { |
| 184 | 184 | delete _freeJoints->itemAt(0)->widget(); |
| 185 | 185 | } |