From 37ba6219e6380fd1b357835dada38786d2c0337c Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 21 Feb 2014 17:04:03 -0800 Subject: [PATCH] hook up go to for HTTP data-server --- interface/src/avatar/MyAvatar.cpp | 35 ++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 5c81ca3cb1..cd3594da09 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -1201,5 +1201,38 @@ void MyAvatar::updateLocationInDataServer() { } void MyAvatar::goToLocationFromResponse(const QJsonObject& jsonObject) { - qDebug() << jsonObject; + + if (jsonObject["status"].toString() == "success") { + + // send a node kill request, indicating to other clients that they should play the "disappeared" effect + sendKillAvatar(); + + QJsonObject locationObject = jsonObject["data"].toObject()["location"].toObject(); + QString positionString = locationObject["position"].toString(); + QString orientationString = locationObject["orientation"].toString(); + QString domainHostnameString = locationObject["domain"].toString(); + + qDebug() << "Changing domain to" << domainHostnameString << + ", position to" << positionString << + ", and orientation to" << orientationString; + + QStringList coordinateItems = positionString.split(','); + QStringList orientationItems = orientationString.split(','); + + NodeList::getInstance()->getDomainInfo().setHostname(domainHostnameString); + + // 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); + 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; + setPosition(newPosition); + } + }