Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="data"></param>
        /// <param name="pos"></param>
        /// <returns></returns>
        public int SetExtraParamsFromBytes(byte[] data, int pos)
        {
            int i           = pos;
            int totalLength = 1;

            if (data.Length == 0)
            {
                return(0);
            }

            byte extraParamCount = data[i++];

            for (int k = 0; k < extraParamCount; k++)
            {
                ExtraParamType type        = (ExtraParamType)(data[i++] + (data[i++] << 8));
                uint           paramLength = (uint)(data[i++] + (data[i++] << 8) +
                                                    (data[i++] << 16) + (data[i++] << 24));
                if (type == ExtraParamType.Flexible)
                {
                    Flexible = new PrimFlexibleData(data, i);
                }
                else if (type == ExtraParamType.Light)
                {
                    Light = new PrimLightData(data, i);
                }
                i           += (int)paramLength;
                totalLength += (int)paramLength + 6;
            }

            return(totalLength);
        }
        void ObjectExtraParamsHandler(Packet packet, Agent agent)
        {
            ObjectExtraParamsPacket extra = (ObjectExtraParamsPacket)packet;

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

                SimulationObject obj;
                if (server.Scene.TryGetObject(block.ObjectLocalID, out obj))
                {
                    ExtraParamType type = (ExtraParamType)block.ParamType;
                }
            }
        }
Beispiel #3
0
        internal int SetExtraParamsFromBytes(byte[] data, int pos)
        {
            int i           = pos;
            int totalLength = 1;

            if (data.Length == 0 || pos >= data.Length)
            {
                return(0);
            }

            try
            {
                byte extraParamCount = data[i++];

                for (int k = 0; k < extraParamCount; k++)
                {
                    ExtraParamType type = (ExtraParamType)Helpers.BytesToUInt16(data, i);
                    i += 2;

                    uint paramLength = Helpers.BytesToUIntBig(data, i);
                    i += 4;

                    if (type == ExtraParamType.Flexible)
                    {
                        Flexible = new FlexibleData(data, i);
                    }
                    else if (type == ExtraParamType.Light)
                    {
                        Light = new LightData(data, i);
                    }
                    else if (type == ExtraParamType.Sculpt)
                    {
                        Sculpt = new SculptData(data, i);
                    }

                    i           += (int)paramLength;
                    totalLength += (int)paramLength + 6;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }

            return(totalLength);
        }
Beispiel #4
0
        public int SetExtraParamsFromBytes(byte[] data, int pos)
        {
            int i           = pos;
            int totalLength = 1;

            if (data.Length == 0 || pos >= data.Length)
            {
                return(0);
            }

            byte extraParamCount = data[i++];

            for (int k = 0; k < extraParamCount; k++)
            {
                ExtraParamType type = (ExtraParamType)Utils.BytesToUInt16(data, i);
                i += 2;

                uint paramLength = Utils.BytesToUInt(data, i);
                i += 4;

                if (type == ExtraParamType.Flexible)
                {
                    Flexible = new FlexibleData(data, i);
                }
                else if (type == ExtraParamType.Light)
                {
                    Light = new LightData(data, i);
                }
                else if (type == ExtraParamType.LightImage)
                {
                    LightMap = new LightImage(data, i);
                }
                else if (type == ExtraParamType.Sculpt || type == ExtraParamType.Mesh)
                {
                    Sculpt = new SculptData(data, i);
                }

                i           += (int)paramLength;
                totalLength += (int)paramLength + 6;
            }

            return(totalLength);
        }
Beispiel #5
0
        /// <summary>
        /// Unset additional primitive parameters on an object
        /// </summary>
        /// <param name="simulator">A reference to the <seealso cref="OpenMetaverse.Simulator"/> object where the object resides</param>
        /// <param name="localID">The objects ID which is local to the simulator the object is in</param>
        /// <param name="type">The extra parameters to set</param>
        public void SetExtraParamOff(Simulator simulator, uint localID, ExtraParamType type)
        {
            ObjectExtraParamsPacket extra = new ObjectExtraParamsPacket();

            extra.AgentData.AgentID = Client.Self.AgentID;
            extra.AgentData.SessionID = Client.Self.SessionID;
            extra.ObjectData = new ObjectExtraParamsPacket.ObjectDataBlock[1];
            extra.ObjectData[0] = new ObjectExtraParamsPacket.ObjectDataBlock();
            extra.ObjectData[0].ObjectLocalID = localID;
            extra.ObjectData[0].ParamType = (byte)type;
            extra.ObjectData[0].ParamInUse = false;
            extra.ObjectData[0].ParamData = Utils.EmptyBytes;
            extra.ObjectData[0].ParamSize = 0;

            Client.Network.SendPacket(extra, simulator);
        }
 public void Deserialize(OSDMap map)
 {
     Type = (ExtraParamType)map["extra_parameter"].AsInteger();
     ExtraParamData = map["param_data"].AsBinary();
 }
Beispiel #7
0
    protected override void DeSerialise(byte[] buf, ref int o, int length)
    {
        RegionHandle = new RegionHandle(BinarySerializer.DeSerializeUInt64_Le(buf, ref o, length));
        TimeDilation = BinarySerializer.DeSerializeUInt16_Le(buf, ref o, length);

        string logMessage = $"ObjectUpdateCompressed: RegionHandle={RegionHandle}, TimeDilation={TimeDilation}";
        int    nObjects   = buf[o++];

        for (int i = 0; i < nObjects; i++)
        {
            UInt32 len;
            ObjectUpdateMessage.ObjectData data = new ObjectUpdateMessage.ObjectData();
            Objects.Add(data);

            data.UpdateFlags = (ObjectUpdateFlags)BinarySerializer.DeSerializeUInt32_Le(buf, ref o, length);

            int    compressedLength = BinarySerializer.DeSerializeUInt16_Le(buf, ref o, length);
            byte[] compressedData   = new byte[compressedLength];
            Array.Copy(buf, o, compressedData, 0, compressedLength);
            o += compressedLength;
            int compressedOffset = 0;

            logMessage      += $"\n  Object {i}: UpdateFlags={data.UpdateFlags}, Data({compressedData.Length})={BitConverter.ToString(compressedData)}";
            data.FullId      = BinarySerializer.DeSerializeGuid(compressedData, ref compressedOffset, compressedLength);
            data.LocalId     = BinarySerializer.DeSerializeUInt32_Le(compressedData, ref compressedOffset, compressedLength);
            data.PCode       = (PCode)compressedData[compressedOffset++];
            data.State       = compressedData[compressedOffset++];
            data.Crc         = BinarySerializer.DeSerializeUInt32_Le(compressedData, ref compressedOffset, compressedLength);
            data.Material    = (MaterialType)compressedData[compressedOffset++];
            data.ClickAction = (ClickAction)compressedData[compressedOffset++];
            data.Scale       = BinarySerializer.DeSerializeVector3(compressedData, ref compressedOffset, compressedLength);
            data.Position    = BinarySerializer.DeSerializeVector3(compressedData, ref compressedOffset, compressedLength);
            data.Rotation    = BinarySerializer.DeSerializeQuaternion(compressedData, ref compressedOffset, compressedLength);
            CompressedFlags compressedFlags = (CompressedFlags)BinarySerializer.DeSerializeUInt32_Le(compressedData, ref compressedOffset, compressedLength);

            data.OwnerId = BinarySerializer.DeSerializeGuid(compressedData, ref compressedOffset, compressedLength);

            logMessage += $"\n    FullId={data.FullId}, LocalId={data.LocalId}, PCode={data.PCode}, State={data.State}, Crc={data.Crc}, Material={data.Material}, ClickAction={data.ClickAction}, Scale={data.Scale}, Position={data.Position}, Rotation={data.Rotation}, CompressedFlags=({compressedFlags})";

            if ((compressedFlags & CompressedFlags.HasAngularVelocity) != 0)
            {
                data.AngularVelocity = BinarySerializer.DeSerializeVector3(compressedData, ref compressedOffset, compressedLength);
                logMessage          += $", AngularVelocity={data.AngularVelocity}";
            }

            data.ParentId = (compressedFlags & CompressedFlags.HasParent) != 0 ? BinarySerializer.DeSerializeUInt32_Le(compressedData, ref compressedOffset, compressedLength) : (uint)0;
            logMessage   += $", ParentId={data.ParentId}";

            if ((compressedFlags & CompressedFlags.Tree) != 0)
            {
                byte treeSpecies = compressedData[compressedOffset++];
                logMessage += $", TreeSpecies={treeSpecies}";
            }

            if ((compressedFlags & CompressedFlags.ScratchPad) != 0)
            {
                len = compressedData[compressedOffset++];
                compressedOffset += (int)len; // TODO: These offsets and length should all be UInt32
                logMessage       += $", Scratchpad({len})";
            }

            if ((compressedFlags & CompressedFlags.HasText) != 0)
            {
                data.Text       = BinarySerializer.DeSerializeString(compressedData, ref compressedOffset, compressedLength, 0);
                data.TextColour = BinarySerializer.DeSerializeColor(compressedData, ref compressedOffset, compressedLength);
                logMessage     += $", Text={data.Text}, TextColour={data.TextColour}";
            }

            if ((compressedFlags & CompressedFlags.MediaURL) != 0)
            {
                data.MediaUrl = BinarySerializer.DeSerializeString(compressedData, ref compressedOffset, compressedLength, 0);
                logMessage   += $", MediaUrl={data.MediaUrl}";
            }

            if ((compressedFlags & CompressedFlags.HasParticles) != 0)
            {
                len         = 86;
                logMessage += $", ParticleSystem({len})";
            }

            byte nExtraParameters = compressedData[compressedOffset++];
            for (int j = 0; j < nExtraParameters; j++)
            {
                if (j == 0)
                {
                    logMessage += ", ExtraParameters=(";
                }
                ExtraParamType type = (ExtraParamType)BinarySerializer.DeSerializeUInt16_Le(compressedData, ref compressedOffset, compressedLength);
                len = BinarySerializer.DeSerializeUInt32_Le(compressedData, ref compressedOffset, compressedLength);
                switch (type)
                {
                case ExtraParamType.Flexible:
                    break;

                case ExtraParamType.Light:
                    break;

                case ExtraParamType.Sculpt:
                    break;

                case ExtraParamType.LightImage:
                    break;

                case ExtraParamType.Mesh:
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                logMessage += $"{type}, ";

                compressedOffset += (int)len; // TODO: These offsets and length should all be UInt32

                if (j == nExtraParameters - 1)
                {
                    logMessage += ")";
                }
            }

            if ((compressedFlags & CompressedFlags.HasSound) != 0)
            {
                data.SoundId    = BinarySerializer.DeSerializeGuid(compressedData, ref compressedOffset, compressedLength);
                data.Gain       = BinarySerializer.DeSerializeUInt32_Le(compressedData, ref compressedOffset, compressedLength);
                data.SoundFlags = (SoundFlags)compressedData[compressedOffset++];
                data.Radius     = BinarySerializer.DeSerializeFloat_Le(compressedData, ref compressedOffset, compressedLength);
                logMessage     += $", SoundId={data.SoundId}, Gain={data.Gain}, SoundFlags={data.SoundFlags}, Radius={data.Radius}";
            }

            if ((compressedFlags & CompressedFlags.HasNameValues) != 0)
            {
                data.NameValue = BinarySerializer.DeSerializeString(compressedData, ref compressedOffset, compressedLength, 0);
                logMessage    += $", NameValue={data.NameValue}";
            }

            data.PathCurve        = (PathType)compressedData[compressedOffset++];
            data.PathBegin        = BinarySerializer.DeSerializeUInt16_Le(compressedData, ref compressedOffset, length) * CUT_QUANTA;
            data.PathEnd          = BinarySerializer.DeSerializeUInt16_Le(compressedData, ref compressedOffset, length) * CUT_QUANTA;
            data.PathScaleX       = compressedData[compressedOffset++] * SCALE_QUANTA;
            data.PathScaleY       = compressedData[compressedOffset++] * SCALE_QUANTA;
            data.PathShearX       = compressedData[compressedOffset++] * SHEAR_QUANTA;
            data.PathShearY       = compressedData[compressedOffset++] * SHEAR_QUANTA;
            data.PathTwist        = (sbyte)compressedData[compressedOffset++] * SCALE_QUANTA;
            data.PathTwistBegin   = (sbyte)compressedData[compressedOffset++] * SCALE_QUANTA;
            data.PathRadiusOffset = (sbyte)compressedData[compressedOffset++] * SCALE_QUANTA;
            data.PathTaperX       = (sbyte)compressedData[compressedOffset++] * TAPER_QUANTA;
            data.PathTaperY       = (sbyte)compressedData[compressedOffset++] * TAPER_QUANTA;
            data.PathRevolutions  = compressedData[compressedOffset++] * REV_QUANTA;
            data.PathSkew         = (sbyte)compressedData[compressedOffset++] * SCALE_QUANTA;

            data.ProfileCurve  = (ProfileType)compressedData[compressedOffset++];
            data.ProfileBegin  = BinarySerializer.DeSerializeUInt16_Le(compressedData, ref compressedOffset, length) * CUT_QUANTA;
            data.ProfileEnd    = BinarySerializer.DeSerializeUInt16_Le(compressedData, ref compressedOffset, length) * CUT_QUANTA;
            data.ProfileHollow = BinarySerializer.DeSerializeUInt16_Le(compressedData, ref compressedOffset, length) * HOLLOW_QUANTA;

            UInt32 textureEntryLength = BinarySerializer.DeSerializeUInt32_Le(compressedData, ref compressedOffset, length);
            logMessage       += $", textures({textureEntryLength})";
            compressedOffset += (int)textureEntryLength;

            if ((compressedFlags & CompressedFlags.TextureAnimation) != 0)
            {
                TextureAnimation textureAnimation = new TextureAnimation()
                {
                    Mode   = (TextureAnimationMode)compressedData[compressedOffset++],
                    Face   = compressedData[compressedOffset++],
                    SizeX  = compressedData[compressedOffset++],
                    SizeY  = compressedData[compressedOffset++],
                    Start  = BinarySerializer.DeSerializeFloat_Le(compressedData, ref compressedOffset, length),
                    Length = BinarySerializer.DeSerializeFloat_Le(compressedData, ref compressedOffset, length),
                    Rate   = BinarySerializer.DeSerializeFloat_Le(compressedData, ref compressedOffset, length)
                };
                logMessage += ", TextureAnimation";
            }

            data.IsAttachment = (compressedFlags & CompressedFlags.HasNameValues) != 0 && data.ParentId != 0;
        }
        //Logger.LogDebug(logMessage);
    }