History

Merge branch 'master' of git://github.com/worklist/hifi into windows_build

Brad Hefta-Gaub committed 12 years ago

Commit 392ff942 parents b947d1e 0f2aa6c11 files · +95 −53Browse files

Showing the changes to interface/src/DataServerClient.cpp (1 of 11 files). Show all

Unified · Split

interface/src/DataServerClient.cpp+17−8
@@ -175,25 +175,34 @@ void DataServerClient::processSendFromDataServer(unsigned char* packetData, int · 174 unmodified lines
175175 }
176176 }
177177 }
178− } else if (keyList[i] == DataServerKey::Domain && keyList[i + 1] == DataServerKey::Position
179− && valueList[i] != " " && valueList[i + 1] != " ") {
178+ } else if (keyList[i] == DataServerKey::Domain && keyList[i + 1] == DataServerKey::Position &&
179+ keyList[i + 2] == DataServerKey::Orientation && valueList[i] != " " &&
180+ valueList[i + 1] != " " && valueList[i + 2] != " ") {
180181
181182 QStringList coordinateItems = valueList[i + 1].split(',');
183+ QStringList orientationItems = valueList[i + 2].split(',');
182184
183− if (coordinateItems.size() == 3) {
185+ if (coordinateItems.size() == 3 && orientationItems.size() == 3) {
184186
185187 // send a node kill request, indicating to other clients that they should play the "disappeared" effect
186188 NodeList::getInstance()->sendKillNode(&NODE_TYPE_AVATAR_MIXER, 1);
187189
188190 qDebug() << "Changing domain to" << valueList[i].toLocal8Bit().constData() <<
189− "and position to" << valueList[i + 1].toLocal8Bit().constData() <<
191+ ", position to" << valueList[i + 1].toLocal8Bit().constData() <<
192+ ", and orientation to" << valueList[i + 2].toLocal8Bit().constData() <<
190193 "to go to" << userString << "\n";
191194
192195 NodeList::getInstance()->setDomainHostname(valueList[i]);
193−
194− glm::vec3 newPosition(coordinateItems[0].toFloat(),
195− coordinateItems[1].toFloat(),
196− coordinateItems[2].toFloat());
196+ // orient the user to face the target
197+ glm::quat newOrientation = glm::quat(glm::radians(glm::vec3(orientationItems[0].toFloat(),
198+ orientationItems[1].toFloat(), orientationItems[2].toFloat()))) *
199+ glm::angleAxis(180.0f, 0.0f, 1.0f, 0.0f);
200+ Application::getInstance()->getAvatar()->setOrientation(newOrientation);
201+
202+ // move the user a couple units away
203+ const float DISTANCE_TO_USER = 2.0f;
204+ glm::vec3 newPosition = glm::vec3(coordinateItems[0].toFloat(), coordinateItems[1].toFloat(),
205+ coordinateItems[2].toFloat()) - newOrientation * IDENTITY_FRONT * DISTANCE_TO_USER;
197206 Application::getInstance()->getAvatar()->setPosition(newPosition);
198207 }
199208