History

Persist the user orientation as well as the position, show up a couple meters in front of (and facing) target. Closes #1367.

Andrzej Kapolka committed 12 years ago

Commit 2d5df381 parent 68eb1f76 files · +53 −12Browse files

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

Unified · Split

interface/src/DataServerClient.cpp+17−7
@@ -175,25 +175,35 @@ 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]);
193196
194− glm::vec3 newPosition(coordinateItems[0].toFloat(),
195− coordinateItems[1].toFloat(),
196− coordinateItems[2].toFloat());
197+ // orient the user to face the target
198+ glm::quat newOrientation = glm::quat(glm::radians(glm::vec3(orientationItems[0].toFloat(),
199+ orientationItems[1].toFloat(), orientationItems[2].toFloat()))) *
200+ glm::angleAxis(180.0f, 0.0f, 1.0f, 0.0f);
201+ Application::getInstance()->getAvatar()->setOrientation(newOrientation);
202+
203+ // move the user a couple units away
204+ const float DISTANCE_TO_USER = 2.0f;
205+ glm::vec3 newPosition = glm::vec3(coordinateItems[0].toFloat(), coordinateItems[1].toFloat(),
206+ coordinateItems[2].toFloat()) - newOrientation * IDENTITY_FRONT * DISTANCE_TO_USER;
197207 Application::getInstance()->getAvatar()->setPosition(newPosition);
198208 }
199209