Add entity model upload

This commit is contained in:
Atlante45 2014-12-23 12:30:00 -08:00
parent 55370477db
commit 879c3e2fd0
6 changed files with 109 additions and 91 deletions

View file

@ -4202,6 +4202,10 @@ void Application::uploadAttachment() {
uploadModel(ATTACHMENT_MODEL); uploadModel(ATTACHMENT_MODEL);
} }
void Application::uploadEntity() {
uploadModel(ENTITY_MODEL);
}
void Application::openUrl(const QUrl& url) { void Application::openUrl(const QUrl& url) {
if (!url.isEmpty()) { if (!url.isEmpty()) {
if (url.scheme() == HIFI_URL_SCHEME) { if (url.scheme() == HIFI_URL_SCHEME) {

View file

@ -374,6 +374,7 @@ public slots:
void uploadHead(); void uploadHead();
void uploadSkeleton(); void uploadSkeleton();
void uploadAttachment(); void uploadAttachment();
void uploadEntity();
void openUrl(const QUrl& url); void openUrl(const QUrl& url);

View file

@ -189,10 +189,14 @@ Menu::Menu() :
SLOT(toggleAddressBar())); SLOT(toggleAddressBar()));
addDisabledActionAndSeparator(fileMenu, "Upload Avatar Model"); addDisabledActionAndSeparator(fileMenu, "Upload Avatar Model");
addActionToQMenuAndActionHash(fileMenu, MenuOption::UploadHead, 0, Application::getInstance(), SLOT(uploadHead())); addActionToQMenuAndActionHash(fileMenu, MenuOption::UploadHead, 0,
addActionToQMenuAndActionHash(fileMenu, MenuOption::UploadSkeleton, 0, Application::getInstance(), SLOT(uploadSkeleton())); Application::getInstance(), SLOT(uploadHead()));
addActionToQMenuAndActionHash(fileMenu, MenuOption::UploadSkeleton, 0,
Application::getInstance(), SLOT(uploadSkeleton()));
addActionToQMenuAndActionHash(fileMenu, MenuOption::UploadAttachment, 0, addActionToQMenuAndActionHash(fileMenu, MenuOption::UploadAttachment, 0,
Application::getInstance(), SLOT(uploadAttachment())); Application::getInstance(), SLOT(uploadAttachment()));
addActionToQMenuAndActionHash(fileMenu, MenuOption::UploadEntity, 0,
Application::getInstance(), SLOT(uploadEntity()));
addDisabledActionAndSeparator(fileMenu, "Settings"); addDisabledActionAndSeparator(fileMenu, "Settings");
addActionToQMenuAndActionHash(fileMenu, MenuOption::SettingsImport, 0, this, SLOT(importSettings())); addActionToQMenuAndActionHash(fileMenu, MenuOption::SettingsImport, 0, this, SLOT(importSettings()));
addActionToQMenuAndActionHash(fileMenu, MenuOption::SettingsExport, 0, this, SLOT(exportSettings())); addActionToQMenuAndActionHash(fileMenu, MenuOption::SettingsExport, 0, this, SLOT(exportSettings()));

View file

@ -482,6 +482,7 @@ namespace MenuOption {
const QString TransmitterDrive = "Transmitter Drive"; const QString TransmitterDrive = "Transmitter Drive";
const QString TurnWithHead = "Turn using Head"; const QString TurnWithHead = "Turn using Head";
const QString UploadAttachment = "Upload Attachment Model"; const QString UploadAttachment = "Upload Attachment Model";
const QString UploadEntity = "Upload Entity Model";
const QString UploadHead = "Upload Head Model"; const QString UploadHead = "Upload Head Model";
const QString UploadSkeleton = "Upload Skeleton Model"; const QString UploadSkeleton = "Upload Skeleton Model";
const QString UserInterface = "User Interface"; const QString UserInterface = "User Interface";

View file

@ -55,8 +55,9 @@ static const QString MODEL_URL = "/api/v1/models";
static const QString SETTING_NAME = "LastModelUploadLocation"; static const QString SETTING_NAME = "LastModelUploadLocation";
static const int MAX_SIZE = 10 * 1024 * 1024; // 10 MB static const int BYTES_PER_MEGABYTES = 1024 * 1024;
static const int MAX_TEXTURE_SIZE = 1024; static const unsigned long MAX_SIZE = 50 * 1024 * BYTES_PER_MEGABYTES; // 50 GB (Virtually remove limit)
static const int MAX_TEXTURE_SIZE = 4096;
static const int TIMEOUT = 1000; static const int TIMEOUT = 1000;
static const int MAX_CHECK = 30; static const int MAX_CHECK = 30;
@ -590,9 +591,9 @@ bool ModelUploader::addPart(const QFile& file, const QByteArray& contents, const
if (_totalSize > MAX_SIZE) { if (_totalSize > MAX_SIZE) {
QMessageBox::warning(NULL, QMessageBox::warning(NULL,
QString("ModelUploader::zip()"), QString("ModelUploader::zip()"),
QString("Model too big, over %1 Bytes.").arg(MAX_SIZE), QString("Model too big, over %1 MB.").arg(MAX_SIZE / BYTES_PER_MEGABYTES),
QMessageBox::Ok); QMessageBox::Ok);
qDebug() << "[Warning] " << QString("Model too big, over %1 Bytes.").arg(MAX_SIZE); qDebug() << "[Warning] " << QString("Model too big, over %1 MB.").arg(MAX_SIZE / BYTES_PER_MEGABYTES);
return false; return false;
} }
qDebug() << "Current model size: " << _totalSize; qDebug() << "Current model size: " << _totalSize;
@ -613,8 +614,8 @@ ModelPropertiesDialog::ModelPropertiesDialog(ModelType modelType, const QVariant
_modelType(modelType), _modelType(modelType),
_originalMapping(originalMapping), _originalMapping(originalMapping),
_basePath(basePath), _basePath(basePath),
_geometry(geometry) { _geometry(geometry)
{
setWindowTitle("Set Model Properties"); setWindowTitle("Set Model Properties");
QFormLayout* form = new QFormLayout(); QFormLayout* form = new QFormLayout();
@ -629,33 +630,35 @@ ModelPropertiesDialog::ModelPropertiesDialog(ModelType modelType, const QVariant
_scale->setMaximum(FLT_MAX); _scale->setMaximum(FLT_MAX);
_scale->setSingleStep(0.01); _scale->setSingleStep(0.01);
if (_modelType == ATTACHMENT_MODEL) { if (_modelType != ENTITY_MODEL) {
QHBoxLayout* translation = new QHBoxLayout(); if (_modelType == ATTACHMENT_MODEL) {
form->addRow("Translation:", translation); QHBoxLayout* translation = new QHBoxLayout();
translation->addWidget(_translationX = createTranslationBox()); form->addRow("Translation:", translation);
translation->addWidget(_translationY = createTranslationBox()); translation->addWidget(_translationX = createTranslationBox());
translation->addWidget(_translationZ = createTranslationBox()); translation->addWidget(_translationY = createTranslationBox());
form->addRow("Pivot About Center:", _pivotAboutCenter = new QCheckBox()); translation->addWidget(_translationZ = createTranslationBox());
form->addRow("Pivot Joint:", _pivotJoint = createJointBox()); form->addRow("Pivot About Center:", _pivotAboutCenter = new QCheckBox());
connect(_pivotAboutCenter, SIGNAL(toggled(bool)), SLOT(updatePivotJoint())); form->addRow("Pivot Joint:", _pivotJoint = createJointBox());
_pivotAboutCenter->setChecked(true); connect(_pivotAboutCenter, SIGNAL(toggled(bool)), SLOT(updatePivotJoint()));
_pivotAboutCenter->setChecked(true);
} else {
form->addRow("Left Eye Joint:", _leftEyeJoint = createJointBox()); } else {
form->addRow("Right Eye Joint:", _rightEyeJoint = createJointBox()); form->addRow("Left Eye Joint:", _leftEyeJoint = createJointBox());
form->addRow("Neck Joint:", _neckJoint = createJointBox()); form->addRow("Right Eye Joint:", _rightEyeJoint = createJointBox());
} form->addRow("Neck Joint:", _neckJoint = createJointBox());
if (_modelType == SKELETON_MODEL) { }
form->addRow("Root Joint:", _rootJoint = createJointBox()); if (_modelType == SKELETON_MODEL) {
form->addRow("Lean Joint:", _leanJoint = createJointBox()); form->addRow("Root Joint:", _rootJoint = createJointBox());
form->addRow("Head Joint:", _headJoint = createJointBox()); form->addRow("Lean Joint:", _leanJoint = createJointBox());
form->addRow("Left Hand Joint:", _leftHandJoint = createJointBox()); form->addRow("Head Joint:", _headJoint = createJointBox());
form->addRow("Right Hand Joint:", _rightHandJoint = 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"); form->addRow("Free Joints:", _freeJoints = new QVBoxLayout());
_freeJoints->addWidget(newFreeJoint); QPushButton* newFreeJoint = new QPushButton("New Free Joint");
connect(newFreeJoint, SIGNAL(clicked(bool)), SLOT(createNewFreeJoint())); _freeJoints->addWidget(newFreeJoint);
connect(newFreeJoint, SIGNAL(clicked(bool)), SLOT(createNewFreeJoint()));
}
} }
QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok |
@ -683,38 +686,40 @@ QVariantHash ModelPropertiesDialog::getMapping() const {
} }
mapping.insert(JOINT_INDEX_FIELD, jointIndices); mapping.insert(JOINT_INDEX_FIELD, jointIndices);
QVariantHash joints = mapping.value(JOINT_FIELD).toHash(); if (_modelType != ENTITY_MODEL) {
if (_modelType == ATTACHMENT_MODEL) { QVariantHash joints = mapping.value(JOINT_FIELD).toHash();
glm::vec3 pivot; if (_modelType == ATTACHMENT_MODEL) {
if (_pivotAboutCenter->isChecked()) { glm::vec3 pivot;
pivot = (_geometry.meshExtents.minimum + _geometry.meshExtents.maximum) * 0.5f; if (_pivotAboutCenter->isChecked()) {
pivot = (_geometry.meshExtents.minimum + _geometry.meshExtents.maximum) * 0.5f;
} else if (_pivotJoint->currentIndex() != 0) {
pivot = extractTranslation(_geometry.joints.at(_pivotJoint->currentIndex() - 1).transform); } else if (_pivotJoint->currentIndex() != 0) {
pivot = extractTranslation(_geometry.joints.at(_pivotJoint->currentIndex() - 1).transform);
}
mapping.insert(TRANSLATION_X_FIELD, -pivot.x * _scale->value() + _translationX->value());
mapping.insert(TRANSLATION_Y_FIELD, -pivot.y * _scale->value() + _translationY->value());
mapping.insert(TRANSLATION_Z_FIELD, -pivot.z * _scale->value() + _translationZ->value());
} else {
insertJointMapping(joints, "jointEyeLeft", _leftEyeJoint->currentText());
insertJointMapping(joints, "jointEyeRight", _rightEyeJoint->currentText());
insertJointMapping(joints, "jointNeck", _neckJoint->currentText());
} }
mapping.insert(TRANSLATION_X_FIELD, -pivot.x * _scale->value() + _translationX->value()); if (_modelType == SKELETON_MODEL) {
mapping.insert(TRANSLATION_Y_FIELD, -pivot.y * _scale->value() + _translationY->value()); insertJointMapping(joints, "jointRoot", _rootJoint->currentText());
mapping.insert(TRANSLATION_Z_FIELD, -pivot.z * _scale->value() + _translationZ->value()); insertJointMapping(joints, "jointLean", _leanJoint->currentText());
insertJointMapping(joints, "jointHead", _headJoint->currentText());
} else { insertJointMapping(joints, "jointLeftHand", _leftHandJoint->currentText());
insertJointMapping(joints, "jointEyeLeft", _leftEyeJoint->currentText()); insertJointMapping(joints, "jointRightHand", _rightHandJoint->currentText());
insertJointMapping(joints, "jointEyeRight", _rightEyeJoint->currentText());
insertJointMapping(joints, "jointNeck", _neckJoint->currentText()); mapping.remove(FREE_JOINT_FIELD);
} for (int i = 0; i < _freeJoints->count() - 1; i++) {
if (_modelType == SKELETON_MODEL) { QComboBox* box = static_cast<QComboBox*>(_freeJoints->itemAt(i)->widget()->layout()->itemAt(0)->widget());
insertJointMapping(joints, "jointRoot", _rootJoint->currentText()); mapping.insertMulti(FREE_JOINT_FIELD, box->currentText());
insertJointMapping(joints, "jointLean", _leanJoint->currentText()); }
insertJointMapping(joints, "jointHead", _headJoint->currentText());
insertJointMapping(joints, "jointLeftHand", _leftHandJoint->currentText());
insertJointMapping(joints, "jointRightHand", _rightHandJoint->currentText());
mapping.remove(FREE_JOINT_FIELD);
for (int i = 0; i < _freeJoints->count() - 1; i++) {
QComboBox* box = static_cast<QComboBox*>(_freeJoints->itemAt(i)->widget()->layout()->itemAt(0)->widget());
mapping.insertMulti(FREE_JOINT_FIELD, box->currentText());
} }
mapping.insert(JOINT_FIELD, joints);
} }
mapping.insert(JOINT_FIELD, joints);
return mapping; return mapping;
} }
@ -729,32 +734,35 @@ void ModelPropertiesDialog::reset() {
_scale->setValue(_originalMapping.value(SCALE_FIELD).toDouble()); _scale->setValue(_originalMapping.value(SCALE_FIELD).toDouble());
QVariantHash jointHash = _originalMapping.value(JOINT_FIELD).toHash(); QVariantHash jointHash = _originalMapping.value(JOINT_FIELD).toHash();
if (_modelType == ATTACHMENT_MODEL) {
_translationX->setValue(_originalMapping.value(TRANSLATION_X_FIELD).toDouble()); if (_modelType != ENTITY_MODEL) {
_translationY->setValue(_originalMapping.value(TRANSLATION_Y_FIELD).toDouble()); if (_modelType == ATTACHMENT_MODEL) {
_translationZ->setValue(_originalMapping.value(TRANSLATION_Z_FIELD).toDouble()); _translationX->setValue(_originalMapping.value(TRANSLATION_X_FIELD).toDouble());
_pivotAboutCenter->setChecked(true); _translationY->setValue(_originalMapping.value(TRANSLATION_Y_FIELD).toDouble());
_pivotJoint->setCurrentIndex(0); _translationZ->setValue(_originalMapping.value(TRANSLATION_Z_FIELD).toDouble());
_pivotAboutCenter->setChecked(true);
} else { _pivotJoint->setCurrentIndex(0);
setJointText(_leftEyeJoint, jointHash.value("jointEyeLeft").toString());
setJointText(_rightEyeJoint, jointHash.value("jointEyeRight").toString()); } else {
setJointText(_neckJoint, jointHash.value("jointNeck").toString()); setJointText(_leftEyeJoint, jointHash.value("jointEyeLeft").toString());
} setJointText(_rightEyeJoint, jointHash.value("jointEyeRight").toString());
if (_modelType == SKELETON_MODEL) { setJointText(_neckJoint, jointHash.value("jointNeck").toString());
setJointText(_rootJoint, jointHash.value("jointRoot").toString());
setJointText(_leanJoint, jointHash.value("jointLean").toString());
setJointText(_headJoint, jointHash.value("jointHead").toString());
setJointText(_leftHandJoint, jointHash.value("jointLeftHand").toString());
setJointText(_rightHandJoint, jointHash.value("jointRightHand").toString());
while (_freeJoints->count() > 1) {
delete _freeJoints->itemAt(0)->widget();
} }
foreach (const QVariant& joint, _originalMapping.values(FREE_JOINT_FIELD)) { if (_modelType == SKELETON_MODEL) {
QString jointName = joint.toString(); setJointText(_rootJoint, jointHash.value("jointRoot").toString());
if (_geometry.jointIndices.contains(jointName)) { setJointText(_leanJoint, jointHash.value("jointLean").toString());
createNewFreeJoint(jointName); setJointText(_headJoint, jointHash.value("jointHead").toString());
setJointText(_leftHandJoint, jointHash.value("jointLeftHand").toString());
setJointText(_rightHandJoint, jointHash.value("jointRightHand").toString());
while (_freeJoints->count() > 1) {
delete _freeJoints->itemAt(0)->widget();
}
foreach (const QVariant& joint, _originalMapping.values(FREE_JOINT_FIELD)) {
QString jointName = joint.toString();
if (_geometry.jointIndices.contains(jointName)) {
createNewFreeJoint(jointName);
}
} }
} }
} }

View file

@ -53,7 +53,7 @@ private:
QSet<QByteArray> _textureFilenames; QSet<QByteArray> _textureFilenames;
int _lodCount; int _lodCount;
int _texturesCount; int _texturesCount;
int _totalSize; unsigned long _totalSize;
ModelType _modelType; ModelType _modelType;
bool _readyToSend; bool _readyToSend;