Contains the variables sent in an object update packet for objects. Used to track position and movement of prims and avatars
コード例 #1
0
 private void OnMovingTowards_OnObjectUpdated(Simulator simulator, ObjectUpdate update, ulong regionHandle, ushort timeDilation)
 {
     if (update.LocalID == Mover.LocalID)
     {
         UpdateAll();
     }
     else
     {
         Primitive prim = Client.WorldSystem.GetPrimitive(update.LocalID);
         if (IsFacing(prim))
         {
             if (!MoverFaceing.Contains(prim))
                 MoverFaceing.Add(prim);
         }
         else
         {
             if (MoverFaceing.Contains(prim))
                 MoverFaceing.Remove(prim);
         }
     }
 }
コード例 #2
0
        /// <summary>
        /// A terse object update, used when a transformation matrix or
        /// velocity/acceleration for an object changes but nothing else
        /// (scale/position/rotation/acceleration/velocity)
        /// </summary>
        /// <param name="packet"></param>
        /// <param name="simulator"></param>
        protected void TerseUpdateHandler(Packet packet, Simulator simulator)
        {
            ImprovedTerseObjectUpdatePacket terse = (ImprovedTerseObjectUpdatePacket)packet;
            UpdateDilation(simulator, terse.RegionData.TimeDilation);

            for (int i = 0; i < terse.ObjectData.Length; i++)
            {
                ImprovedTerseObjectUpdatePacket.ObjectDataBlock block = terse.ObjectData[i];

                try
                {
                    int pos = 4;
                    uint localid = Utils.BytesToUInt(block.Data, 0);

                    // Check if we are interested in this update
                    if (!Client.Settings.ALWAYS_DECODE_OBJECTS && localid != Client.Self.localID && OnObjectUpdated == null)
                        continue;

                    #region Decode update data

                    ObjectUpdate update = new ObjectUpdate();

                    // LocalID
                    update.LocalID = localid;
                    // State
                    update.State = block.Data[pos++];
                    // Avatar boolean
                    update.Avatar = (block.Data[pos++] != 0);
                    // Collision normal for avatar
                    if (update.Avatar)
                    {
                        update.CollisionPlane = new Vector4(block.Data, pos);
                        pos += 16;
                    }
                    // Position
                    update.Position = new Vector3(block.Data, pos);
                    pos += 12;
                    // Velocity
                    update.Velocity = new Vector3(
                        Utils.UInt16ToFloat(block.Data, pos, -128.0f, 128.0f),
                        Utils.UInt16ToFloat(block.Data, pos + 2, -128.0f, 128.0f),
                        Utils.UInt16ToFloat(block.Data, pos + 4, -128.0f, 128.0f));
                    pos += 6;
                    // Acceleration
                    update.Acceleration = new Vector3(
                        Utils.UInt16ToFloat(block.Data, pos, -64.0f, 64.0f),
                        Utils.UInt16ToFloat(block.Data, pos + 2, -64.0f, 64.0f),
                        Utils.UInt16ToFloat(block.Data, pos + 4, -64.0f, 64.0f));
                    pos += 6;
                    // Rotation (theta)
                    update.Rotation = new Quaternion(
                        Utils.UInt16ToFloat(block.Data, pos, -1.0f, 1.0f),
                        Utils.UInt16ToFloat(block.Data, pos + 2, -1.0f, 1.0f),
                        Utils.UInt16ToFloat(block.Data, pos + 4, -1.0f, 1.0f),
                        Utils.UInt16ToFloat(block.Data, pos + 6, -1.0f, 1.0f));
                    pos += 8;
                    // Angular velocity
                    update.AngularVelocity = new Vector3(
                        Utils.UInt16ToFloat(block.Data, pos, -64.0f, 64.0f),
                        Utils.UInt16ToFloat(block.Data, pos + 2, -64.0f, 64.0f),
                        Utils.UInt16ToFloat(block.Data, pos + 4, -64.0f, 64.0f));
                    pos += 6;

                    // Textures
                    // FIXME: Why are we ignoring the first four bytes here?
                    if (block.TextureEntry.Length != 0)
                        update.Textures = new Primitive.TextureEntry(block.TextureEntry, 4, block.TextureEntry.Length - 4);

                    #endregion Decode update data

                    Primitive obj = (update.Avatar) ?
                        (Primitive)GetAvatar(simulator, update.LocalID, UUID.Zero):
                        (Primitive)GetPrimitive(simulator, update.LocalID, UUID.Zero);

                    #region Update Client.Self
                    if (update.LocalID == Client.Self.localID)
                    {
                        Client.Self.collisionPlane = update.CollisionPlane;
                        Client.Self.relativePosition = update.Position;
                        Client.Self.velocity = update.Velocity;
                        Client.Self.acceleration = update.Acceleration;
                        Client.Self.relativeRotation = update.Rotation;
                        Client.Self.angularVelocity = update.AngularVelocity;
                    }
                    #endregion Update Client.Self

                    obj.Acceleration = update.Acceleration;
                    obj.AngularVelocity = update.AngularVelocity;
                    obj.CollisionPlane = update.CollisionPlane;
                    obj.Position = update.Position;
                    obj.Rotation = update.Rotation;
                    obj.Velocity = update.Velocity;
                    if (update.Textures != null)
                        obj.Textures = update.Textures;

                    // Fire the callback
                    FireOnObjectUpdated(simulator, update, terse.RegionData.RegionHandle, terse.RegionData.TimeDilation);
                }
                catch (Exception e)
                {
                    Logger.Log(e.Message, Helpers.LogLevel.Warning, Client, e);
                }
            }
        }
コード例 #3
0
 protected void FireOnObjectUpdated(Simulator simulator, ObjectUpdate update, ulong RegionHandle, ushort TimeDilation)
 {
     if (OnObjectUpdated != null)
     {
         try { OnObjectUpdated(simulator, update, RegionHandle, TimeDilation); }
         catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, Client, e); }
     }
 }
コード例 #4
0
ファイル: ObjectPathTracer.cs プロジェクト: ewencp/sltrace
 private void StoreLocationUpdate(Primitive prim, ObjectUpdate update)
 {
     StoreLocationUpdate(prim, update.Position, update.Velocity, update.Rotation, update.AngularVelocity);
 }
コード例 #5
0
ファイル: ObjectPathTracer.cs プロジェクト: ewencp/sltrace
 private void ObjectUpdatedTerseHandler(Simulator simulator, Primitive prim, ObjectUpdate update, ulong regionHandle, ushort timeDilation)
 {
     CheckMembership(simulator, "terse", prim);
     StoreLocationUpdate(prim, update);
 }
コード例 #6
0
ファイル: ObjectPathTracer.cs プロジェクト: ewencp/sltrace
 private void ObjectDataBlockUpdateHandler(Simulator simulator, Primitive prim, Primitive.ConstructionData constructionData, ObjectUpdatePacket.ObjectDataBlock block, ObjectUpdate update, NameValue[] nameValues)
 {
     // Note: We can't do membership or really much useful here since the
     // primitive doesn't have its information filled in quite yet.  Instead,
     // we're forced to use the OnNew* events, which get called *after* all
     // the data has been filled in.
     //Console.WriteLine("Object: " + update.LocalID.ToString() + " - " + update.Position.ToString() + " " + update.Velocity.ToString());
 }
コード例 #7
0
        private void OnSelfUpdated(Simulator simulator, ObjectUpdate update, ulong regionhandle)
        {
            lock (_lastKnownPosLock)
            {
                if (_lastKnownSimPostion == Vector3.Zero)
                {
                    _lastKnownSimPostion = update.Position;
                    return;
                }
                if (Vector3.Distance(update.Position, _lastKnownSimPostion) < 8) return;
                _lastKnownSimPostion = update.Position;
            }

            List<SimulatorCull> simCulls = null;
            List<SimPatchInfo> sendpatches = new List<SimPatchInfo>();
            lock (SimulatorCullings)
            {
                simCulls = new List<SimulatorCull>(SimulatorCullings.Values);
            }

            foreach (SimulatorCull sc in simCulls)
            {
                lock (sc)
                {
                    foreach (var p in sc.PatchesCulled)
                    {

                        if (Vector3d.Distance(CameraPosition, p.pos) < LandSightDistance)
                        {
                            sendpatches.Add(p);
                        }
                    }
                    foreach (var p in sendpatches)
                    {
                        sc.PatchesCulled.Remove(p);
                        sc.PatchesSent.Add(p);
                    }
                }
            }
            foreach (var p in sendpatches)
            {
                landPatchCallback(p.simulator, p.x, p.y, p.width, p.data);
            }

            if (!ObjectsToManagedLayerIsRangeBased) return;

            foreach (SimulatorCull sc in simCulls)
            {
                lock (sc) OnSelfUpdatedObjects(sc);
            }
        }
コード例 #8
0
ファイル: Viewer.cs プロジェクト: Booser/radegast
 private void OnNetworkObjectUpdate(VSimulator simulator, ObjectUpdate update, ulong regionHandle, ushort timeDilation)
 {
     m_timeDilation = (float)(timeDilation / ushort.MaxValue);
     SceneGraph.OnNetworkObjectUpdate(simulator, update, regionHandle, timeDilation);
 }
コード例 #9
0
ファイル: MediBot.cs プロジェクト: SonicZentropy/MiscProjects
        //Callback for object updates in simulator
        private void Object_OnObjectUpdated(Simulator simulator, ObjectUpdate update, ulong regionHandle, ushort timeDilation)
        {
            if (movementState == MovementStates.following) //Check to make sure we need to be following
            {
                if (!update.Avatar) { return; }//Exit this event if it's not an avatar update
                if (update.LocalID == leaderID)
                {
                    Vector3 pos = update.Position;

                    if (Vector3.Distance(pos, client.Self.SimPosition) > 1)
                    {
                        GoToPosition(pos);
                        /*
                        int followRegionX = (int)(regionHandle >> 32);
                        int followRegionY = (int)(regionHandle & 0xFFFFFFFF);
                        int followRegionZ = (int)(regionHandle);
                        ulong x = (ulong)(pos.X + followRegionX);
                        ulong y = (ulong)(pos.Y + followRegionY);

                        if (pos.Z > 1)
                        {
                            //client.Self.AutoPilotLocal(Convert.ToInt32(pos.X), Convert.ToInt32(pos.Y), pos.Z);
                        }
                        else
                        {
                            client.Self.AutoPilotCancel();
                        }
                        */
                    }
                }
            }
        }
コード例 #10
0
ファイル: ObjectManager.cs プロジェクト: RavenB/gridsearch
 protected void FireOnObjectDataBlockUpdate(Simulator simulator, Primitive primitive, Primitive.ConstructionData data, ObjectUpdatePacket.ObjectDataBlock block, ObjectUpdate objectupdate, NameValue[] nameValue)
 {
     if (OnObjectDataBlockUpdate != null)
     {
         try { OnObjectDataBlockUpdate(simulator, primitive, data, block, objectupdate, nameValue); }
         catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, Client, e); }
     }
 }
コード例 #11
0
ファイル: ObjectManager.cs プロジェクト: RavenB/gridsearch
        /// <summary>
        /// Used for new prims, or significant changes to existing prims
        /// </summary>
        /// <param name="packet"></param>
        /// <param name="simulator"></param>
        protected void UpdateHandler(Packet packet, Simulator simulator)
        {
            ObjectUpdatePacket update = (ObjectUpdatePacket)packet;
            UpdateDilation(simulator, update.RegionData.TimeDilation);
            
            for (int b = 0; b < update.ObjectData.Length; b++)
            {
                ObjectUpdatePacket.ObjectDataBlock block = update.ObjectData[b];

                ObjectUpdate objectupdate = new ObjectUpdate();
                //Vector4 collisionPlane = Vector4.Zero;
                //Vector3 position;
                //Vector3 velocity;
                //Vector3 acceleration;
                //Quaternion rotation;
                //Vector3 angularVelocity;
                NameValue[] nameValues;
                bool attachment = false;
                PCode pcode = (PCode)block.PCode;

                #region Relevance check

                // Check if we are interested in this object
                if (!Client.Settings.ALWAYS_DECODE_OBJECTS)
                {
                    switch (pcode)
                    {
                        case PCode.Grass:
                        case PCode.Tree:
                        case PCode.NewTree:
                        case PCode.Prim:
                            if (OnNewPrim == null) continue;
                            break;
                        case PCode.Avatar:
                            // Make an exception for updates about our own agent
                            if (block.FullID != Client.Self.AgentID && OnNewAvatar == null) continue;
                            break;
                        case PCode.ParticleSystem:
                            continue; // TODO: Do something with these
                    }
                }

                #endregion Relevance check

                #region NameValue parsing

                string nameValue = Utils.BytesToString(block.NameValue);
                if (nameValue.Length > 0)
                {
                    string[] lines = nameValue.Split('\n');
                    nameValues = new NameValue[lines.Length];

                    for (int i = 0; i < lines.Length; i++)
                    {
                        if (!String.IsNullOrEmpty(lines[i]))
                        {
                            NameValue nv = new NameValue(lines[i]);
                            if (nv.Name == "AttachItemID") attachment = true;
                            nameValues[i] = nv;
                        }
                    }
                }
                else
                {
                    nameValues = new NameValue[0];
                }

                #endregion NameValue parsing

                #region Decode Object (primitive) parameters
                Primitive.ConstructionData data = new Primitive.ConstructionData();
                data.State = block.State;
                data.Material = (Material)block.Material;
                data.PathCurve = (PathCurve)block.PathCurve;
                data.profileCurve = block.ProfileCurve;
                data.PathBegin = Primitive.UnpackBeginCut(block.PathBegin);
                data.PathEnd = Primitive.UnpackEndCut(block.PathEnd);
                data.PathScaleX = Primitive.UnpackPathScale(block.PathScaleX);
                data.PathScaleY = Primitive.UnpackPathScale(block.PathScaleY);
                data.PathShearX = Primitive.UnpackPathShear((sbyte)block.PathShearX);
                data.PathShearY = Primitive.UnpackPathShear((sbyte)block.PathShearY);
                data.PathTwist = Primitive.UnpackPathTwist(block.PathTwist);
                data.PathTwistBegin = Primitive.UnpackPathTwist(block.PathTwistBegin);
                data.PathRadiusOffset = Primitive.UnpackPathTwist(block.PathRadiusOffset);
                data.PathTaperX = Primitive.UnpackPathTaper(block.PathTaperX);
                data.PathTaperY = Primitive.UnpackPathTaper(block.PathTaperY);
                data.PathRevolutions = Primitive.UnpackPathRevolutions(block.PathRevolutions);
                data.PathSkew = Primitive.UnpackPathTwist(block.PathSkew);
                data.ProfileBegin = Primitive.UnpackBeginCut(block.ProfileBegin);
                data.ProfileEnd = Primitive.UnpackEndCut(block.ProfileEnd);
                data.ProfileHollow = Primitive.UnpackProfileHollow(block.ProfileHollow);
                data.PCode = pcode;
                #endregion

                #region Decode Additional packed parameters in ObjectData
                int pos = 0;
                switch (block.ObjectData.Length)
                {
                    case 76:
                        // Collision normal for avatar
                        objectupdate.CollisionPlane = new Vector4(block.ObjectData, pos);
                        pos += 16;

                        goto case 60;
                    case 60:
                        // Position
                        objectupdate.Position = new Vector3(block.ObjectData, pos);
                        pos += 12;
                        // Velocity
                        objectupdate.Velocity = new Vector3(block.ObjectData, pos);
                        pos += 12;
                        // Acceleration
                        objectupdate.Acceleration = new Vector3(block.ObjectData, pos);
                        pos += 12;
                        // Rotation (theta)
                        objectupdate.Rotation = new Quaternion(block.ObjectData, pos, true);
                        pos += 12;
                        // Angular velocity (omega)
                        objectupdate.AngularVelocity = new Vector3(block.ObjectData, pos);
                        pos += 12;

                        break;
                    case 48:
                        // Collision normal for avatar
                        objectupdate.CollisionPlane = new Vector4(block.ObjectData, pos);
                        pos += 16;

                        goto case 32;
                    case 32:
                        // The data is an array of unsigned shorts

                        // Position
                        objectupdate.Position = new Vector3(
                            Utils.UInt16ToFloat(block.ObjectData, pos, -0.5f * 256.0f, 1.5f * 256.0f),
                            Utils.UInt16ToFloat(block.ObjectData, pos + 2, -0.5f * 256.0f, 1.5f * 256.0f),
                            Utils.UInt16ToFloat(block.ObjectData, pos + 4, -256.0f, 3.0f * 256.0f));
                        pos += 6;
                        // Velocity
                        objectupdate.Velocity = new Vector3(
                            Utils.UInt16ToFloat(block.ObjectData, pos, -256.0f, 256.0f),
                            Utils.UInt16ToFloat(block.ObjectData, pos + 2, -256.0f, 256.0f),
                            Utils.UInt16ToFloat(block.ObjectData, pos + 4, -256.0f, 256.0f));
                        pos += 6;
                        // Acceleration
                        objectupdate.Acceleration = new Vector3(
                            Utils.UInt16ToFloat(block.ObjectData, pos, -256.0f, 256.0f),
                            Utils.UInt16ToFloat(block.ObjectData, pos + 2, -256.0f, 256.0f),
                            Utils.UInt16ToFloat(block.ObjectData, pos + 4, -256.0f, 256.0f));
                        pos += 6;
                        // Rotation (theta)
                        objectupdate.Rotation = new Quaternion(
                            Utils.UInt16ToFloat(block.ObjectData, pos, -1.0f, 1.0f),
                            Utils.UInt16ToFloat(block.ObjectData, pos + 2, -1.0f, 1.0f),
                            Utils.UInt16ToFloat(block.ObjectData, pos + 4, -1.0f, 1.0f),
                            Utils.UInt16ToFloat(block.ObjectData, pos + 6, -1.0f, 1.0f));
                        pos += 8;
                        // Angular velocity (omega)
                        objectupdate.AngularVelocity = new Vector3(
                            Utils.UInt16ToFloat(block.ObjectData, pos, -256.0f, 256.0f),
                            Utils.UInt16ToFloat(block.ObjectData, pos + 2, -256.0f, 256.0f),
                            Utils.UInt16ToFloat(block.ObjectData, pos + 4, -256.0f, 256.0f));
                        pos += 6;

                        break;
                    case 16:
                        // The data is an array of single bytes (8-bit numbers)

                        // Position
                        objectupdate.Position = new Vector3(
                            Utils.ByteToFloat(block.ObjectData, pos, -256.0f, 256.0f),
                            Utils.ByteToFloat(block.ObjectData, pos + 1, -256.0f, 256.0f),
                            Utils.ByteToFloat(block.ObjectData, pos + 2, -256.0f, 256.0f));
                        pos += 3;
                        // Velocity
                        objectupdate.Velocity = new Vector3(
                            Utils.ByteToFloat(block.ObjectData, pos, -256.0f, 256.0f),
                            Utils.ByteToFloat(block.ObjectData, pos + 1, -256.0f, 256.0f),
                            Utils.ByteToFloat(block.ObjectData, pos + 2, -256.0f, 256.0f));
                        pos += 3;
                        // Accleration
                        objectupdate.Acceleration = new Vector3(
                            Utils.ByteToFloat(block.ObjectData, pos, -256.0f, 256.0f),
                            Utils.ByteToFloat(block.ObjectData, pos + 1, -256.0f, 256.0f),
                            Utils.ByteToFloat(block.ObjectData, pos + 2, -256.0f, 256.0f));
                        pos += 3;
                        // Rotation
                        objectupdate.Rotation = new Quaternion(
                            Utils.ByteToFloat(block.ObjectData, pos, -1.0f, 1.0f),
                            Utils.ByteToFloat(block.ObjectData, pos + 1, -1.0f, 1.0f),
                            Utils.ByteToFloat(block.ObjectData, pos + 2, -1.0f, 1.0f),
                            Utils.ByteToFloat(block.ObjectData, pos + 3, -1.0f, 1.0f));
                        pos += 4;
                        // Angular Velocity
                        objectupdate.AngularVelocity = new Vector3(
                            Utils.ByteToFloat(block.ObjectData, pos, -256.0f, 256.0f),
                            Utils.ByteToFloat(block.ObjectData, pos + 1, -256.0f, 256.0f),
                            Utils.ByteToFloat(block.ObjectData, pos + 2, -256.0f, 256.0f));
                        pos += 3;

                        break;
                    default:
                        Logger.Log("Got an ObjectUpdate block with ObjectUpdate field length of " +
                            block.ObjectData.Length, Helpers.LogLevel.Warning, Client);

                        continue;
                }
                #endregion

                // Determine the object type and create the appropriate class
                switch (pcode)
                {
                    #region Prim and Foliage
                    case PCode.Grass:
                    case PCode.Tree:
                    case PCode.NewTree:
                    case PCode.Prim:
                        Primitive prim = GetPrimitive(simulator, block.ID, block.FullID);

                        // Textures
                        objectupdate.Textures = new Primitive.TextureEntry(block.TextureEntry, 0,
                            block.TextureEntry.Length);
                        FireOnObjectDataBlockUpdate(simulator, prim, data , block , objectupdate, nameValues);

                        #region Update Prim Info with decoded data
                        prim.Flags = (PrimFlags)block.UpdateFlags;

                        if ((prim.Flags & PrimFlags.ZlibCompressed) != 0)
                        {
                            Logger.Log("Got a ZlibCompressed ObjectUpdate, implement me!",
                                Helpers.LogLevel.Warning, Client);
                            continue;
                        }

                        // Automatically request ObjectProperties for prim if it was rezzed selected.
                        if ((prim.Flags & PrimFlags.CreateSelected) != 0)
                        {
                            SelectObject(simulator, prim.LocalID);
                        }

                        prim.NameValues = nameValues;
                        prim.LocalID = block.ID;
                        prim.ID = block.FullID;
                        prim.ParentID = block.ParentID;
                        prim.RegionHandle = update.RegionData.RegionHandle;
                        prim.Scale = block.Scale;
                        prim.ClickAction = (ClickAction)block.ClickAction;
                        prim.OwnerID = block.OwnerID;
                        prim.MediaURL = Utils.BytesToString(block.MediaURL);
                        prim.Text = Utils.BytesToString(block.Text);
                        prim.TextColor = new Color4(block.TextColor, 0, false, true);

                        // Sound information
                        prim.Sound = block.Sound;
                        prim.SoundFlags = (SoundFlags)block.Flags;
                        prim.SoundGain = block.Gain;
                        prim.SoundRadius = block.Radius;

                        // Joint information
                        prim.Joint = (JointType)block.JointType;
                        prim.JointPivot = block.JointPivot;
                        prim.JointAxisOrAnchor = block.JointAxisOrAnchor;

                        // Object parameters
                        prim.PrimData = data;

                        // Textures, texture animations, particle system, and extra params
                        prim.Textures = objectupdate.Textures;

                        prim.TextureAnim = new Primitive.TextureAnimation(block.TextureAnim, 0);
                        prim.ParticleSys = new Primitive.ParticleSystem(block.PSBlock, 0);
                        prim.SetExtraParamsFromBytes(block.ExtraParams, 0);

                        // PCode-specific data
                        switch (pcode)
                        {
                            case PCode.Grass:
                            case PCode.Tree:
                            case PCode.NewTree:
                                if (block.Data.Length == 1)
                                    prim.TreeSpecies = (Tree)block.Data[0];
                                else
                                    Logger.Log("Got a foliage update with an invalid TreeSpecies field", Helpers.LogLevel.Warning);
                                prim.ScratchPad = Utils.EmptyBytes;
                                break;
                            default:
                                prim.ScratchPad = new byte[block.Data.Length];
                                if (block.Data.Length > 0)
                                    Buffer.BlockCopy(block.Data, 0, prim.ScratchPad, 0, prim.ScratchPad.Length);
                                break;
                        }

                        // Packed parameters
                        prim.CollisionPlane = objectupdate.CollisionPlane;
                        prim.Position = objectupdate.Position;
                        prim.Velocity = objectupdate.Velocity;
                        prim.Acceleration = objectupdate.Acceleration;
                        prim.Rotation = objectupdate.Rotation;
                        prim.AngularVelocity = objectupdate.AngularVelocity;
                        #endregion

                        if (attachment)
                            FireOnNewAttachment(simulator, prim, update.RegionData.RegionHandle,
                                update.RegionData.TimeDilation);
                        else
                            FireOnNewPrim(simulator, prim, update.RegionData.RegionHandle,
                                update.RegionData.TimeDilation);

                        break;
                    #endregion Prim and Foliage
                    #region Avatar
                    case PCode.Avatar:
                        // Update some internals if this is our avatar
                        if (block.FullID == Client.Self.AgentID)
                        {
                            #region Update Client.Self

                            // We need the local ID to recognize terse updates for our agent
                            Client.Self.localID = block.ID;

                            // Packed parameters
                            Client.Self.collisionPlane = objectupdate.CollisionPlane;
                            Client.Self.relativePosition = objectupdate.Position;
                            Client.Self.velocity = objectupdate.Velocity;
                            Client.Self.acceleration = objectupdate.Acceleration;
                            Client.Self.relativeRotation = objectupdate.Rotation;
                            Client.Self.angularVelocity = objectupdate.AngularVelocity;

                            #endregion
                        }

                        #region Create an Avatar from the decoded data

                        Avatar avatar = GetAvatar(simulator, block.ID, block.FullID);

                        objectupdate.Avatar = true;
                        // Textures
                        objectupdate.Textures = new Primitive.TextureEntry(block.TextureEntry, 0,                 
                            block.TextureEntry.Length);

                        FireOnObjectDataBlockUpdate(simulator, avatar, data, block, objectupdate, nameValues);

                        uint oldSeatID = avatar.ParentID;

                        avatar.ID = block.FullID;
                        avatar.LocalID = block.ID;
                        avatar.CollisionPlane = objectupdate.CollisionPlane;
                        avatar.Position = objectupdate.Position;
                        avatar.Velocity = objectupdate.Velocity;
                        avatar.Acceleration = objectupdate.Acceleration;
                        avatar.Rotation = objectupdate.Rotation;
                        avatar.AngularVelocity = objectupdate.AngularVelocity;
                        avatar.NameValues = nameValues;
                        avatar.PrimData = data;
                        if (block.Data.Length > 0) Logger.Log("Unexpected Data field for an avatar update, length " + block.Data.Length, Helpers.LogLevel.Warning);
                        avatar.ParentID = block.ParentID;
                        avatar.RegionHandle = update.RegionData.RegionHandle;

                        SetAvatarSittingOn(simulator, avatar, block.ParentID, oldSeatID);

                        // Textures
                        avatar.Textures = objectupdate.Textures;

                        #endregion Create an Avatar from the decoded data

                        FireOnNewAvatar(simulator, avatar, update.RegionData.RegionHandle,
                            update.RegionData.TimeDilation);

                        break;
                    #endregion Avatar
                    case PCode.ParticleSystem:
                        DecodeParticleUpdate(block);
                        // TODO: Create a callback for particle updates
                        break;
                    default:
                        Logger.DebugLog("Got an ObjectUpdate block with an unrecognized PCode " + pcode.ToString(), Client);
                        break;
                }
            }
        }
コード例 #12
0
ファイル: SimExport.cs プロジェクト: 3di/3di-viewer-rei-libs
        void Objects_OnObjectUpdated(Simulator simulator, ObjectUpdate update, ulong regionHandle, ushort timeDilation)
        {
            if (!update.Avatar)
            {
                Primitive prim;

                if (prims.TryGetValue(update.LocalID, out prim))
                {
                    lock (prim)
                    {
                        if (Program.Verbosity > 1)
                            Logger.Log("Updating state for " + prim.ID.ToString(), Helpers.LogLevel.Info);

                        prim.Acceleration = update.Acceleration;
                        prim.AngularVelocity = update.AngularVelocity;
                        prim.CollisionPlane = update.CollisionPlane;
                        prim.Position = update.Position;
                        prim.Rotation = update.Rotation;
                        prim.PrimData.State = update.State;
                        prim.Textures = update.Textures;
                        prim.Velocity = update.Velocity;
                    }

                    UpdateTextureQueue(prim.Textures);
                }
            }
        }
コード例 #13
0
ファイル: Callbacks.cs プロジェクト: cobain861/ghettosl
 void Objects_OnObjectUpdated(Simulator simulator, ObjectUpdate update, ulong regionHandle, ushort timeDilation)
 {
     lock (Session.Prims)
     {
         if (Session.Prims.ContainsKey(update.LocalID))
         {
             Session.Prims[update.LocalID].Position = update.Position;
             Session.Prims[update.LocalID].Rotation = update.Rotation;
         }
     }
     lock (Session.Avatars)
     {
         if (Session.Avatars.ContainsKey(update.LocalID))
         {
             Avatar av = Session.Avatars[update.LocalID];
             av.Position = update.Position;
             av.Rotation = update.Rotation;
             Dictionary<string, string> identifiers = new Dictionary<string,string>();
             identifiers.Add("$name", av.Name);
             identifiers.Add("$id", av.ID.ToString());
             identifiers.Add("$pos", av.Position.ToString());
             ScriptSystem.TriggerEvents(Session.SessionNumber, ScriptSystem.EventTypes.Update, identifiers);
         }
     }
 }
コード例 #14
0
ファイル: Protocol_process.cs プロジェクト: yooyke/work
        private void ProcessObjectUpdated(Simulator simulator, ObjectUpdate update, ulong regionHandle, ushort timeDilation)
        {
            OpenMetaverse.Primitive p = GetObjectFromLocalID(update.LocalID);
            if (p == null) return;

            ObjectData objectData;
            if (Ox.DataStore.World.SimCollection.TryGetObject(simulator.ID.ToString(), p.ID.ToString(), out objectData))
            {
                objectData.OPosition = new float[] { p.Position.X, p.Position.Y, p.Position.Z };
                objectData.OQuaternion = new float[] { p.Rotation.X, p.Rotation.Y, p.Rotation.Z, p.Rotation.W };
                objectData.Scale = new float[] { p.Scale.X, p.Scale.Y, p.Scale.Z };
                objectData.Velocity = new float[] { p.Velocity.X, p.Velocity.Y, p.Velocity.Z };

                string msg = JsonUtil.SerializeMessage(JsonType.ObjectUpdated, new JsonObjectUpdated(
                    simulator.ID.ToString(),
                    p.ID.ToString(),
                    (p is Avatar ? (int)JsonObjectUpdated.PrimType.Avatar : (int)JsonObjectUpdated.PrimType.Prim),
                    (int)JsonObjectUpdated.Type.Update
                    ));
                Ox.EventFire(msg, false);
            }
        }
コード例 #15
0
ファイル: Protocol_callback.cs プロジェクト: yooyke/work
 void Objects_OnObjectUpdated(Simulator simulator, ObjectUpdate update, ulong regionHandle, ushort timeDilation)
 {
     lock (processQueue) processQueue.Enqueue(new QueueBase(new ObjectManager.ObjectUpdatedCallback(ProcessObjectUpdated), simulator, update, regionHandle, timeDilation));
 }
コード例 #16
0
ファイル: AvatarList.cs プロジェクト: RavenB/gridsearch
 void Objects_OnObjectUpdated(Simulator simulator, ObjectUpdate update, ulong regionHandle, ushort timeDilation)
 {
     lock (_TrackedAvatars)
     {
         if (_TrackedAvatars.ContainsKey(update.LocalID))
         {
             Avatar av;
             if (simulator.ObjectsAvatars.TryGetValue(update.LocalID, out av))
                 UpdateAvatar(av);
         }
     }
 }
コード例 #17
0
ファイル: DefaultNetwork.cs プロジェクト: arcazrael/glife-cs
 void Objects_OnObjectUpdated(Simulator simulator, ObjectUpdate update, ulong regionHandle, ushort timeDilation)
 {
 }
コード例 #18
0
ファイル: SLProtocol.cs プロジェクト: caocao/3di-viewer-rei
 private void objectUpdatedCallback(Simulator simulator, ObjectUpdate update, ulong regionHandle,
                                   ushort timeDilation)
 {
     if (OnObjectUpdated != null)
     {
         OnObjectUpdated(simulator, update, regionHandle, timeDilation);
     }
 }
コード例 #19
0
 private void objectUpdatedCallback(Simulator simulator, ObjectUpdate update, ulong regionHandle,
                                   ushort timeDilation)
 {
     if (simulator == m_user.Network.CurrentSim)
     {
         if (m_user.Self.LocalID == update.LocalID)
         {
             OnSelfUpdated(simulator, update, regionHandle);
         }
     }
     if (OnObjectUpdate != null)
     {
         OnObjectUpdate(new VSimulator(simulator), update, regionHandle, timeDilation);
     }
 }