History

More work on avatar customization.

Andrzej Kapolka committed 12 years ago

Commit 6caa9281 parent c8877c34 files · +95 −30Browse files

Showing the changes to interface/src/ModelUploader.cpp (1 of 4 files). Show all

Unified · Split

interface/src/ModelUploader.cpp+73−26
@@ -148,6 +148,43 @@ bool ModelUploader::zip() { · 147 unmodified lines
148 mapping.insert(TEXDIR_FIELD, ".");148 mapping.insert(TEXDIR_FIELD, ".");
149 }149 }
150 150
151 // mixamo/autodesk defaults
152 if (!mapping.contains(SCALE_FIELD)) {
153 mapping.insert(SCALE_FIELD, 10.0);
154 }
155 QVariantHash joints = mapping.value(JOINT_FIELD).toHash();
156 if (!joints.contains("jointEyeLeft")) {
157 joints.insert("jointEyeLeft", "LeftEye");
158 }
159 if (!joints.contains("jointEyeRight")) {
160 joints.insert("jointEyeRight", "RightEye");
161 }
162 if (!joints.contains("jointNeck")) {
163 joints.insert("jointNeck", "Neck");
164 }
165 if (!joints.contains("jointRoot")) {
166 joints.insert("jointRoot", "Hips");
167 }
168 if (!joints.contains("jointLean")) {
169 joints.insert("jointLean", "Spine");
170 }
171 if (!joints.contains("jointHead")) {
172 joints.insert("jointHead", geometry.applicationName == "mixamo.com" ? "HeadTop_End" : "HeadEnd");
173 }
174 if (!joints.contains("jointLeftHand")) {
175 joints.insert("jointLeftHand", "LeftHand");
176 }
177 if (!joints.contains("jointRightHand")) {
178 joints.insert("jointRightHand", "RightHand");
179 }
180 mapping.insert(JOINT_FIELD, joints);
181 if (!mapping.contains(FREE_JOINT_FIELD)) {
182 mapping.insertMulti(FREE_JOINT_FIELD, "LeftArm");
183 mapping.insertMulti(FREE_JOINT_FIELD, "LeftForeArm");
184 mapping.insertMulti(FREE_JOINT_FIELD, "RightArm");
185 mapping.insertMulti(FREE_JOINT_FIELD, "RightForeArm");
186 }
187
151 // open the dialog to configure the rest188 // open the dialog to configure the rest
152 ModelPropertiesDialog properties(_isHead, mapping, basePath, geometry);189 ModelPropertiesDialog properties(_isHead, mapping, basePath, geometry);
153 if (properties.exec() == QDialog::Rejected) {190 if (properties.exec() == QDialog::Rejected) {
@@ -475,10 +512,8 @@ ModelPropertiesDialog::ModelPropertiesDialog(bool isHead, const QVariantHash& or · 321 unmodified lines
475 _scale->setMaximum(FLT_MAX);512 _scale->setMaximum(FLT_MAX);
476 _scale->setSingleStep(0.01);513 _scale->setSingleStep(0.01);
477 514
478 if (isHead) {515 form->addRow("Left Eye Joint:", _leftEyeJoint = createJointBox());
479 form->addRow("Left Eye Joint:", _leftEyeJoint = createJointBox());516 form->addRow("Right Eye Joint:", _rightEyeJoint = createJointBox());
480 form->addRow("Right Eye Joint:", _rightEyeJoint = createJointBox());
481 }
482 form->addRow("Neck Joint:", _neckJoint = createJointBox());517 form->addRow("Neck Joint:", _neckJoint = createJointBox());
483 if (!isHead) {518 if (!isHead) {
484 form->addRow("Root Joint:", _rootJoint = createJointBox());519 form->addRow("Root Joint:", _rootJoint = createJointBox());
@@ -519,17 +554,15 @@ QVariantHash ModelPropertiesDialog::getMapping() const { · 34 unmodified lines
519 mapping.insert(JOINT_INDEX_FIELD, jointIndices);554 mapping.insert(JOINT_INDEX_FIELD, jointIndices);
520 555
521 QVariantHash joints = mapping.value(JOINT_FIELD).toHash();556 QVariantHash joints = mapping.value(JOINT_FIELD).toHash();
522 if (_isHead) {557 insertJointMapping(joints, "jointEyeLeft", _leftEyeJoint->currentText());
523 joints.insert("jointEyeLeft", _leftEyeJoint->currentText());558 insertJointMapping(joints, "jointEyeRight", _rightEyeJoint->currentText());
524 joints.insert("jointEyeRight", _rightEyeJoint->currentText());559 insertJointMapping(joints, "jointNeck", _neckJoint->currentText());
525 }
526 joints.insert("jointNeck", _neckJoint->currentText());
527 if (!_isHead) {560 if (!_isHead) {
528 joints.insert("jointRoot", _rootJoint->currentText());561 insertJointMapping(joints, "jointRoot", _rootJoint->currentText());
529 joints.insert("jointLean", _leanJoint->currentText());562 insertJointMapping(joints, "jointLean", _leanJoint->currentText());
530 joints.insert("jointHead", _headJoint->currentText());563 insertJointMapping(joints, "jointHead", _headJoint->currentText());
531 joints.insert("jointLeftHand", _leftHandJoint->currentText());564 insertJointMapping(joints, "jointLeftHand", _leftHandJoint->currentText());
532 joints.insert("jointRightHand", _rightHandJoint->currentText());565 insertJointMapping(joints, "jointRightHand", _rightHandJoint->currentText());
533 566
534 mapping.remove(FREE_JOINT_FIELD);567 mapping.remove(FREE_JOINT_FIELD);
535 for (int i = 0; i < _freeJoints->count() - 1; i++) {568 for (int i = 0; i < _freeJoints->count() - 1; i++) {
@@ -542,23 +575,25 @@ QVariantHash ModelPropertiesDialog::getMapping() const { · 6 unmodified lines
542 return mapping;575 return mapping;
543}576}
544 577
578static void setJointText(QComboBox* box, const QString& text) {
579 box->setCurrentIndex(qMax(box->findText(text), 0));
580}
581
545void ModelPropertiesDialog::reset() {582void ModelPropertiesDialog::reset() {
546 _name->setText(_originalMapping.value(NAME_FIELD).toString());583 _name->setText(_originalMapping.value(NAME_FIELD).toString());
547 _textureDirectory->setText(_originalMapping.value(TEXDIR_FIELD).toString());584 _textureDirectory->setText(_originalMapping.value(TEXDIR_FIELD).toString());
548 _scale->setValue(_originalMapping.value(SCALE_FIELD, 1.0).toDouble());585 _scale->setValue(_originalMapping.value(SCALE_FIELD, 1.0).toDouble());
549 586
550 QVariantHash jointHash = _originalMapping.value(JOINT_FIELD).toHash();587 QVariantHash jointHash = _originalMapping.value(JOINT_FIELD).toHash();
551 if (_isHead) {588 setJointText(_leftEyeJoint, jointHash.value("jointEyeLeft").toString());
552 _leftEyeJoint->setCurrentText(jointHash.value("jointEyeLeft").toString());589 setJointText(_rightEyeJoint, jointHash.value("jointEyeRight").toString());
553 _rightEyeJoint->setCurrentText(jointHash.value("jointEyeRight").toString());590 setJointText(_neckJoint, jointHash.value("jointNeck").toString());
554 }
555 _neckJoint->setCurrentText(jointHash.value("jointNeck").toString());
556 if (!_isHead) {591 if (!_isHead) {
557 _rootJoint->setCurrentText(jointHash.value("jointRoot").toString());592 setJointText(_rootJoint, jointHash.value("jointRoot").toString());
558 _leanJoint->setCurrentText(jointHash.value("jointLean").toString());593 setJointText(_leanJoint, jointHash.value("jointLean").toString());
559 _headJoint->setCurrentText(jointHash.value("jointHead").toString());594 setJointText(_headJoint, jointHash.value("jointHead").toString());
560 _leftHandJoint->setCurrentText(jointHash.value("jointLeftHand").toString());595 setJointText(_leftHandJoint, jointHash.value("jointLeftHand").toString());
561 _rightHandJoint->setCurrentText(jointHash.value("jointRightHand").toString());596 setJointText(_rightHandJoint, jointHash.value("jointRightHand").toString());
562 597
563 while (_freeJoints->count() > 1) {598 while (_freeJoints->count() > 1) {
564 delete _freeJoints->itemAt(0)->widget();599 delete _freeJoints->itemAt(0)->widget();
@@ -587,7 +622,7 @@ void ModelPropertiesDialog::createNewFreeJoint(const QString& joint) { · 22 unmodified lines
587 QHBoxLayout* freeJointLayout = new QHBoxLayout();622 QHBoxLayout* freeJointLayout = new QHBoxLayout();
588 freeJointLayout->setContentsMargins(QMargins());623 freeJointLayout->setContentsMargins(QMargins());
589 freeJoint->setLayout(freeJointLayout);624 freeJoint->setLayout(freeJointLayout);
590 QComboBox* jointBox = createJointBox();625 QComboBox* jointBox = createJointBox(false);
591 jointBox->setCurrentText(joint);626 jointBox->setCurrentText(joint);
592 freeJointLayout->addWidget(jointBox, 1);627 freeJointLayout->addWidget(jointBox, 1);
593 QPushButton* deleteJoint = new QPushButton("Delete");628 QPushButton* deleteJoint = new QPushButton("Delete");
@@ -596,10 +631,22 @@ void ModelPropertiesDialog::createNewFreeJoint(const QString& joint) { · 2 unmodified lines
596 _freeJoints->insertWidget(_freeJoints->count() - 1, freeJoint);631 _freeJoints->insertWidget(_freeJoints->count() - 1, freeJoint);
597}632}
598 633
599QComboBox* ModelPropertiesDialog::createJointBox() const {634QComboBox* ModelPropertiesDialog::createJointBox(bool withNone) const {
600 QComboBox* box = new QComboBox();635 QComboBox* box = new QComboBox();
636 if (withNone) {
637 box->addItem("(none)");
638 }
601 foreach (const FBXJoint& joint, _geometry.joints) {639 foreach (const FBXJoint& joint, _geometry.joints) {
602 box->addItem(joint.name);640 box->addItem(joint.name);
603 }641 }
604 return box;642 return box;
605}643}
644
645void ModelPropertiesDialog::insertJointMapping(QVariantHash& joints, const QString& joint, const QString& name) const {
646 if (_geometry.jointIndices.contains(name)) {
647 joints.insert(joint, name);
648 } else {
649 joints.remove(joint);
650 }
651}
652