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
175 }175 }
176 }176 }
177 }177 }
178 } else if (keyList[i] == DataServerKey::Domain && keyList[i + 1] == DataServerKey::Position178 } else if (keyList[i] == DataServerKey::Domain && keyList[i + 1] == DataServerKey::Position &&
179 && valueList[i] != " " && valueList[i + 1] != " ") {179 keyList[i + 2] == DataServerKey::Orientation && valueList[i] != " " &&
180 valueList[i + 1] != " " && valueList[i + 2] != " ") {
180 181
181 QStringList coordinateItems = valueList[i + 1].split(',');182 QStringList coordinateItems = valueList[i + 1].split(',');
183 QStringList orientationItems = valueList[i + 2].split(',');
182 184
183 if (coordinateItems.size() == 3) {185 if (coordinateItems.size() == 3 && orientationItems.size() == 3) {
184 186
185 // send a node kill request, indicating to other clients that they should play the "disappeared" effect187 // send a node kill request, indicating to other clients that they should play the "disappeared" effect
186 NodeList::getInstance()->sendKillNode(&NODE_TYPE_AVATAR_MIXER, 1);188 NodeList::getInstance()->sendKillNode(&NODE_TYPE_AVATAR_MIXER, 1);
187 189
188 qDebug() << "Changing domain to" << valueList[i].toLocal8Bit().constData() <<190 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() <<
190 "to go to" << userString << "\n";193 "to go to" << userString << "\n";
191 194
192 NodeList::getInstance()->setDomainHostname(valueList[i]);195 NodeList::getInstance()->setDomainHostname(valueList[i]);
193 196
194 glm::vec3 newPosition(coordinateItems[0].toFloat(),197 // orient the user to face the target
195 coordinateItems[1].toFloat(),198 glm::quat newOrientation = glm::quat(glm::radians(glm::vec3(orientationItems[0].toFloat(),
196 coordinateItems[2].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;
197 Application::getInstance()->getAvatar()->setPosition(newPosition);207 Application::getInstance()->getAvatar()->setPosition(newPosition);
198 }208 }
199 209