mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-04 03:33:09 +02:00
Merge branch 'master' of https://github.com/worklist/hifi into 19508
This commit is contained in:
commit
b45f61ec54
12 changed files with 157 additions and 186 deletions
|
@ -63,7 +63,7 @@
|
|||
#include <UUID.h>
|
||||
#include <OctreeSceneStats.h>
|
||||
#include <LocalVoxelsList.h>
|
||||
#include <FstReader.h>
|
||||
#include <ModelUploader.h>
|
||||
|
||||
#include "Application.h"
|
||||
#include "InterfaceVersion.h"
|
||||
|
@ -510,7 +510,7 @@ void Application::paintGL() {
|
|||
_myCamera.setDistance(0.0f);
|
||||
_myCamera.setTightness(0.0f); // Camera is directly connected to head without smoothing
|
||||
_myCamera.setTargetPosition(_myAvatar->getHead()->calculateAverageEyePosition());
|
||||
_myCamera.setTargetRotation(_myAvatar->getHead()->getOrientation());
|
||||
_myCamera.setTargetRotation(_myAvatar->getHead()->getCameraOrientation());
|
||||
|
||||
} else if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) {
|
||||
_myCamera.setTightness(0.0f); // In first person, camera follows (untweaked) head exactly without delay
|
||||
|
@ -3244,9 +3244,9 @@ void Application::toggleRunningScriptsWidget()
|
|||
}
|
||||
|
||||
void Application::uploadFST(bool isHead) {
|
||||
FstReader reader(isHead);
|
||||
if (reader.zip()) {
|
||||
reader.send();
|
||||
ModelUploader* uploader = new ModelUploader(isHead);
|
||||
if (uploader->zip()) {
|
||||
uploader->send();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1109,20 +1109,22 @@ void Menu::autoAdjustLOD(float currentFPS) {
|
|||
|
||||
quint64 now = usecTimestampNow();
|
||||
|
||||
const float ADJUST_AVATAR_LOD_DOWN_FPS = 30.0f;
|
||||
const quint64 ADJUST_AVATAR_LOD_DOWN_DELAY = 1000 * 1000;
|
||||
if (_fastFPSAverage.getAverage() < ADJUST_LOD_DOWN_FPS) {
|
||||
if (_fastFPSAverage.getAverage() < ADJUST_AVATAR_LOD_DOWN_FPS) {
|
||||
if (now - _lastAvatarDetailDrop > ADJUST_AVATAR_LOD_DOWN_DELAY) {
|
||||
// attempt to lower the detail in proportion to the fps difference
|
||||
float targetFps = (ADJUST_LOD_DOWN_FPS + ADJUST_LOD_UP_FPS) * 0.5f;
|
||||
float targetFps = (ADJUST_AVATAR_LOD_DOWN_FPS + ADJUST_LOD_UP_FPS) * 0.5f;
|
||||
float averageFps = _fastFPSAverage.getAverage();
|
||||
const float MAXIMUM_MULTIPLIER_SCALE = 2.0f;
|
||||
_avatarLODDistanceMultiplier *= (averageFps < EPSILON) ? MAXIMUM_MULTIPLIER_SCALE :
|
||||
qMin(MAXIMUM_MULTIPLIER_SCALE, targetFps / averageFps);
|
||||
const float MAXIMUM_DISTANCE_MULTIPLIER = 15.0f;
|
||||
_avatarLODDistanceMultiplier = qMin(MAXIMUM_DISTANCE_MULTIPLIER, _avatarLODDistanceMultiplier *
|
||||
(averageFps < EPSILON ? MAXIMUM_MULTIPLIER_SCALE : qMin(MAXIMUM_MULTIPLIER_SCALE, targetFps / averageFps)));
|
||||
_lastAvatarDetailDrop = now;
|
||||
}
|
||||
} else if (_fastFPSAverage.getAverage() > ADJUST_LOD_UP_FPS) {
|
||||
// let the detail level creep slowly upwards
|
||||
const float DISTANCE_DECREASE_RATE = 0.02f;
|
||||
const float DISTANCE_DECREASE_RATE = 0.05f;
|
||||
const float MINIMUM_DISTANCE_MULTIPLIER = 0.1f;
|
||||
_avatarLODDistanceMultiplier = qMax(MINIMUM_DISTANCE_MULTIPLIER,
|
||||
_avatarLODDistanceMultiplier - DISTANCE_DECREASE_RATE);
|
||||
|
|
|
@ -18,7 +18,7 @@ FaceModel::FaceModel(Head* owningHead) :
|
|||
{
|
||||
}
|
||||
|
||||
void FaceModel::simulate(float deltaTime) {
|
||||
void FaceModel::simulate(float deltaTime, bool fullUpdate) {
|
||||
updateGeometry();
|
||||
Avatar* owningAvatar = static_cast<Avatar*>(_owningHead->_owningAvatar);
|
||||
glm::vec3 neckPosition;
|
||||
|
|
|
@ -21,7 +21,7 @@ public:
|
|||
|
||||
FaceModel(Head* owningHead);
|
||||
|
||||
void simulate(float deltaTime);
|
||||
virtual void simulate(float deltaTime, bool fullUpdate = true);
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "Head.h"
|
||||
#include "Menu.h"
|
||||
#include "Util.h"
|
||||
#include "devices/OculusManager.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -198,6 +199,9 @@ glm::quat Head::getFinalOrientation() const {
|
|||
}
|
||||
|
||||
glm::quat Head::getCameraOrientation () const {
|
||||
if (OculusManager::isConnected()) {
|
||||
return getOrientation();
|
||||
}
|
||||
Avatar* owningAvatar = static_cast<Avatar*>(_owningAvatar);
|
||||
return owningAvatar->getWorldAlignedOrientation() * glm::quat(glm::radians(glm::vec3(_basePitch, 0.f, 0.0f)));
|
||||
}
|
||||
|
|
|
@ -169,9 +169,6 @@ void MyAvatar::simulate(float deltaTime) {
|
|||
// Collect thrust forces from keyboard and devices
|
||||
updateThrust(deltaTime);
|
||||
|
||||
// copy velocity so we can use it later for acceleration
|
||||
glm::vec3 oldVelocity = getVelocity();
|
||||
|
||||
// calculate speed
|
||||
_speed = glm::length(_velocity);
|
||||
|
||||
|
@ -231,29 +228,6 @@ void MyAvatar::simulate(float deltaTime) {
|
|||
// update the euler angles
|
||||
setOrientation(orientation);
|
||||
|
||||
// Compute instantaneous acceleration
|
||||
float forwardAcceleration = glm::length(glm::dot(getBodyFrontDirection(), getVelocity() - oldVelocity)) / deltaTime;
|
||||
const float OCULUS_ACCELERATION_PULL_THRESHOLD = 1.0f;
|
||||
const int OCULUS_YAW_OFFSET_THRESHOLD = 10;
|
||||
|
||||
if (!Application::getInstance()->getFaceshift()->isActive() && OculusManager::isConnected() &&
|
||||
fabsf(forwardAcceleration) > OCULUS_ACCELERATION_PULL_THRESHOLD &&
|
||||
fabs(getHead()->getBaseYaw()) > OCULUS_YAW_OFFSET_THRESHOLD) {
|
||||
|
||||
// if we're wearing the oculus
|
||||
// and this acceleration is above the pull threshold
|
||||
// and the head yaw if off the body by more than OCULUS_YAW_OFFSET_THRESHOLD
|
||||
|
||||
// match the body yaw to the oculus yaw
|
||||
_bodyYaw = getAbsoluteHeadYaw();
|
||||
|
||||
// set the head yaw to zero for this draw
|
||||
getHead()->setBaseYaw(0);
|
||||
|
||||
// correct the oculus yaw offset
|
||||
OculusManager::updateYawOffset();
|
||||
}
|
||||
|
||||
const float WALKING_SPEED_THRESHOLD = 0.2f;
|
||||
// use speed and angular velocity to determine walking vs. standing
|
||||
if (_speed + fabs(_bodyYawDelta) > WALKING_SPEED_THRESHOLD) {
|
||||
|
@ -308,7 +282,7 @@ void MyAvatar::simulate(float deltaTime) {
|
|||
head->simulate(deltaTime, true);
|
||||
|
||||
// Zero thrust out now that we've added it to velocity in this frame
|
||||
_thrust = glm::vec3(0, 0, 0);
|
||||
_thrust = glm::vec3(0.f);
|
||||
|
||||
// now that we're done stepping the avatar forward in time, compute new collisions
|
||||
if (_collisionFlags != 0) {
|
||||
|
|
|
@ -8,11 +8,10 @@
|
|||
|
||||
#include <QDialog>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QEventLoop>
|
||||
#include <QGridLayout>
|
||||
#include <QHeaderView>
|
||||
#include <QMessageBox>
|
||||
#include <QStringListModel>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QUrl>
|
||||
#include <QXmlStreamReader>
|
||||
|
||||
|
@ -33,27 +32,42 @@ static const QString KEY_NAME = "Key";
|
|||
static const QString LOADING_MSG = "Loading...";
|
||||
static const QString ERROR_MSG = "Error loading files";
|
||||
|
||||
static const QString DO_NOT_MODIFY_TAG = "DoNotModify";
|
||||
|
||||
enum ModelMetaData {
|
||||
NAME,
|
||||
CREATOR,
|
||||
UPLOAD_DATE,
|
||||
TYPE,
|
||||
GENDER,
|
||||
DATE_ADDED,
|
||||
TOTAL_SIZE,
|
||||
POLY_NUM,
|
||||
TAGS,
|
||||
|
||||
MODEL_METADATA_COUNT
|
||||
};
|
||||
static const QString propertiesNames[MODEL_METADATA_COUNT] = {
|
||||
"Name",
|
||||
"Creator",
|
||||
"Upload Date",
|
||||
"Type",
|
||||
"Gender"
|
||||
"Date Added",
|
||||
"Total Size",
|
||||
"Poly#",
|
||||
"Tags"
|
||||
};
|
||||
static const QString propertiesIds[MODEL_METADATA_COUNT] = {
|
||||
DO_NOT_MODIFY_TAG,
|
||||
"Creator",
|
||||
"Date-Added",
|
||||
"Total-Size",
|
||||
"Poly-Num",
|
||||
"Tags"
|
||||
};
|
||||
|
||||
ModelsBrowser::ModelsBrowser(ModelType modelsType, QWidget* parent) :
|
||||
QWidget(parent),
|
||||
_handler(new ModelHandler(modelsType))
|
||||
{
|
||||
connect(_handler, SIGNAL(doneDownloading()), SLOT(resizeView()));
|
||||
connect(_handler, SIGNAL(updated()), SLOT(resizeView()));
|
||||
|
||||
// Connect handler
|
||||
_handler->connect(this, SIGNAL(startDownloading()), SLOT(download()));
|
||||
_handler->connect(_handler, SIGNAL(doneDownloading()), SLOT(update()));
|
||||
|
@ -86,7 +100,7 @@ void ModelsBrowser::applyFilter(const QString &filter) {
|
|||
for (int k = 0; k < filters.count(); ++k) {
|
||||
match = false;
|
||||
for (int j = 0; j < MODEL_METADATA_COUNT; ++j) {
|
||||
if (model->item(i, j)->text().contains(filters.at(k))) {
|
||||
if (model->item(i, j)->text().contains(filters.at(k), Qt::CaseInsensitive)) {
|
||||
match = true;
|
||||
break;
|
||||
}
|
||||
|
@ -106,6 +120,12 @@ void ModelsBrowser::applyFilter(const QString &filter) {
|
|||
_handler->unlockModel();
|
||||
}
|
||||
|
||||
void ModelsBrowser::resizeView() {
|
||||
for (int i = 0; i < MODEL_METADATA_COUNT; ++i) {
|
||||
_view.resizeColumnToContents(i);
|
||||
}
|
||||
}
|
||||
|
||||
void ModelsBrowser::browse() {
|
||||
QDialog dialog;
|
||||
dialog.setWindowTitle("Browse models");
|
||||
|
@ -145,8 +165,6 @@ ModelHandler::ModelHandler(ModelType modelsType, QWidget* parent) :
|
|||
_initiateExit(false),
|
||||
_type(modelsType)
|
||||
{
|
||||
connect(&_downloader, SIGNAL(done(QNetworkReply::NetworkError)), SLOT(downloadFinished()));
|
||||
|
||||
// set headers data
|
||||
QStringList headerData;
|
||||
for (int i = 0; i < MODEL_METADATA_COUNT; ++i) {
|
||||
|
@ -156,9 +174,6 @@ ModelHandler::ModelHandler(ModelType modelsType, QWidget* parent) :
|
|||
}
|
||||
|
||||
void ModelHandler::download() {
|
||||
// Query models list
|
||||
queryNewFiles();
|
||||
|
||||
_lock.lockForWrite();
|
||||
if (_initiateExit) {
|
||||
_lock.unlock();
|
||||
|
@ -169,10 +184,25 @@ void ModelHandler::download() {
|
|||
loadingItem->setEnabled(false);
|
||||
_model.appendRow(loadingItem);
|
||||
_lock.unlock();
|
||||
|
||||
// Query models list
|
||||
queryNewFiles();
|
||||
}
|
||||
|
||||
void ModelHandler::update() {
|
||||
// Will be implemented in my next PR
|
||||
_lock.lockForWrite();
|
||||
if (_initiateExit) {
|
||||
_lock.unlock();
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < _model.rowCount(); ++i) {
|
||||
QUrl url(_model.item(i,0)->data(Qt::UserRole).toString());
|
||||
QNetworkAccessManager* accessManager = new QNetworkAccessManager(this);
|
||||
QNetworkRequest request(url);
|
||||
accessManager->head(request);
|
||||
connect(accessManager, SIGNAL(finished(QNetworkReply*)), SLOT(downloadFinished(QNetworkReply*)));
|
||||
}
|
||||
_lock.unlock();
|
||||
}
|
||||
|
||||
void ModelHandler::exit() {
|
||||
|
@ -180,7 +210,6 @@ void ModelHandler::exit() {
|
|||
_initiateExit = true;
|
||||
|
||||
// Disconnect everything
|
||||
_downloader.disconnect();
|
||||
disconnect();
|
||||
thread()->disconnect();
|
||||
|
||||
|
@ -191,12 +220,16 @@ void ModelHandler::exit() {
|
|||
_lock.unlock();
|
||||
}
|
||||
|
||||
void ModelHandler::downloadFinished() {
|
||||
if (_downloader.getData().startsWith("<?xml")) {
|
||||
parseXML(_downloader.getData());
|
||||
void ModelHandler::downloadFinished(QNetworkReply* reply) {
|
||||
QByteArray data = reply->readAll();
|
||||
|
||||
if (!data.isEmpty()) {
|
||||
parseXML(data);
|
||||
} else {
|
||||
qDebug() << _downloader.getData();
|
||||
parseHeaders(reply);
|
||||
}
|
||||
reply->deleteLater();
|
||||
sender()->deleteLater();
|
||||
}
|
||||
|
||||
void ModelHandler::queryNewFiles(QString marker) {
|
||||
|
@ -219,7 +252,11 @@ void ModelHandler::queryNewFiles(QString marker) {
|
|||
|
||||
// Download
|
||||
url.setQuery(query);
|
||||
_downloader.download(url);
|
||||
QNetworkAccessManager* accessManager = new QNetworkAccessManager(this);
|
||||
QNetworkRequest request(url);
|
||||
accessManager->get(request);
|
||||
connect(accessManager, SIGNAL(finished(QNetworkReply*)), SLOT(downloadFinished(QNetworkReply*)));
|
||||
|
||||
}
|
||||
|
||||
bool ModelHandler::parseXML(QByteArray xmlFile) {
|
||||
|
@ -266,18 +303,9 @@ bool ModelHandler::parseXML(QByteArray xmlFile) {
|
|||
QList<QStandardItem*> model;
|
||||
model << new QStandardItem(QFileInfo(xml.text().toString()).baseName());
|
||||
model.first()->setData(PUBLIC_URL + "/" + xml.text().toString(), Qt::UserRole);
|
||||
|
||||
// Rand properties for now (Will be taken out in the next PR)
|
||||
static QString creator[] = {"Ryan", "Philip", "Andzrej"};
|
||||
static QString type[] = {"human", "beast", "pet", "elfe"};
|
||||
static QString gender[] = {"male", "female", "none"};
|
||||
model << new QStandardItem(creator[randIntInRange(0, 2)]);
|
||||
model << new QStandardItem(QDate(randIntInRange(2013, 2014),
|
||||
randIntInRange(1, 12),
|
||||
randIntInRange(1, 30)).toString());
|
||||
model << new QStandardItem(type[randIntInRange(0, 3)]);
|
||||
model << new QStandardItem(gender[randIntInRange(0, 2)]);
|
||||
////////////////////////////////////////////////////////////
|
||||
for (int i = 1; i < MODEL_METADATA_COUNT; ++i) {
|
||||
model << new QStandardItem();
|
||||
}
|
||||
|
||||
_model.appendRow(model);
|
||||
}
|
||||
|
@ -312,9 +340,32 @@ bool ModelHandler::parseXML(QByteArray xmlFile) {
|
|||
_lock.unlock();
|
||||
|
||||
if (!truncated) {
|
||||
qDebug() << "Emitting...";
|
||||
emit doneDownloading();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool ModelHandler::parseHeaders(QNetworkReply* reply) {
|
||||
_lock.lockForWrite();
|
||||
|
||||
QList<QStandardItem*> items = _model.findItems(QFileInfo(reply->url().toString()).baseName());
|
||||
if (items.isEmpty() || items.first()->text() == DO_NOT_MODIFY_TAG) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < MODEL_METADATA_COUNT; ++i) {
|
||||
for (int k = 1; k < reply->rawHeaderPairs().count(); ++k) {
|
||||
QString key = reply->rawHeaderPairs().at(k).first.data();
|
||||
QString item = reply->rawHeaderPairs().at(k).second.data();
|
||||
if (key == propertiesIds[i]) {
|
||||
_model.item(_model.indexFromItem(items.first()).row(), i)->setText(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
_lock.unlock();
|
||||
|
||||
emit updated();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,13 +9,10 @@
|
|||
#ifndef __hifi__ModelsBrowser__
|
||||
#define __hifi__ModelsBrowser__
|
||||
|
||||
#include <QAbstractTableModel>
|
||||
#include <QStandardItem>
|
||||
#include <QTreeView>
|
||||
#include <QVector>
|
||||
#include <QReadWriteLock>
|
||||
#include <QStandardItemModel>
|
||||
#include <QTreeView>
|
||||
|
||||
#include "FileDownloader.h"
|
||||
|
||||
enum ModelType {
|
||||
Head,
|
||||
|
@ -33,7 +30,7 @@ public:
|
|||
|
||||
signals:
|
||||
void doneDownloading();
|
||||
void doneUpdating();
|
||||
void updated();
|
||||
|
||||
public slots:
|
||||
void download();
|
||||
|
@ -41,17 +38,17 @@ public slots:
|
|||
void exit();
|
||||
|
||||
private slots:
|
||||
void downloadFinished();
|
||||
void downloadFinished(QNetworkReply* reply);
|
||||
|
||||
private:
|
||||
bool _initiateExit;
|
||||
ModelType _type;
|
||||
FileDownloader _downloader;
|
||||
QReadWriteLock _lock;
|
||||
QStandardItemModel _model;
|
||||
|
||||
void queryNewFiles(QString marker = QString());
|
||||
bool parseXML(QByteArray xmlFile);
|
||||
bool parseHeaders(QNetworkReply* reply);
|
||||
};
|
||||
|
||||
|
||||
|
@ -71,6 +68,7 @@ public slots:
|
|||
|
||||
private slots:
|
||||
void applyFilter(const QString& filter);
|
||||
void resizeView();
|
||||
|
||||
private:
|
||||
ModelHandler* _handler;
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
//
|
||||
// FileDownloader.cpp
|
||||
// hifi
|
||||
//
|
||||
// Created by Clement Brisset on 3/14/14.
|
||||
// Copyright (c) 2014 HighFidelity, Inc. All rights reserved.
|
||||
//
|
||||
//
|
||||
|
||||
#include <QUrl>
|
||||
#include <QNetworkRequest>
|
||||
#include <QEventLoop>
|
||||
#include <QTimer>
|
||||
|
||||
#include "FileDownloader.h"
|
||||
|
||||
FileDownloader::FileDownloader(QObject* parent) : QObject(parent) {
|
||||
connect(&_networkAccessManager, SIGNAL(finished(QNetworkReply*)), SLOT(processReply(QNetworkReply*)));
|
||||
}
|
||||
|
||||
void FileDownloader::download(const QUrl& dataURL, QNetworkAccessManager::Operation operation) {
|
||||
QNetworkRequest request(dataURL);
|
||||
|
||||
_downloadedData.clear();
|
||||
switch (operation) {
|
||||
case QNetworkAccessManager::GetOperation:
|
||||
_networkAccessManager.get(request);
|
||||
break;
|
||||
case QNetworkAccessManager::HeadOperation:
|
||||
_networkAccessManager.head(request);
|
||||
break;
|
||||
default:
|
||||
emit done(QNetworkReply::ProtocolInvalidOperationError);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void FileDownloader::processReply(QNetworkReply *reply) {
|
||||
if (reply->error() == QNetworkReply::NoError) {
|
||||
_downloadedData = reply->readAll();
|
||||
}
|
||||
|
||||
reply->deleteLater();
|
||||
emit done(reply->error());
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
//
|
||||
// FileDownloader.h
|
||||
// hifi
|
||||
//
|
||||
// Created by Clement Brisset on 3/14/14.
|
||||
// Copyright (c) 2014 HighFidelity, Inc. All rights reserved.
|
||||
//
|
||||
//
|
||||
|
||||
#ifndef __hifi__FileDownloader__
|
||||
#define __hifi__FileDownloader__
|
||||
|
||||
#include <QObject>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkReply>
|
||||
#include <QThread>
|
||||
|
||||
class FileDownloader : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FileDownloader(QObject* parent = NULL);
|
||||
QByteArray getData() const { return _downloadedData; }
|
||||
|
||||
|
||||
signals:
|
||||
void done(QNetworkReply::NetworkError error);
|
||||
|
||||
public slots:
|
||||
void download(const QUrl& dataURL, QNetworkAccessManager::Operation operation = QNetworkAccessManager::GetOperation);
|
||||
|
||||
private slots:
|
||||
void processReply(QNetworkReply* reply);
|
||||
|
||||
private:
|
||||
QNetworkAccessManager _networkAccessManager;
|
||||
QByteArray _downloadedData;
|
||||
};
|
||||
|
||||
|
||||
#endif /* defined(__hifi__FileDownloader__) */
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// FstReader.cpp
|
||||
// ModelUploader.cpp
|
||||
// hifi
|
||||
//
|
||||
// Created by Clément Brisset on 3/4/14.
|
||||
|
@ -18,7 +18,7 @@
|
|||
#include <QMessageBox>
|
||||
|
||||
#include "AccountManager.h"
|
||||
#include "FstReader.h"
|
||||
#include "ModelUploader.h"
|
||||
|
||||
|
||||
static const QString NAME_FIELD = "name";
|
||||
|
@ -38,7 +38,7 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
FstReader::FstReader(bool isHead) :
|
||||
ModelUploader::ModelUploader(bool isHead) :
|
||||
_zipDir(new TemporaryDir()),
|
||||
_lodCount(-1),
|
||||
_texturesCount(-1),
|
||||
|
@ -51,11 +51,11 @@ FstReader::FstReader(bool isHead) :
|
|||
|
||||
}
|
||||
|
||||
FstReader::~FstReader() {
|
||||
ModelUploader::~ModelUploader() {
|
||||
delete _dataMultiPart;
|
||||
}
|
||||
|
||||
bool FstReader::zip() {
|
||||
bool ModelUploader::zip() {
|
||||
// File Dialog
|
||||
QString filename = QFileDialog::getOpenFileName(NULL,
|
||||
"Select your .fst file ...",
|
||||
|
@ -167,20 +167,41 @@ bool FstReader::zip() {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool FstReader::send() {
|
||||
bool ModelUploader::send() {
|
||||
if (!_readyToSend) {
|
||||
return false;
|
||||
}
|
||||
|
||||
AccountManager::getInstance().authenticatedRequest(MODEL_URL, QNetworkAccessManager::PostOperation, JSONCallbackParameters(), QByteArray(), _dataMultiPart);
|
||||
JSONCallbackParameters callbackParams;
|
||||
callbackParams.jsonCallbackReceiver = this;
|
||||
callbackParams.jsonCallbackMethod = "uploadSuccess";
|
||||
callbackParams.errorCallbackReceiver = this;
|
||||
callbackParams.errorCallbackMethod = "uploadFailed";
|
||||
|
||||
AccountManager::getInstance().authenticatedRequest(MODEL_URL, QNetworkAccessManager::PostOperation, callbackParams, QByteArray(), _dataMultiPart);
|
||||
_zipDir = NULL;
|
||||
_dataMultiPart = NULL;
|
||||
qDebug() << "Model sent.";
|
||||
qDebug() << "Sending model...";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FstReader::addTextures(const QFileInfo& texdir) {
|
||||
void ModelUploader::uploadSuccess(const QJsonObject& jsonResponse) {
|
||||
qDebug() << "Model sent with success to the data server.";
|
||||
qDebug() << "It might take a few minute for it to appear in your model browser.";
|
||||
deleteLater();
|
||||
}
|
||||
|
||||
void ModelUploader::uploadFailed(QNetworkReply::NetworkError errorCode, const QString& errorString) {
|
||||
QMessageBox::warning(NULL,
|
||||
QString("ModelUploader::uploadFailed()"),
|
||||
QString("Model could not be sent to the data server."),
|
||||
QMessageBox::Ok);
|
||||
qDebug() << "Model upload failed (" << errorCode << "): " << errorString;
|
||||
deleteLater();
|
||||
}
|
||||
|
||||
bool ModelUploader::addTextures(const QFileInfo& texdir) {
|
||||
QStringList filter;
|
||||
filter << "*.png" << "*.tif" << "*.jpg" << "*.jpeg";
|
||||
|
||||
|
@ -209,7 +230,7 @@ bool FstReader::addTextures(const QFileInfo& texdir) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool FstReader::compressFile(const QString &inFileName, const QString &outFileName) {
|
||||
bool ModelUploader::compressFile(const QString &inFileName, const QString &outFileName) {
|
||||
QFile inFile(inFileName);
|
||||
inFile.open(QIODevice::ReadOnly);
|
||||
QByteArray buffer = inFile.readAll();
|
||||
|
@ -233,7 +254,7 @@ bool FstReader::compressFile(const QString &inFileName, const QString &outFileNa
|
|||
}
|
||||
|
||||
|
||||
bool FstReader::addPart(const QString &path, const QString& name) {
|
||||
bool ModelUploader::addPart(const QString &path, const QString& name) {
|
||||
QFile* file = new QFile(path);
|
||||
if (!file->open(QIODevice::ReadOnly)) {
|
||||
QMessageBox::warning(NULL,
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// FstReader.h
|
||||
// ModelUploader.h
|
||||
// hifi
|
||||
//
|
||||
// Created by Clément Brisset on 3/4/14.
|
||||
|
@ -7,20 +7,27 @@
|
|||
//
|
||||
//
|
||||
|
||||
#ifndef __hifi__FstReader__
|
||||
#define __hifi__FstReader__
|
||||
#ifndef __hifi__ModelUploader__
|
||||
#define __hifi__ModelUploader__
|
||||
|
||||
class TemporaryDir;
|
||||
class QHttpMultiPart;
|
||||
class QFileInfo;
|
||||
|
||||
class FstReader : public QObject {
|
||||
class ModelUploader : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FstReader(bool isHead);
|
||||
~FstReader();
|
||||
ModelUploader(bool isHead);
|
||||
~ModelUploader();
|
||||
|
||||
bool zip();
|
||||
bool send();
|
||||
|
||||
private slots:
|
||||
void uploadSuccess(const QJsonObject& jsonResponse);
|
||||
void uploadFailed(QNetworkReply::NetworkError errorCode, const QString& errorString);
|
||||
|
||||
private:
|
||||
TemporaryDir* _zipDir;
|
||||
int _lodCount;
|
||||
|
@ -37,4 +44,4 @@ private:
|
|||
bool addPart(const QString& path, const QString& name);
|
||||
};
|
||||
|
||||
#endif /* defined(__hifi__FstReader__) */
|
||||
#endif /* defined(__hifi__ModelUploader__) */
|
Loading…
Reference in a new issue