bool decodeTimedMotionQuat(v8::Handle<v8::Value> orientationQuat,v8::Handle<v8::Value> orientationVelQuat,v8::Handle<v8::Value> toDecodeTimeAsString, TimedMotionQuaternion& toDecodeTo, String& errorMessage) { //decode orientation bool isQuat =QuaternionValValidate(orientationQuat); if (! isQuat) { errorMessage += "Could not convert orientation to a quaternion. "; return false; } Quaternion orientation = QuaternionValExtract(orientationQuat); //decode orientation velocity isQuat = QuaternionValValidate(orientationVelQuat); if (! isQuat) { errorMessage += "Could not convert orientation velocity to a quaternion. "; return false; } Quaternion orientationVel = QuaternionValExtract(orientationVelQuat); //decode time. Time decodedTime; bool timeDecoded = decodeTimeFromString(toDecodeTimeAsString,decodedTime,errorMessage); if (! timeDecoded) { errorMessage += "Could not convert value to a time when deconding timed motion vector. "; return false; } MotionQuaternion motQuat(orientation,orientationVel); toDecodeTo = TimedMotionQuaternion(decodedTime,motQuat); return true; }
TimedMotionQuaternion LocProtocolLocUpdate::orientation() const { Sirikata::Protocol::TimedMotionQuaternion update_orient = mUpdate.orientation(); return TimedMotionQuaternion( mSync.localTime(update_orient.t()), MotionQuaternion(update_orient.position(), update_orient.velocity()) ); }
void ProxyObject::setOrientation(const TimedMotionQuaternion& reqorient, uint64 seqno, bool predictive) { if (seqno < mUpdateSeqno[LOC_ORIENT_PART] && !predictive) return; if (!predictive) mUpdateSeqno[LOC_ORIENT_PART] = seqno; mOrientation = TimedMotionQuaternion(reqorient.time(), MotionQuaternion(reqorient.position(), reqorient.velocity())); PositionProvider::notify(&PositionListener::updateLocation, mLoc, mOrientation, mBounds); }
bool HostedObject::objectHostConnect(const SpaceID spaceID, const Location startingLocation, const BoundingSphere3f meshBounds, const String mesh, const String physics, const String query, const String zernike, const ObjectReference orefID, PresenceToken token) { ObjectReference oref = (orefID == ObjectReference::null()) ? ObjectReference(UUID::random()) : orefID; SpaceObjectReference connectingSporef (spaceID,oref); // Note: we always use Time::null() here. The server will fill in the // appropriate value. When we get the callback, we can fix this up. Time approx_server_time = Time::null(); if (mObjectHost->connect( getSharedPtr(), connectingSporef, spaceID, TimedMotionVector3f(approx_server_time, MotionVector3f( Vector3f(startingLocation.getPosition()), startingLocation.getVelocity()) ), TimedMotionQuaternion(approx_server_time,MotionQuaternion(startingLocation.getOrientation().normal(),Quaternion(startingLocation.getAxisOfRotation(),startingLocation.getAngularSpeed()))), //normalize orientations meshBounds, mesh, physics, query, zernike, std::tr1::bind(&HostedObject::handleConnected, getWeakPtr(), mObjectHost, _1, _2, _3), std::tr1::bind(&HostedObject::handleMigrated, getWeakPtr(), _1, _2, _3), std::tr1::bind(&HostedObject::handleStreamCreated, getWeakPtr(), _1, _2, token), std::tr1::bind(&HostedObject::handleDisconnected, getWeakPtr(), _1, _2) )) { mObjectHost->registerHostedObject(connectingSporef,getSharedPtr()); return true; }else { return false; } }