mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 14:58:03 +02:00
add support for billboard setting from URL
This commit is contained in:
parent
039f9ff1e3
commit
f2a70bf275
2 changed files with 39 additions and 1 deletions
|
@ -11,6 +11,9 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include <QtCore/QDataStream>
|
#include <QtCore/QDataStream>
|
||||||
|
#include <QtNetwork/QNetworkAccessManager>
|
||||||
|
#include <QtNetwork/QNetworkReply>
|
||||||
|
#include <QtNetwork/QNetworkRequest>
|
||||||
|
|
||||||
#include <NodeList.h>
|
#include <NodeList.h>
|
||||||
#include <PacketHeaders.h>
|
#include <PacketHeaders.h>
|
||||||
|
@ -24,6 +27,8 @@ using namespace std;
|
||||||
|
|
||||||
static const float fingerVectorRadix = 4; // bits of precision when converting from float<->fixed
|
static const float fingerVectorRadix = 4; // bits of precision when converting from float<->fixed
|
||||||
|
|
||||||
|
QNetworkAccessManager* AvatarData::networkAccessManager = NULL;
|
||||||
|
|
||||||
AvatarData::AvatarData() :
|
AvatarData::AvatarData() :
|
||||||
NodeData(),
|
NodeData(),
|
||||||
_handPosition(0,0,0),
|
_handPosition(0,0,0),
|
||||||
|
@ -338,6 +343,28 @@ void AvatarData::setBillboard(const QByteArray& billboard) {
|
||||||
qDebug() << "Changing billboard for avatar.";
|
qDebug() << "Changing billboard for avatar.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AvatarData::setBillboardFromURL(const QString &billboardURL) {
|
||||||
|
_billboardURL = billboardURL;
|
||||||
|
|
||||||
|
if (AvatarData::networkAccessManager) {
|
||||||
|
qDebug() << "Changing billboard for avatar to PNG at" << qPrintable(billboardURL);
|
||||||
|
|
||||||
|
QNetworkRequest billboardRequest;
|
||||||
|
billboardRequest.setUrl(QUrl(billboardURL));
|
||||||
|
|
||||||
|
QNetworkReply* networkReply = AvatarData::networkAccessManager->get(billboardRequest);
|
||||||
|
connect(networkReply, SIGNAL(finished()), this, SLOT(setBillboardFromNetworkReply()));
|
||||||
|
|
||||||
|
} else {
|
||||||
|
qDebug() << "Billboard PNG download requested but no network access manager is available.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AvatarData::setBillboardFromNetworkReply() {
|
||||||
|
QNetworkReply* networkReply = reinterpret_cast<QNetworkReply*>(sender());
|
||||||
|
setBillboard(networkReply->readAll());
|
||||||
|
}
|
||||||
|
|
||||||
void AvatarData::setClampedTargetScale(float targetScale) {
|
void AvatarData::setClampedTargetScale(float targetScale) {
|
||||||
|
|
||||||
targetScale = glm::clamp(targetScale, MIN_AVATAR_SCALE, MAX_AVATAR_SCALE);
|
targetScale = glm::clamp(targetScale, MIN_AVATAR_SCALE, MAX_AVATAR_SCALE);
|
||||||
|
|
|
@ -68,6 +68,8 @@ enum KeyState {
|
||||||
|
|
||||||
const glm::vec3 vec3Zero(0.0f);
|
const glm::vec3 vec3Zero(0.0f);
|
||||||
|
|
||||||
|
class QNetworkAccessManager;
|
||||||
|
|
||||||
class AvatarData : public NodeData {
|
class AvatarData : public NodeData {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -88,6 +90,7 @@ class AvatarData : public NodeData {
|
||||||
|
|
||||||
Q_PROPERTY(QString faceModelURL READ getFaceModelURLFromScript WRITE setFaceModelURLFromScript)
|
Q_PROPERTY(QString faceModelURL READ getFaceModelURLFromScript WRITE setFaceModelURLFromScript)
|
||||||
Q_PROPERTY(QString skeletonModelURL READ getSkeletonModelURLFromScript WRITE setSkeletonModelURLFromScript)
|
Q_PROPERTY(QString skeletonModelURL READ getSkeletonModelURLFromScript WRITE setSkeletonModelURLFromScript)
|
||||||
|
Q_PROPERTY(QString billboardURL READ getBillboardURL WRITE setBillboardFromURL)
|
||||||
public:
|
public:
|
||||||
AvatarData();
|
AvatarData();
|
||||||
~AvatarData();
|
~AvatarData();
|
||||||
|
@ -170,6 +173,9 @@ public:
|
||||||
virtual void setBillboard(const QByteArray& billboard);
|
virtual void setBillboard(const QByteArray& billboard);
|
||||||
const QByteArray& getBillboard() const { return _billboard; }
|
const QByteArray& getBillboard() const { return _billboard; }
|
||||||
|
|
||||||
|
void setBillboardFromURL(const QString& billboardURL);
|
||||||
|
const QString& getBillboardURL() { return _billboardURL; }
|
||||||
|
|
||||||
QString getFaceModelURLFromScript() const { return _faceModelURL.toString(); }
|
QString getFaceModelURLFromScript() const { return _faceModelURL.toString(); }
|
||||||
void setFaceModelURLFromScript(const QString& faceModelString) { setFaceModelURL(faceModelString); }
|
void setFaceModelURLFromScript(const QString& faceModelString) { setFaceModelURL(faceModelString); }
|
||||||
|
|
||||||
|
@ -178,10 +184,12 @@ public:
|
||||||
|
|
||||||
virtual float getBoundingRadius() const { return 1.f; }
|
virtual float getBoundingRadius() const { return 1.f; }
|
||||||
|
|
||||||
|
static void setNetworkAccessManager(QNetworkAccessManager* sharedAccessManager) { networkAccessManager = sharedAccessManager; }
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void sendIdentityPacket();
|
void sendIdentityPacket();
|
||||||
void sendBillboardPacket();
|
void sendBillboardPacket();
|
||||||
|
void setBillboardFromNetworkReply();
|
||||||
protected:
|
protected:
|
||||||
glm::vec3 _position;
|
glm::vec3 _position;
|
||||||
glm::vec3 _handPosition;
|
glm::vec3 _handPosition;
|
||||||
|
@ -217,6 +225,9 @@ protected:
|
||||||
float _displayNameAlpha;
|
float _displayNameAlpha;
|
||||||
|
|
||||||
QByteArray _billboard;
|
QByteArray _billboard;
|
||||||
|
QString _billboardURL;
|
||||||
|
|
||||||
|
static QNetworkAccessManager* networkAccessManager;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// privatize the copy constructor and assignment operator so they cannot be called
|
// privatize the copy constructor and assignment operator so they cannot be called
|
||||||
|
|
Loading…
Reference in a new issue