mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-05 03:26:15 +02:00
hook old data server functionality through profile
This commit is contained in:
parent
cf40fb0ef8
commit
0ac5ec0690
1 changed files with 74 additions and 1 deletions
|
@ -147,7 +147,80 @@ void Profile::loadData(QSettings* settings) {
|
|||
}
|
||||
|
||||
void Profile::processDataServerResponse(const QString& userString, const QStringList& keyList, const QStringList& valueList) {
|
||||
qDebug() << "Called with" << keyList << valueList;
|
||||
for (int i = 0; i < keyList.size(); i++) {
|
||||
if (valueList[i] != " ") {
|
||||
if (keyList[i] == DataServerKey::FaceMeshURL) {
|
||||
if (userString == _username || userString == uuidStringWithoutCurlyBraces(_uuid)) {
|
||||
qDebug("Changing user's face model URL to %s", valueList[i].toLocal8Bit().constData());
|
||||
Application::getInstance()->getProfile()->setFaceModelURL(QUrl(valueList[i]));
|
||||
} else {
|
||||
// mesh URL for a UUID, find avatar in our list
|
||||
|
||||
foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) {
|
||||
if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) {
|
||||
Avatar* avatar = (Avatar *) node->getLinkedData();
|
||||
|
||||
if (avatar->getUUID() == QUuid(userString)) {
|
||||
QMetaObject::invokeMethod(&avatar->getHead().getFaceModel(),
|
||||
"setURL", Q_ARG(QUrl, QUrl(valueList[i])));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (keyList[i] == DataServerKey::SkeletonURL) {
|
||||
if (userString == _username || userString == uuidStringWithoutCurlyBraces(_uuid)) {
|
||||
qDebug("Changing user's skeleton URL to %s", valueList[i].toLocal8Bit().constData());
|
||||
Application::getInstance()->getProfile()->setSkeletonModelURL(QUrl(valueList[i]));
|
||||
} else {
|
||||
// skeleton URL for a UUID, find avatar in our list
|
||||
foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) {
|
||||
if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) {
|
||||
Avatar* avatar = (Avatar *) node->getLinkedData();
|
||||
|
||||
if (avatar->getUUID() == QUuid(userString)) {
|
||||
QMetaObject::invokeMethod(&avatar->getSkeletonModel(), "setURL",
|
||||
Q_ARG(QUrl, QUrl(valueList[i])));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (keyList[i] == DataServerKey::Domain && keyList[i + 1] == DataServerKey::Position &&
|
||||
keyList[i + 2] == DataServerKey::Orientation && valueList[i] != " " &&
|
||||
valueList[i + 1] != " " && valueList[i + 2] != " ") {
|
||||
|
||||
QStringList coordinateItems = valueList[i + 1].split(',');
|
||||
QStringList orientationItems = valueList[i + 2].split(',');
|
||||
|
||||
if (coordinateItems.size() == 3 && orientationItems.size() == 3) {
|
||||
|
||||
// send a node kill request, indicating to other clients that they should play the "disappeared" effect
|
||||
NodeList::getInstance()->sendKillNode(&NODE_TYPE_AVATAR_MIXER, 1);
|
||||
|
||||
qDebug() << "Changing domain to" << valueList[i].toLocal8Bit().constData() <<
|
||||
", position to" << valueList[i + 1].toLocal8Bit().constData() <<
|
||||
", and orientation to" << valueList[i + 2].toLocal8Bit().constData() <<
|
||||
"to go to" << userString;
|
||||
|
||||
NodeList::getInstance()->setDomainHostname(valueList[i]);
|
||||
// orient the user to face the target
|
||||
glm::quat newOrientation = glm::quat(glm::radians(glm::vec3(orientationItems[0].toFloat(),
|
||||
orientationItems[1].toFloat(), orientationItems[2].toFloat()))) *
|
||||
glm::angleAxis(180.0f, 0.0f, 1.0f, 0.0f);
|
||||
Application::getInstance()->getAvatar()->setOrientation(newOrientation);
|
||||
|
||||
// move the user a couple units away
|
||||
const float DISTANCE_TO_USER = 2.0f;
|
||||
glm::vec3 newPosition = glm::vec3(coordinateItems[0].toFloat(), coordinateItems[1].toFloat(),
|
||||
coordinateItems[2].toFloat()) - newOrientation * IDENTITY_FRONT * DISTANCE_TO_USER;
|
||||
Application::getInstance()->getAvatar()->setPosition(newPosition);
|
||||
}
|
||||
|
||||
} else if (keyList[i] == DataServerKey::UUID) {
|
||||
// this is the user's UUID - set it on the profile
|
||||
_uuid = QUuid(valueList[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Profile::setUsername(const QString& username) {
|
||||
|
|
Loading…
Reference in a new issue