Exemplo n.º 1
0
        public void RenderMaterialsPostCap(IOSHttpRequest request, IOSHttpResponse response, UUID agentID)
        {
            OSDMap req;

            try
            {
                req = (OSDMap)OSDParser.DeserializeLLSDXml(request.InputStream);
            }
            catch
            {
                response.StatusCode = (int)HttpStatusCode.BadRequest;
                return;
            }

            OSDArray respArr = new OSDArray();
            OSD      tmpOSD;

            if (req.TryGetValue("Zipped", out tmpOSD))
            {
                OSD osd = null;

                byte[] inBytes = tmpOSD.AsBinary();

                try
                {
                    osd = ZDecompressBytesToOsd(inBytes);

                    if (osd != null && osd is OSDArray)
                    {
                        foreach (OSD elem in (OSDArray)osd)
                        {
                            try
                            {
                                UUID id = new UUID(elem.AsBinary(), 0);

                                lock (materialslock)
                                {
                                    if (m_Materials.ContainsKey(id))
                                    {
                                        OSDMap matMap = new OSDMap();
                                        matMap["ID"]       = OSD.FromBinary(id.GetBytes());
                                        matMap["Material"] = m_Materials[id].toOSD();
                                        respArr.Add(matMap);
                                    }
                                    else
                                    {
                                        m_log.Warn("[Materials]: request for unknown material ID: " + id.ToString());

                                        // Theoretically we could try to load the material from the assets service,
                                        // but that shouldn't be necessary because the viewer should only request
                                        // materials that exist in a prim on the region, and all of these materials
                                        // are already stored in m_regionMaterials.
                                    }
                                }
                            }
                            catch (Exception e)
                            {
                                m_log.Error("Error getting materials in response to viewer request", e);
                                continue;
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    m_log.Warn("[Materials]: exception decoding zipped CAP payload ", e);
                    response.StatusCode = (int)HttpStatusCode.BadRequest;
                    return;
                }
            }

            OSDMap resp = new OSDMap();

            resp["Zipped"]     = ZCompressOSD(respArr, false);
            response.RawBuffer = Encoding.UTF8.GetBytes(OSDParser.SerializeLLSDXmlString(resp));

            //m_log.Debug("[Materials]: cap request: " + request);
            //m_log.Debug("[Materials]: cap request (zipped portion): " + ZippedOsdBytesToString(req["Zipped"].AsBinary()));
            //m_log.Debug("[Materials]: cap response: " + response);
        }
Exemplo n.º 2
0
        public virtual OSDMap Pack()
        {
            OSDMap args = new OSDMap();

            args["message_type"] = OSD.FromString("AgentData");

            args["region_id"]    = OSD.FromString(RegionID.ToString());
            args["circuit_code"] = OSD.FromString(CircuitCode.ToString());
            args["agent_uuid"]   = OSD.FromUUID(AgentID);
            args["session_uuid"] = OSD.FromUUID(SessionID);

            args["position"]  = OSD.FromString(Position.ToString());
            args["velocity"]  = OSD.FromString(Velocity.ToString());
            args["center"]    = OSD.FromString(Center.ToString());
            args["size"]      = OSD.FromString(Size.ToString());
            args["at_axis"]   = OSD.FromString(AtAxis.ToString());
            args["left_axis"] = OSD.FromString(LeftAxis.ToString());
            args["up_axis"]   = OSD.FromString(UpAxis.ToString());

            args["changed_grid"] = OSD.FromBoolean(ChangedGrid);
            args["far"]          = OSD.FromReal(Far);
            args["aspect"]       = OSD.FromReal(Aspect);

            if ((Throttles != null) && (Throttles.Length > 0))
            {
                args["throttles"] = OSD.FromBinary(Throttles);
            }

            args["locomotion_state"] = OSD.FromString(LocomotionState.ToString());
            args["head_rotation"]    = OSD.FromString(HeadRotation.ToString());
            args["body_rotation"]    = OSD.FromString(BodyRotation.ToString());
            args["control_flags"]    = OSD.FromString(ControlFlags.ToString());

            args["energy_level"] = OSD.FromReal(EnergyLevel);
            args["god_level"]    = OSD.FromString(GodLevel.ToString());
            args["always_run"]   = OSD.FromBoolean(AlwaysRun);
            args["prey_agent"]   = OSD.FromUUID(PreyAgent);
            args["agent_access"] = OSD.FromString(AgentAccess.ToString());

            args["active_group_id"] = OSD.FromUUID(ActiveGroupID);

            if ((Groups != null) && (Groups.Length > 0))
            {
                OSDArray groups = new OSDArray(Groups.Length);

                foreach (AgentGroupData agd in Groups)
                {
                    groups.Add(agd.PackUpdateMessage());
                }

                args["groups"] = groups;
            }

            if ((Anims != null) && (Anims.Length > 0))
            {
                OSDArray anims = new OSDArray(Anims.Length);

                foreach (Animation aanim in Anims)
                {
                    anims.Add(aanim.PackUpdateMessage());
                }

                args["animations"] = anims;
            }

            if ((AgentTextures != null) && (AgentTextures.Length > 0))
            {
                args["texture_entry"] = OSD.FromBinary(AgentTextures);
            }

            if ((VisualParams != null) && (VisualParams.Length > 0))
            {
                args["visual_params"] = OSD.FromBinary(VisualParams);
            }

            // We might not pass this in all cases...
            if ((Wearables != null) && (Wearables.Length > 0))
            {
                OSDArray wears = new OSDArray(Wearables.Length);

                foreach (UUID uuid in Wearables)
                {
                    wears.Add(OSD.FromUUID(uuid));
                }

                args["wearables"] = wears;
            }

            if ((Attachments != null) && (Attachments.Length > 0))
            {
                OSDArray attachs = new OSDArray(Attachments.Length);

                foreach (AttachmentData att in Attachments)
                {
                    attachs.Add(att.PackUpdateMessage());
                }

                args["attachments"] = attachs;
            }

            if ((Controllers != null) && (Controllers.Length > 0))
            {
                OSDArray controls = new OSDArray(Controllers.Length);

                foreach (ControllerData ctl in Controllers)
                {
                    controls.Add(ctl.PackUpdateMessage());
                }

                args["controllers"] = controls;
            }

            if ((CallbackURI != null) && (!CallbackURI.Equals("")))
            {
                args["callback_uri"] = OSD.FromString(CallbackURI);
            }

            return(args);
        }
        public virtual OSDMap Pack()
        {
// DEBUG ON
            m_log.WarnFormat("[CHILDAGENTDATAUPDATE] Pack data");
// DEBUG OFF

            OSDMap args = new OSDMap();

            args["message_type"] = OSD.FromString("AgentData");

            args["region_id"]    = OSD.FromString(RegionID.ToString());
            args["circuit_code"] = OSD.FromString(CircuitCode.ToString());
            args["agent_uuid"]   = OSD.FromUUID(AgentID);
            args["session_uuid"] = OSD.FromUUID(SessionID);

            args["position"]  = OSD.FromString(Position.ToString());
            args["velocity"]  = OSD.FromString(Velocity.ToString());
            args["center"]    = OSD.FromString(Center.ToString());
            args["size"]      = OSD.FromString(Size.ToString());
            args["at_axis"]   = OSD.FromString(AtAxis.ToString());
            args["left_axis"] = OSD.FromString(LeftAxis.ToString());
            args["up_axis"]   = OSD.FromString(UpAxis.ToString());


            args["changed_grid"] = OSD.FromBoolean(ChangedGrid);
            args["far"]          = OSD.FromReal(Far);
            args["aspect"]       = OSD.FromReal(Aspect);

            if ((Throttles != null) && (Throttles.Length > 0))
            {
                args["throttles"] = OSD.FromBinary(Throttles);
            }

            args["locomotion_state"] = OSD.FromString(LocomotionState.ToString());
            args["head_rotation"]    = OSD.FromString(HeadRotation.ToString());
            args["body_rotation"]    = OSD.FromString(BodyRotation.ToString());
            args["control_flags"]    = OSD.FromString(ControlFlags.ToString());

            args["energy_level"] = OSD.FromReal(EnergyLevel);
            args["god_level"]    = OSD.FromString(GodLevel.ToString());
            args["always_run"]   = OSD.FromBoolean(AlwaysRun);
            args["prey_agent"]   = OSD.FromUUID(PreyAgent);
            args["agent_access"] = OSD.FromString(AgentAccess.ToString());

            args["active_group_id"] = OSD.FromUUID(ActiveGroupID);

            if ((Groups != null) && (Groups.Length > 0))
            {
                OSDArray groups = new OSDArray(Groups.Length);
                foreach (AgentGroupData agd in Groups)
                {
                    groups.Add(agd.PackUpdateMessage());
                }
                args["groups"] = groups;
            }

            if ((Anims != null) && (Anims.Length > 0))
            {
                OSDArray anims = new OSDArray(Anims.Length);
                foreach (Animation aanim in Anims)
                {
                    anims.Add(aanim.PackUpdateMessage());
                }
                args["animations"] = anims;
            }

            if (Appearance != null)
            {
                args["packed_appearance"] = Appearance.Pack();
            }

            //if ((AgentTextures != null) && (AgentTextures.Length > 0))
            //{
            //    OSDArray textures = new OSDArray(AgentTextures.Length);
            //    foreach (UUID uuid in AgentTextures)
            //        textures.Add(OSD.FromUUID(uuid));
            //    args["agent_textures"] = textures;
            //}

            // The code to pack textures, visuals, wearables and attachments
            // should be removed; packed appearance contains the full appearance
            // This is retained for backward compatibility only
            if (Appearance.Texture != null)
            {
                byte[] rawtextures = Appearance.Texture.GetBytes();
                args["texture_entry"] = OSD.FromBinary(rawtextures);
            }

            if ((Appearance.VisualParams != null) && (Appearance.VisualParams.Length > 0))
            {
                args["visual_params"] = OSD.FromBinary(Appearance.VisualParams);
            }

            // We might not pass this in all cases...
            if ((Appearance.Wearables != null) && (Appearance.Wearables.Length > 0))
            {
                OSDArray wears = new OSDArray(Appearance.Wearables.Length);
                foreach (AvatarWearable awear in Appearance.Wearables)
                {
                    wears.Add(awear.Pack());
                }

                args["wearables"] = wears;
            }

            List <AvatarAttachment> attachments = Appearance.GetAttachments();

            if ((attachments != null) && (attachments.Count > 0))
            {
                OSDArray attachs = new OSDArray(attachments.Count);
                foreach (AvatarAttachment att in attachments)
                {
                    attachs.Add(att.Pack());
                }
                args["attachments"] = attachs;
            }
            // End of code to remove

            if ((Controllers != null) && (Controllers.Length > 0))
            {
                OSDArray controls = new OSDArray(Controllers.Length);
                foreach (ControllerData ctl in Controllers)
                {
                    controls.Add(ctl.PackUpdateMessage());
                }
                args["controllers"] = controls;
            }


            if ((CallbackURI != null) && (!CallbackURI.Equals("")))
            {
                args["callback_uri"] = OSD.FromString(CallbackURI);
            }


            return(args);
        }
Exemplo n.º 4
0
        public virtual OSDMap Pack()
        {
            OSDMap args = new OSDMap();

            args["message_type"] = OSD.FromString("AgentData");

            args["region_handle"] = OSD.FromString(RegionHandle.ToString());
            args["circuit_code"]  = OSD.FromString(CircuitCode.ToString());
            args["agent_uuid"]    = OSD.FromUUID(AgentID);
            args["session_uuid"]  = OSD.FromUUID(SessionID);

            args["position"]  = OSD.FromString(Position.ToString());
            args["velocity"]  = OSD.FromString(Velocity.ToString());
            args["center"]    = OSD.FromString(Center.ToString());
            args["size"]      = OSD.FromString(Size.ToString());
            args["at_axis"]   = OSD.FromString(AtAxis.ToString());
            args["left_axis"] = OSD.FromString(LeftAxis.ToString());
            args["up_axis"]   = OSD.FromString(UpAxis.ToString());

            args["changed_grid"] = OSD.FromBoolean(ChangedGrid);
            args["far"]          = OSD.FromReal(Far);
            args["aspect"]       = OSD.FromReal(Aspect);

            if ((Throttles != null) && (Throttles.Length > 0))
            {
                args["throttles"] = OSD.FromBinary(Throttles);
            }

            args["locomotion_state"] = OSD.FromString(LocomotionState.ToString());
            args["head_rotation"]    = OSD.FromString(HeadRotation.ToString());
            args["body_rotation"]    = OSD.FromString(BodyRotation.ToString());
            args["control_flags"]    = OSD.FromString(ControlFlags.ToString());

            args["energy_level"] = OSD.FromReal(EnergyLevel);
            args["god_level"]    = OSD.FromString(GodLevel.ToString());
            args["always_run"]   = OSD.FromBoolean(AlwaysRun);
            args["prey_agent"]   = OSD.FromUUID(PreyAgent);
            args["agent_access"] = OSD.FromString(AgentAccess.ToString());

            args["active_group_id"] = OSD.FromUUID(ActiveGroupID);

            if ((Groups != null) && (Groups.Length > 0))
            {
                OSDArray groups = new OSDArray(Groups.Length);
                foreach (AgentGroupData agd in Groups)
                {
                    groups.Add(agd.PackUpdateMessage());
                }
                args["groups"] = groups;
            }

            if ((Anims != null) && (Anims.Length > 0))
            {
                OSDArray anims = new OSDArray(Anims.Length);
                foreach (Animation aanim in Anims)
                {
                    anims.Add(aanim.PackUpdateMessage());
                }
                args["animations"] = anims;
            }

            if ((Appearance != null) && (Appearance.Texture != null))
            {
                args["texture_entry"] = OSD.FromBinary(Appearance.Texture.GetBytes());
            }

            if ((Appearance != null) && (Appearance.VisualParams != null) && (Appearance.VisualParams.Length > 0))
            {
                args["visual_params"] = OSD.FromBinary(Appearance.VisualParams);
            }

            // We might not pass this in all cases...
            if (Appearance != null)
            {
                OSDArray wears = new OSDArray(AvatarWearable.MAX_WEARABLES * 2);
                for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++)
                {
                    AvatarWearable wearable = Appearance.GetWearableOfType(i);
                    wears.Add(OSD.FromUUID(wearable.ItemID));
                    wears.Add(OSD.FromUUID(wearable.AssetID));
                }

                args["wearables"] = wears;
            }

            if (!String.IsNullOrEmpty(CallbackURI))
            {
                args["callback_uri"] = OSD.FromString(CallbackURI);
            }

            if (SatOnGroup != UUID.Zero)
            {
                args["sat_on_group"] = OSD.FromUUID(SatOnGroup);
                args["sat_on_prim"]  = OSD.FromUUID(SatOnPrim);
                args["sit_offset"]   = OSD.FromString(SatOnPrimOffset.ToString());
            }

            return(args);
        }
Exemplo n.º 5
0
        public static OSD ParcelProperties(ParcelPropertiesPacket parcelPropertiesPacket)
        {
            OSDMap parcelProperties = new OSDMap();
            OSDMap body             = new OSDMap();

            OSDArray ageVerificationBlock = new OSDArray();
            OSDMap   ageVerificationMap   = new OSDMap();

            ageVerificationMap.Add("RegionDenyAgeUnverified",
                                   OSD.FromBoolean(parcelPropertiesPacket.AgeVerificationBlock.RegionDenyAgeUnverified));
            ageVerificationBlock.Add(ageVerificationMap);
            body.Add("AgeVerificationBlock", ageVerificationBlock);

            // LL sims send media info in this event queue message but it's not in the UDP
            // packet we construct this event queue message from. This should be refactored in
            // other areas of the code so it can all be send in the same message. Until then we will
            // still send the media info via UDP

            //OSDArray mediaData = new OSDArray();
            //OSDMap mediaDataMap = new OSDMap();
            //mediaDataMap.Add("MediaDesc", OSD.FromString(""));
            //mediaDataMap.Add("MediaHeight", OSD.FromInteger(0));
            //mediaDataMap.Add("MediaLoop", OSD.FromInteger(0));
            //mediaDataMap.Add("MediaType", OSD.FromString("type/type"));
            //mediaDataMap.Add("MediaWidth", OSD.FromInteger(0));
            //mediaDataMap.Add("ObscureMedia", OSD.FromInteger(0));
            //mediaDataMap.Add("ObscureMusic", OSD.FromInteger(0));
            //mediaData.Add(mediaDataMap);
            //body.Add("MediaData", mediaData);

            OSDArray parcelData    = new OSDArray();
            OSDMap   parcelDataMap = new OSDMap();
            OSDArray AABBMax       = new OSDArray(3);

            AABBMax.Add(OSD.FromReal(parcelPropertiesPacket.ParcelData.AABBMax.X));
            AABBMax.Add(OSD.FromReal(parcelPropertiesPacket.ParcelData.AABBMax.Y));
            AABBMax.Add(OSD.FromReal(parcelPropertiesPacket.ParcelData.AABBMax.Z));
            parcelDataMap.Add("AABBMax", AABBMax);

            OSDArray AABBMin = new OSDArray(3);

            AABBMin.Add(OSD.FromReal(parcelPropertiesPacket.ParcelData.AABBMin.X));
            AABBMin.Add(OSD.FromReal(parcelPropertiesPacket.ParcelData.AABBMin.Y));
            AABBMin.Add(OSD.FromReal(parcelPropertiesPacket.ParcelData.AABBMin.Z));
            parcelDataMap.Add("AABBMin", AABBMin);

            parcelDataMap.Add("Area", OSD.FromInteger(parcelPropertiesPacket.ParcelData.Area));
            parcelDataMap.Add("AuctionID", OSD.FromBinary(uintToByteArray(parcelPropertiesPacket.ParcelData.AuctionID)));
            parcelDataMap.Add("AuthBuyerID", OSD.FromUUID(parcelPropertiesPacket.ParcelData.AuthBuyerID));
            parcelDataMap.Add("Bitmap", OSD.FromBinary(parcelPropertiesPacket.ParcelData.Bitmap));
            parcelDataMap.Add("Category", OSD.FromInteger((int)parcelPropertiesPacket.ParcelData.Category));
            parcelDataMap.Add("ClaimDate", OSD.FromInteger(parcelPropertiesPacket.ParcelData.ClaimDate));
            parcelDataMap.Add("ClaimPrice", OSD.FromInteger(parcelPropertiesPacket.ParcelData.ClaimPrice));
            parcelDataMap.Add("Desc", OSD.FromString(Utils.BytesToString(parcelPropertiesPacket.ParcelData.Desc)));
            parcelDataMap.Add("GroupID", OSD.FromUUID(parcelPropertiesPacket.ParcelData.GroupID));
            parcelDataMap.Add("GroupPrims", OSD.FromInteger(parcelPropertiesPacket.ParcelData.GroupPrims));
            parcelDataMap.Add("IsGroupOwned", OSD.FromBoolean(parcelPropertiesPacket.ParcelData.IsGroupOwned));
            parcelDataMap.Add("LandingType", OSD.FromInteger(parcelPropertiesPacket.ParcelData.LandingType));
            parcelDataMap.Add("LocalID", OSD.FromInteger(parcelPropertiesPacket.ParcelData.LocalID));
            parcelDataMap.Add("MaxPrims", OSD.FromInteger(parcelPropertiesPacket.ParcelData.MaxPrims));
            parcelDataMap.Add("MediaAutoScale", OSD.FromInteger((int)parcelPropertiesPacket.ParcelData.MediaAutoScale));
            parcelDataMap.Add("MediaID", OSD.FromUUID(parcelPropertiesPacket.ParcelData.MediaID));
            parcelDataMap.Add("MediaURL", OSD.FromString(Utils.BytesToString(parcelPropertiesPacket.ParcelData.MediaURL)));
            parcelDataMap.Add("MusicURL", OSD.FromString(Utils.BytesToString(parcelPropertiesPacket.ParcelData.MusicURL)));
            parcelDataMap.Add("Name", OSD.FromString(Utils.BytesToString(parcelPropertiesPacket.ParcelData.Name)));
            parcelDataMap.Add("OtherCleanTime", OSD.FromInteger(parcelPropertiesPacket.ParcelData.OtherCleanTime));
            parcelDataMap.Add("OtherCount", OSD.FromInteger(parcelPropertiesPacket.ParcelData.OtherCount));
            parcelDataMap.Add("OtherPrims", OSD.FromInteger(parcelPropertiesPacket.ParcelData.OtherPrims));
            parcelDataMap.Add("OwnerID", OSD.FromUUID(parcelPropertiesPacket.ParcelData.OwnerID));
            parcelDataMap.Add("OwnerPrims", OSD.FromInteger(parcelPropertiesPacket.ParcelData.OwnerPrims));
            parcelDataMap.Add("ParcelFlags", OSD.FromBinary(uintToByteArray(parcelPropertiesPacket.ParcelData.ParcelFlags)));
            parcelDataMap.Add("ParcelPrimBonus", OSD.FromReal(parcelPropertiesPacket.ParcelData.ParcelPrimBonus));
            parcelDataMap.Add("PassHours", OSD.FromReal(parcelPropertiesPacket.ParcelData.PassHours));
            parcelDataMap.Add("PassPrice", OSD.FromInteger(parcelPropertiesPacket.ParcelData.PassPrice));
            parcelDataMap.Add("PublicCount", OSD.FromInteger(parcelPropertiesPacket.ParcelData.PublicCount));
            parcelDataMap.Add("RegionDenyAnonymous", OSD.FromBoolean(parcelPropertiesPacket.ParcelData.RegionDenyAnonymous));
            parcelDataMap.Add("RegionDenyIdentified", OSD.FromBoolean(parcelPropertiesPacket.ParcelData.RegionDenyIdentified));
            parcelDataMap.Add("RegionDenyTransacted", OSD.FromBoolean(parcelPropertiesPacket.ParcelData.RegionDenyTransacted));

            parcelDataMap.Add("RegionPushOverride", OSD.FromBoolean(parcelPropertiesPacket.ParcelData.RegionPushOverride));
            parcelDataMap.Add("RentPrice", OSD.FromInteger(parcelPropertiesPacket.ParcelData.RentPrice));
            parcelDataMap.Add("RequestResult", OSD.FromInteger(parcelPropertiesPacket.ParcelData.RequestResult));
            parcelDataMap.Add("SalePrice", OSD.FromInteger(parcelPropertiesPacket.ParcelData.SalePrice));
            parcelDataMap.Add("SelectedPrims", OSD.FromInteger(parcelPropertiesPacket.ParcelData.SelectedPrims));
            parcelDataMap.Add("SelfCount", OSD.FromInteger(parcelPropertiesPacket.ParcelData.SelfCount));
            parcelDataMap.Add("SequenceID", OSD.FromInteger(parcelPropertiesPacket.ParcelData.SequenceID));
            parcelDataMap.Add("SimWideMaxPrims", OSD.FromInteger(parcelPropertiesPacket.ParcelData.SimWideMaxPrims));
            parcelDataMap.Add("SimWideTotalPrims", OSD.FromInteger(parcelPropertiesPacket.ParcelData.SimWideTotalPrims));
            parcelDataMap.Add("SnapSelection", OSD.FromBoolean(parcelPropertiesPacket.ParcelData.SnapSelection));
            parcelDataMap.Add("SnapshotID", OSD.FromUUID(parcelPropertiesPacket.ParcelData.SnapshotID));
            parcelDataMap.Add("Status", OSD.FromInteger((int)parcelPropertiesPacket.ParcelData.Status));
            parcelDataMap.Add("TotalPrims", OSD.FromInteger(parcelPropertiesPacket.ParcelData.TotalPrims));

            OSDArray UserLocation = new OSDArray(3);

            UserLocation.Add(OSD.FromReal(parcelPropertiesPacket.ParcelData.UserLocation.X));
            UserLocation.Add(OSD.FromReal(parcelPropertiesPacket.ParcelData.UserLocation.Y));
            UserLocation.Add(OSD.FromReal(parcelPropertiesPacket.ParcelData.UserLocation.Z));
            parcelDataMap.Add("UserLocation", UserLocation);

            OSDArray UserLookAt = new OSDArray(3);

            UserLookAt.Add(OSD.FromReal(parcelPropertiesPacket.ParcelData.UserLookAt.X));
            UserLookAt.Add(OSD.FromReal(parcelPropertiesPacket.ParcelData.UserLookAt.Y));
            UserLookAt.Add(OSD.FromReal(parcelPropertiesPacket.ParcelData.UserLookAt.Z));
            parcelDataMap.Add("UserLookAt", UserLookAt);

            parcelData.Add(parcelDataMap);
            body.Add("ParcelData", parcelData);
            parcelProperties.Add("body", body);
            parcelProperties.Add("message", OSD.FromString("ParcelProperties"));

            return(parcelProperties);
        }
Exemplo n.º 6
0
        public virtual OSDMap Pack(EntityTransferContext ctx)
        {
//            m_log.InfoFormat("[CHILDAGENTDATAUPDATE] Pack data");

            OSDMap args = new OSDMap();

            args["message_type"] = OSD.FromString("AgentData");

            args["region_id"]    = OSD.FromString(RegionID.ToString());
            args["circuit_code"] = OSD.FromString(CircuitCode.ToString());
            args["agent_uuid"]   = OSD.FromUUID(AgentID);
            args["session_uuid"] = OSD.FromUUID(SessionID);

            args["position"]  = OSD.FromString(Position.ToString());
            args["velocity"]  = OSD.FromString(Velocity.ToString());
            args["center"]    = OSD.FromString(Center.ToString());
            args["size"]      = OSD.FromString(Size.ToString());
            args["at_axis"]   = OSD.FromString(AtAxis.ToString());
            args["left_axis"] = OSD.FromString(LeftAxis.ToString());
            args["up_axis"]   = OSD.FromString(UpAxis.ToString());

            //backwards compatibility
            args["changed_grid"]  = OSD.FromBoolean(SenderWantsToWaitForRoot);
            args["wait_for_root"] = OSD.FromBoolean(SenderWantsToWaitForRoot);
            args["far"]           = OSD.FromReal(Far);
            args["aspect"]        = OSD.FromReal(Aspect);

            if ((Throttles != null) && (Throttles.Length > 0))
            {
                args["throttles"] = OSD.FromBinary(Throttles);
            }

            args["locomotion_state"] = OSD.FromString(LocomotionState.ToString());
            args["head_rotation"]    = OSD.FromString(HeadRotation.ToString());
            args["body_rotation"]    = OSD.FromString(BodyRotation.ToString());
            args["control_flags"]    = OSD.FromString(ControlFlags.ToString());

            args["energy_level"] = OSD.FromReal(EnergyLevel);
            //args["god_level"] = OSD.FromString(GodLevel.ToString());
            if (GodData != null)
            {
                args["god_data"] = GodData;
                OSDMap g = (OSDMap)GodData;
                if (g.ContainsKey("ViewerUiIsGod"))
                {
                    args["god_level"] = g["ViewerUiIsGod"].AsBoolean() ? 200 : 0;
                }
                ;
            }
            args["always_run"]   = OSD.FromBoolean(AlwaysRun);
            args["prey_agent"]   = OSD.FromUUID(PreyAgent);
            args["agent_access"] = OSD.FromString(AgentAccess.ToString());

            args["agent_cof"]     = OSD.FromUUID(agentCOF);
            args["crossingflags"] = OSD.FromInteger(CrossingFlags);
            if (CrossingFlags != 0)
            {
                args["crossExtraFlags"] = OSD.FromInteger(CrossExtraFlags);
            }

            args["active_group_id"]   = OSD.FromUUID(ActiveGroupID);
            args["active_group_name"] = OSD.FromString(ActiveGroupName);
            if (ActiveGroupTitle != null)
            {
                args["active_group_title"] = OSD.FromString(ActiveGroupTitle);
            }

            if (ChildrenCapSeeds != null && ChildrenCapSeeds.Count > 0)
            {
                OSDArray childrenSeeds = new OSDArray(ChildrenCapSeeds.Count);
                foreach (KeyValuePair <ulong, string> kvp in ChildrenCapSeeds)
                {
                    OSDMap pair = new OSDMap();
                    pair["handle"] = OSD.FromString(kvp.Key.ToString());
                    pair["seed"]   = OSD.FromString(kvp.Value);
                    childrenSeeds.Add(pair);
                }
                args["children_seeds"] = childrenSeeds;
            }

            if ((Anims != null) && (Anims.Length > 0))
            {
                OSDArray anims = new OSDArray(Anims.Length);
                foreach (Animation aanim in Anims)
                {
                    anims.Add(aanim.PackUpdateMessage());
                }
                args["animations"] = anims;
            }

            if (DefaultAnim != null)
            {
                args["default_animation"] = DefaultAnim.PackUpdateMessage();
            }

            if (AnimState != null)
            {
                args["animation_state"] = AnimState.PackUpdateMessage();
            }

            if (MovementAnimationOverRides.Count > 0)
            {
                OSDArray AOs = new OSDArray(MovementAnimationOverRides.Count);
                {
                    foreach (KeyValuePair <string, UUID> kvp in MovementAnimationOverRides)
                    {
                        OSDMap ao = new OSDMap(2);
                        ao["state"] = OSD.FromString(kvp.Key);
                        ao["uuid"]  = OSD.FromUUID(kvp.Value);
                        AOs.Add(ao);
                    }
                }
                args["movementAO"] = AOs;
            }

            if (MotionState != 0)
            {
                args["motion_state"] = OSD.FromInteger(MotionState);
            }

            if (Appearance != null)
            {
                args["packed_appearance"] = Appearance.Pack(ctx);
            }

            if ((Controllers != null) && (Controllers.Length > 0))
            {
                OSDArray controls = new OSDArray(Controllers.Length);
                foreach (ControllerData ctl in Controllers)
                {
                    controls.Add(ctl.PackUpdateMessage());
                }
                args["controllers"] = controls;
            }

            if ((CallbackURI != null) && (!CallbackURI.Equals("")))
            {
                args["callback_uri"] = OSD.FromString(CallbackURI);
            }

            if ((NewCallbackURI != null) && (!NewCallbackURI.Equals("")))
            {
                args["cb_uri"] = OSD.FromString(NewCallbackURI);
            }

            // Attachment objects for fatpack messages
            if (AttachmentObjects != null)
            {
                int      i       = 0;
                OSDArray attObjs = new OSDArray(AttachmentObjects.Count);
                foreach (ISceneObject so in AttachmentObjects)
                {
                    OSDMap info = new OSDMap(4);
                    info["sog"]      = OSD.FromString(so.ToXml2());
                    info["extra"]    = OSD.FromString(so.ExtraToXmlString());
                    info["modified"] = OSD.FromBoolean(so.HasGroupChanged);
                    try
                    {
                        info["state"] = OSD.FromString(AttachmentObjectStates[i++]);
                    }
                    catch (IndexOutOfRangeException)
                    {
                        m_log.WarnFormat("[CHILD AGENT DATA]: scripts list is shorter than object list.");
                    }

                    attObjs.Add(info);
                }
                args["attach_objects"] = attObjs;
            }

            args["parent_part"] = OSD.FromUUID(ParentPart);
            args["sit_offset"]  = OSD.FromString(SitOffset.ToString());

            return(args);
        }
Exemplo n.º 7
0
        public string RenderMaterialsPostCap(string request, string path,
                                             string param, IOSHttpRequest httpRequest,
                                             IOSHttpResponse httpResponse)
        {
            m_log.Debug("[MaterialsDemoModule]: POST cap handler");

            OSDMap req  = (OSDMap)OSDParser.DeserializeLLSDXml(request);
            OSDMap resp = new OSDMap();

            OSDMap materialsFromViewer = null;

            OSDArray respArr = new OSDArray();

            if (req.ContainsKey("Zipped"))
            {
                OSD osd = null;

                byte[] inBytes = req["Zipped"].AsBinary();

                try
                {
                    osd = ZDecompressBytesToOsd(inBytes);

                    if (osd != null)
                    {
                        if (osd is OSDArray) // assume array of MaterialIDs designating requested material entries
                        {
                            foreach (OSD elem in (OSDArray)osd)
                            {
                                try
                                {
                                    UUID id = new UUID(elem.AsBinary(), 0);

                                    lock (m_knownMaterials)
                                    {
                                        if (m_knownMaterials.ContainsKey(id))
                                        {
                                            m_log.Info("[MaterialsDemoModule]: request for known material ID: " + id.ToString());
                                            OSDMap matMap = new OSDMap();
                                            matMap["ID"] = OSD.FromBinary(id.GetBytes());

                                            matMap["Material"] = m_knownMaterials[id];
                                            respArr.Add(matMap);
                                        }
                                        else
                                        {
                                            m_log.Info("[MaterialsDemoModule]: request for UNKNOWN material ID: " + id.ToString());
                                        }
                                    }
                                }
                                catch (Exception e)
                                {
                                    // report something here?
                                    continue;
                                }
                            }
                        }
                        else if (osd is OSDMap) // reqest to assign a material
                        {
                            materialsFromViewer = osd as OSDMap;

                            if (materialsFromViewer.ContainsKey("FullMaterialsPerFace"))
                            {
                                OSD matsOsd = materialsFromViewer["FullMaterialsPerFace"];
                                if (matsOsd is OSDArray)
                                {
                                    OSDArray matsArr = matsOsd as OSDArray;

                                    try
                                    {
                                        foreach (OSDMap matsMap in matsArr)
                                        {
                                            m_log.Debug("[MaterialsDemoModule]: processing matsMap: " + OSDParser.SerializeJsonString(matsMap));

                                            uint matLocalID = 0;
                                            try { matLocalID = matsMap["ID"].AsUInteger(); }
                                            catch (Exception e) { m_log.Warn("[MaterialsDemoModule]: cannot decode \"ID\" from matsMap: " + e.Message); }
                                            m_log.Debug("[MaterialsDemoModule]: matLocalId: " + matLocalID.ToString());


                                            OSDMap mat = null;
                                            try { mat = matsMap["Material"] as OSDMap; }
                                            catch (Exception e) { m_log.Warn("[MaterialsDemoModule]: cannot decode \"Material\" from matsMap: " + e.Message); }
                                            m_log.Debug("[MaterialsDemoModule]: mat: " + OSDParser.SerializeJsonString(mat));

                                            UUID id = HashOsd(mat);
                                            lock (m_knownMaterials)
                                                m_knownMaterials[id] = mat;


                                            var sop = m_scene.GetSceneObjectPart(matLocalID);
                                            if (sop == null)
                                            {
                                                m_log.Debug("[MaterialsDemoModule]: null SOP for localId: " + matLocalID.ToString());
                                            }
                                            else
                                            {
                                                var te = new Primitive.TextureEntry(sop.Shape.TextureEntry, 0, sop.Shape.TextureEntry.Length);

                                                if (te == null)
                                                {
                                                    m_log.Debug("[MaterialsDemoModule]: null TextureEntry for localId: " + matLocalID.ToString());
                                                }
                                                else
                                                {
                                                    int face = -1;

                                                    if (matsMap.ContainsKey("Face"))
                                                    {
                                                        face = matsMap["Face"].AsInteger();
                                                        if (te.FaceTextures == null) // && face == 0)
                                                        {
                                                            if (te.DefaultTexture == null)
                                                            {
                                                                m_log.Debug("[MaterialsDemoModule]: te.DefaultTexture is null");
                                                            }
                                                            else
                                                            {
                                                                te.DefaultTexture.MaterialID = id;
                                                            }
                                                        }
                                                        else
                                                        {
                                                            if (te.FaceTextures.Length >= face - 1)
                                                            {
                                                                if (te.FaceTextures[face] == null)
                                                                {
                                                                    te.DefaultTexture.MaterialID = id;
                                                                }
                                                                else
                                                                {
                                                                    te.FaceTextures[face].MaterialID = id;
                                                                }
                                                            }
                                                        }
                                                    }
                                                    else
                                                    {
                                                        if (te.DefaultTexture != null)
                                                        {
                                                            te.DefaultTexture.MaterialID = id;
                                                        }
                                                    }

                                                    m_log.Debug("[MaterialsDemoModule]: setting material ID for face " + face.ToString() + " to " + id.ToString());

                                                    //we cant use sop.UpdateTextureEntry(te); because it filters so do it manually

                                                    if (sop.ParentGroup != null)
                                                    {
                                                        sop.Shape.TextureEntry = te.GetBytes();
                                                        sop.TriggerScriptChangedEvent(Changed.TEXTURE);
                                                        sop.UpdateFlag = UpdateRequired.FULL;
                                                        sop.ParentGroup.HasGroupChanged = true;

                                                        sop.ScheduleFullUpdate();

                                                        StoreMaterialsForPart(sop);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    catch (Exception e)
                                    {
                                        m_log.Warn("[MaterialsDemoModule]: exception processing received material: " + e.Message);
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    m_log.Warn("[MaterialsDemoModule]: exception decoding zipped CAP payload: " + e.Message);
                    //return "";
                }
                m_log.Debug("[MaterialsDemoModule]: knownMaterials.Count: " + m_knownMaterials.Count.ToString());
            }


            resp["Zipped"] = ZCompressOSD(respArr, false);
            string response = OSDParser.SerializeLLSDXmlString(resp);

            //m_log.Debug("[MaterialsDemoModule]: cap request: " + request);
            m_log.Debug("[MaterialsDemoModule]: cap request (zipped portion): " + ZippedOsdBytesToString(req["Zipped"].AsBinary()));
            m_log.Debug("[MaterialsDemoModule]: cap response: " + response);
            return(response);
        }
Exemplo n.º 8
0
        public string RenderMaterialsPostCap(string request, UUID agentID)
        {
            OSDMap req  = (OSDMap)OSDParser.DeserializeLLSDXml(request);
            OSDMap resp = new OSDMap();

            OSDMap materialsFromViewer = null;

            OSDArray respArr = new OSDArray();

            if (req.ContainsKey("Zipped"))
            {
                OSD osd = null;

                byte[] inBytes = req["Zipped"].AsBinary();

                try
                {
                    osd = ZDecompressBytesToOsd(inBytes);

                    if (osd != null)
                    {
                        if (osd is OSDArray) // assume array of MaterialIDs designating requested material entries
                        {
                            foreach (OSD elem in (OSDArray)osd)
                            {
                                try
                                {
                                    UUID id = new UUID(elem.AsBinary(), 0);

                                    lock (m_regionMaterials)
                                    {
                                        if (m_regionMaterials.ContainsKey(id))
                                        {
                                            OSDMap matMap = new OSDMap();
                                            matMap["ID"]       = OSD.FromBinary(id.GetBytes());
                                            matMap["Material"] = m_regionMaterials[id];
                                            respArr.Add(matMap);
                                        }
                                        else
                                        {
                                            m_log.Warn("[Materials]: request for unknown material ID: " + id.ToString());

                                            // Theoretically we could try to load the material from the assets service,
                                            // but that shouldn't be necessary because the viewer should only request
                                            // materials that exist in a prim on the region, and all of these materials
                                            // are already stored in m_regionMaterials.
                                        }
                                    }
                                }
                                catch (Exception e)
                                {
                                    m_log.Error("Error getting materials in response to viewer request", e);
                                    continue;
                                }
                            }
                        }
                        else if (osd is OSDMap) // request to assign a material
                        {
                            materialsFromViewer = osd as OSDMap;

                            if (materialsFromViewer.ContainsKey("FullMaterialsPerFace"))
                            {
                                OSD matsOsd = materialsFromViewer["FullMaterialsPerFace"];
                                if (matsOsd is OSDArray)
                                {
                                    OSDArray matsArr = matsOsd as OSDArray;

                                    try
                                    {
                                        foreach (OSDMap matsMap in matsArr)
                                        {
                                            uint primLocalID = 0;
                                            try
                                            {
                                                primLocalID = matsMap["ID"].AsUInteger();
                                            }
                                            catch (Exception e)
                                            {
                                                m_log.Warn("[Materials]: cannot decode \"ID\" from matsMap: " + e.Message);
                                                continue;
                                            }

                                            OSDMap mat = null;
                                            try
                                            {
                                                mat = matsMap["Material"] as OSDMap;
                                            }
                                            catch (Exception e)
                                            {
                                                m_log.Warn("[Materials]: cannot decode \"Material\" from matsMap: " + e.Message);
                                                continue;
                                            }

                                            SceneObjectPart sop = m_scene.GetSceneObjectPart(primLocalID);
                                            if (sop == null)
                                            {
                                                m_log.WarnFormat("[Materials]: SOP not found for localId: {0}", primLocalID.ToString());
                                                continue;
                                            }

                                            if (!m_scene.Permissions.CanEditObject(sop.UUID, agentID))
                                            {
                                                m_log.WarnFormat("User {0} can't edit object {1} {2}", agentID, sop.Name, sop.UUID);
                                                continue;
                                            }

                                            Primitive.TextureEntry te = new Primitive.TextureEntry(sop.Shape.TextureEntry, 0, sop.Shape.TextureEntry.Length);
                                            if (te == null)
                                            {
                                                m_log.WarnFormat("[Materials]: Error in TextureEntry for SOP {0} {1}", sop.Name, sop.UUID);
                                                continue;
                                            }

                                            UUID id;
                                            if (mat == null)
                                            {
                                                // This happens then the user removes a material from a prim
                                                id = UUID.Zero;
                                            }
                                            else
                                            {
                                                id = StoreMaterialAsAsset(agentID, mat, sop);
                                            }

                                            int face = -1;

                                            if (matsMap.ContainsKey("Face"))
                                            {
                                                face = matsMap["Face"].AsInteger();
                                                Primitive.TextureEntryFace faceEntry = te.CreateFace((uint)face);
                                                faceEntry.MaterialID = id;
                                            }
                                            else
                                            {
                                                if (te.DefaultTexture == null)
                                                {
                                                    m_log.WarnFormat("[Materials]: TextureEntry.DefaultTexture is null in {0} {1}", sop.Name, sop.UUID);
                                                }
                                                else
                                                {
                                                    te.DefaultTexture.MaterialID = id;
                                                }
                                            }

                                            //m_log.DebugFormat("[Materials]: in \"{0}\" {1}, setting material ID for face {2} to {3}", sop.Name, sop.UUID, face, id);

                                            // We can't use sop.UpdateTextureEntry(te) because it filters, so do it manually
                                            sop.Shape.TextureEntry = te.GetBytes();

                                            if (sop.ParentGroup != null)
                                            {
                                                sop.TriggerScriptChangedEvent(Changed.TEXTURE);
                                                sop.UpdateFlag = UpdateRequired.FULL;
                                                sop.ParentGroup.HasGroupChanged = true;
                                                sop.ScheduleFullUpdate();
                                            }
                                        }
                                    }
                                    catch (Exception e)
                                    {
                                        m_log.Warn("[Materials]: exception processing received material ", e);
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    m_log.Warn("[Materials]: exception decoding zipped CAP payload ", e);
                    //return "";
                }
            }

            resp["Zipped"] = ZCompressOSD(respArr, false);
            string response = OSDParser.SerializeLLSDXmlString(resp);

            //m_log.Debug("[Materials]: cap request: " + request);
            //m_log.Debug("[Materials]: cap request (zipped portion): " + ZippedOsdBytesToString(req["Zipped"].AsBinary()));
            //m_log.Debug("[Materials]: cap response: " + response);
            return(response);
        }
Exemplo n.º 9
0
        OSD AssetResources(bool upload)
        {
            OSDArray      instanceList = new OSDArray();
            List <byte[]> meshes       = new List <byte[]>();
            List <byte[]> textures     = new List <byte[]>();

            foreach (var prim in Prims)
            {
                OSDMap primMap = new OSDMap();

                OSDArray faceList = new OSDArray();

                foreach (var face in prim.Faces)
                {
                    OSDMap faceMap = new OSDMap();

                    faceMap["diffuse_color"] = face.Material.DiffuseColor;
                    faceMap["fullbright"]    = false;

                    if (face.Material.TextureData != null)
                    {
                        int index;
                        if (ImgIndex.ContainsKey(face.Material.Texture))
                        {
                            index = ImgIndex[face.Material.Texture];
                        }
                        else
                        {
                            index = Images.Count;
                            ImgIndex[face.Material.Texture] = index;
                            Images.Add(face.Material.TextureData);
                        }
                        faceMap["image"]    = index;
                        faceMap["scales"]   = 1.0f;
                        faceMap["scalet"]   = 1.0f;
                        faceMap["offsets"]  = 0.0f;
                        faceMap["offsett"]  = 0.0f;
                        faceMap["imagerot"] = 0.0f;
                    }

                    faceList.Add(faceMap);
                }

                primMap["face_list"] = faceList;

                primMap["position"] = prim.Position;
                primMap["rotation"] = prim.Rotation;
                primMap["scale"]    = prim.Scale;

                primMap["material"]           = 3; // always sent as "wood" material
                primMap["physics_shape_type"] = 2; // always sent as "convex hull";
                primMap["mesh"] = meshes.Count;
                meshes.Add(prim.Asset);


                instanceList.Add(primMap);
            }

            OSDMap resources = new OSDMap();

            resources["instance_list"] = instanceList;

            OSDArray meshList = new OSDArray();

            foreach (var mesh in meshes)
            {
                meshList.Add(OSD.FromBinary(mesh));
            }
            resources["mesh_list"] = meshList;

            OSDArray textureList = new OSDArray();

            for (int i = 0; i < Images.Count; i++)
            {
                if (upload)
                {
                    textureList.Add(new OSDBinary(Images[i]));
                }
                else
                {
                    textureList.Add(new OSDBinary(Utils.EmptyBytes));
                }
            }

            resources["texture_list"] = textureList;

            resources["metric"] = "MUT_Unspecified";

            return(resources);
        }
Exemplo n.º 10
0
        public OSDMap GetOSD()
        {
            OSDMap map = new OSDMap();

            map["id"]       = OSD.FromUUID(ID);
            map["local_id"] = OSD.FromInteger(LocalID);

            OSDArray blacklist = new OSDArray();

            if (AccessBlackList != null)
            {
                for (int i = 0; i < AccessBlackList.Count; i++)
                {
                    blacklist.Add(AccessBlackList[i].GetOSD());
                }
            }
            map["access_black_list"] = blacklist;

            OSDArray whitelist = new OSDArray();

            if (AccessWhiteList != null)
            {
                for (int i = 0; i < AccessWhiteList.Count; i++)
                {
                    whitelist.Add(AccessWhiteList[i].GetOSD());
                }
            }
            map["access_white_list"] = whitelist;

            map["auth_buyer_id"]    = OSD.FromUUID(AuthBuyerID);
            map["auto_return_time"] = OSD.FromInteger(AutoReturnTime);
            map["bitmap"]           = OSD.FromBinary(Bitmap);
            map["category"]         = OSD.FromInteger((int)Category);
            map["claim_date"]       = OSD.FromDate(ClaimDate);
            map["desc"]             = OSD.FromString(Desc);
            map["dwell"]            = OSD.FromReal(Dwell);
            map["flags"]            = OSD.FromInteger((uint)Flags);
            map["group_id"]         = OSD.FromUUID(GroupID);
            map["is_group_owned"]   = OSD.FromBoolean(IsGroupOwned);
            map["landing"]          = OSD.FromInteger((int)Landing);
            map["max_prims"]        = OSD.FromInteger(MaxPrims);

            OSDMap media = new OSDMap
            {
                { "auto_scale", OSD.FromBoolean(Media.MediaAutoScale) },
                { "desc", OSD.FromString(Media.MediaDesc) },
                { "height", OSD.FromInteger(Media.MediaHeight) },
                { "id", OSD.FromUUID(Media.MediaID) },
                { "loop", OSD.FromBoolean(Media.MediaLoop) },
                { "type", OSD.FromString(Media.MediaType) },
                { "url", OSD.FromString(Media.MediaURL) },
                { "width", OSD.FromInteger(Media.MediaWidth) }
            };

            map["parcel_media"] = media;

            map["music_url"]           = OSD.FromString(MusicURL);
            map["name"]                = OSD.FromString(Name);
            map["obscure_media"]       = OSD.FromBoolean(ObscureMedia);
            map["obscure_music"]       = OSD.FromBoolean(ObscureMusic);
            map["owner_id"]            = OSD.FromUUID(OwnerID);
            map["pass_hours"]          = OSD.FromReal(PassHours);
            map["pass_price"]          = OSD.FromInteger(PassPrice);
            map["deny_age_unverified"] = OSD.FromBoolean(DenyAgeUnverified);
            map["deny_anonymous"]      = OSD.FromBoolean(DenyAnonymous);
            map["push_override"]       = OSD.FromBoolean(PushOverride);
            map["sale_price"]          = OSD.FromInteger(SalePrice);
            map["snapshot_id"]         = OSD.FromUUID(SnapshotID);
            map["status"]              = OSD.FromInteger((int)Status);
            map["landing_location"]    = OSD.FromVector3(LandingLocation);
            map["landing_look_at"]     = OSD.FromVector3(LandingLookAt);

            return(map);
        }
Exemplo n.º 11
0
        public static OSD PlacesQuery(PlacesReplyPacket PlacesReply, string[] regionType)
        {
            OSDMap placesReply = new OSDMap {
                { "message", OSD.FromString("PlacesReplyMessage") }
            };

            OSDMap   body         = new OSDMap();
            OSDArray agentData    = new OSDArray();
            OSDMap   agentDataMap = new OSDMap
            {
                { "AgentID", OSD.FromUUID(PlacesReply.AgentData.AgentID) },
                { "QueryID", OSD.FromUUID(PlacesReply.AgentData.QueryID) },
                { "TransactionID", OSD.FromUUID(PlacesReply.TransactionData.TransactionID) }
            };

            agentData.Add(agentDataMap);
            body.Add("AgentData", agentData);

            OSDArray QueryData = new OSDArray();

#if (!ISWIN)
            int i = 0;
            foreach (PlacesReplyPacket.QueryDataBlock groupDataBlock in PlacesReply.QueryData)
            {
                OSDMap QueryDataMap = new OSDMap();
                QueryDataMap.Add("ActualArea", OSD.FromInteger(groupDataBlock.ActualArea));
                QueryDataMap.Add("BillableArea", OSD.FromInteger(groupDataBlock.BillableArea));
                QueryDataMap.Add("Description", OSD.FromBinary(groupDataBlock.Desc));
                QueryDataMap.Add("Dwell", OSD.FromInteger((int)groupDataBlock.Dwell));
                QueryDataMap.Add("Flags", OSD.FromString(Convert.ToString(groupDataBlock.Flags)));
                QueryDataMap.Add("GlobalX", OSD.FromInteger((int)groupDataBlock.GlobalX));
                QueryDataMap.Add("GlobalY", OSD.FromInteger((int)groupDataBlock.GlobalY));
                QueryDataMap.Add("GlobalZ", OSD.FromInteger((int)groupDataBlock.GlobalZ));
                QueryDataMap.Add("Name", OSD.FromBinary(groupDataBlock.Name));
                QueryDataMap.Add("OwnerID", OSD.FromUUID(groupDataBlock.OwnerID));
                QueryDataMap.Add("SimName", OSD.FromBinary(groupDataBlock.SimName));
                QueryDataMap.Add("SnapShotID", OSD.FromUUID(groupDataBlock.SnapshotID));
                QueryDataMap.Add("ProductSku", OSD.FromString(regionType[i]));
                QueryDataMap.Add("Price", OSD.FromInteger(groupDataBlock.Price));

                QueryData.Add(QueryDataMap);
                i++;
            }
#else
            int[] i = { 0 };
            foreach (OSDMap QueryDataMap in PlacesReply.QueryData.Select(groupDataBlock => new OSDMap
            {
                { "ActualArea", OSD.FromInteger(groupDataBlock.ActualArea) },
                { "BillableArea", OSD.FromInteger(groupDataBlock.BillableArea) },
                { "Description", OSD.FromBinary(groupDataBlock.Desc) },
                { "Dwell", OSD.FromInteger((int)groupDataBlock.Dwell) },
                { "Flags", OSD.FromString(Convert.ToString(groupDataBlock.Flags)) },
                { "GlobalX", OSD.FromInteger((int)groupDataBlock.GlobalX) },
                { "GlobalY", OSD.FromInteger((int)groupDataBlock.GlobalY) },
                { "GlobalZ", OSD.FromInteger((int)groupDataBlock.GlobalZ) },
                { "Name", OSD.FromBinary(groupDataBlock.Name) },
                { "OwnerID", OSD.FromUUID(groupDataBlock.OwnerID) },
                { "SimName", OSD.FromBinary(groupDataBlock.SimName) },
                { "SnapShotID", OSD.FromUUID(groupDataBlock.SnapshotID) },
                { "ProductSku", OSD.FromString(regionType[i[0]]) },
                { "Price", OSD.FromInteger(groupDataBlock.Price) }
            }))
            {
                QueryData.Add(QueryDataMap);
                i[0]++;
            }
#endif
            body.Add("QueryData", QueryData);
            placesReply.Add("QueryData[]", body);

            placesReply.Add("body", body);

            return(placesReply);
        }
        public virtual OSDMap Pack()
        {
//            m_log.InfoFormat("[CHILDAGENTDATAUPDATE] Pack data");

            OSDMap args = new OSDMap();

            args["message_type"] = OSD.FromString("AgentData");

            args["region_id"]    = OSD.FromString(RegionID.ToString());
            args["circuit_code"] = OSD.FromString(CircuitCode.ToString());
            args["agent_uuid"]   = OSD.FromUUID(AgentID);
            args["session_uuid"] = OSD.FromUUID(SessionID);

            args["position"]  = OSD.FromString(Position.ToString());
            args["velocity"]  = OSD.FromString(Velocity.ToString());
            args["center"]    = OSD.FromString(Center.ToString());
            args["size"]      = OSD.FromString(Size.ToString());
            args["at_axis"]   = OSD.FromString(AtAxis.ToString());
            args["left_axis"] = OSD.FromString(LeftAxis.ToString());
            args["up_axis"]   = OSD.FromString(UpAxis.ToString());

            //backwards compatibility
            args["changed_grid"]  = OSD.FromBoolean(SenderWantsToWaitForRoot);
            args["wait_for_root"] = OSD.FromBoolean(SenderWantsToWaitForRoot);
            args["far"]           = OSD.FromReal(Far);
            args["aspect"]        = OSD.FromReal(Aspect);

            if ((Throttles != null) && (Throttles.Length > 0))
            {
                args["throttles"] = OSD.FromBinary(Throttles);
            }

            args["locomotion_state"] = OSD.FromString(LocomotionState.ToString());
            args["head_rotation"]    = OSD.FromString(HeadRotation.ToString());
            args["body_rotation"]    = OSD.FromString(BodyRotation.ToString());
            args["control_flags"]    = OSD.FromString(ControlFlags.ToString());

            args["energy_level"] = OSD.FromReal(EnergyLevel);
            args["god_level"]    = OSD.FromString(GodLevel.ToString());
            args["always_run"]   = OSD.FromBoolean(AlwaysRun);
            args["prey_agent"]   = OSD.FromUUID(PreyAgent);
            args["agent_access"] = OSD.FromString(AgentAccess.ToString());

            args["active_group_id"] = OSD.FromUUID(ActiveGroupID);

            if ((Groups != null) && (Groups.Length > 0))
            {
                OSDArray groups = new OSDArray(Groups.Length);
                foreach (AgentGroupData agd in Groups)
                {
                    groups.Add(agd.PackUpdateMessage());
                }
                args["groups"] = groups;
            }

            if ((Anims != null) && (Anims.Length > 0))
            {
                OSDArray anims = new OSDArray(Anims.Length);
                foreach (Animation aanim in Anims)
                {
                    anims.Add(aanim.PackUpdateMessage());
                }
                args["animations"] = anims;
            }

            if (DefaultAnim != null)
            {
                args["default_animation"] = DefaultAnim.PackUpdateMessage();
            }

            if (AnimState != null)
            {
                args["animation_state"] = AnimState.PackUpdateMessage();
            }

            if (Appearance != null)
            {
                args["packed_appearance"] = Appearance.Pack();
            }

            //if ((AgentTextures != null) && (AgentTextures.Length > 0))
            //{
            //    OSDArray textures = new OSDArray(AgentTextures.Length);
            //    foreach (UUID uuid in AgentTextures)
            //        textures.Add(OSD.FromUUID(uuid));
            //    args["agent_textures"] = textures;
            //}

            // The code to pack textures, visuals, wearables and attachments
            // should be removed; packed appearance contains the full appearance
            // This is retained for backward compatibility only
            if (Appearance.Texture != null)
            {
                byte[] rawtextures = Appearance.Texture.GetBytes();
                args["texture_entry"] = OSD.FromBinary(rawtextures);
            }

            if ((Appearance.VisualParams != null) && (Appearance.VisualParams.Length > 0))
            {
                args["visual_params"] = OSD.FromBinary(Appearance.VisualParams);
            }

            // We might not pass this in all cases...
            if ((Appearance.Wearables != null) && (Appearance.Wearables.Length > 0))
            {
                OSDArray wears = new OSDArray(Appearance.Wearables.Length);
                foreach (AvatarWearable awear in Appearance.Wearables)
                {
                    wears.Add(awear.Pack());
                }

                args["wearables"] = wears;
            }

            List <AvatarAttachment> attachments = Appearance.GetAttachments();

            if ((attachments != null) && (attachments.Count > 0))
            {
                OSDArray attachs = new OSDArray(attachments.Count);
                foreach (AvatarAttachment att in attachments)
                {
                    attachs.Add(att.Pack());
                }
                args["attachments"] = attachs;
            }
            // End of code to remove

            if ((Controllers != null) && (Controllers.Length > 0))
            {
                OSDArray controls = new OSDArray(Controllers.Length);
                foreach (ControllerData ctl in Controllers)
                {
                    controls.Add(ctl.PackUpdateMessage());
                }
                args["controllers"] = controls;
            }

            if ((CallbackURI != null) && (!CallbackURI.Equals("")))
            {
                args["callback_uri"] = OSD.FromString(CallbackURI);
            }

            // Attachment objects for fatpack messages
            if (AttachmentObjects != null)
            {
                int      i       = 0;
                OSDArray attObjs = new OSDArray(AttachmentObjects.Count);
                foreach (ISceneObject so in AttachmentObjects)
                {
                    OSDMap info = new OSDMap(4);
                    info["sog"]      = OSD.FromString(so.ToXml2());
                    info["extra"]    = OSD.FromString(so.ExtraToXmlString());
                    info["modified"] = OSD.FromBoolean(so.HasGroupChanged);
                    try
                    {
                        info["state"] = OSD.FromString(AttachmentObjectStates[i++]);
                    }
                    catch (IndexOutOfRangeException)
                    {
                        m_log.WarnFormat("[CHILD AGENT DATA]: scripts list is shorter than object list.");
                    }

                    attObjs.Add(info);
                }
                args["attach_objects"] = attObjs;
            }
            return(args);
        }
Exemplo n.º 13
0
        public static OSD CrossRegion(ulong handle, Vector3 pos, Vector3 lookAt,
                                      IPAddress address, int port,
                                      string capsURL, UUID agentID, UUID sessionID, int RegionSizeX, int RegionSizeY)
        {
            OSDArray lookAtArr = new OSDArray(3)
            {
                OSD.FromReal(lookAt.X), OSD.FromReal(lookAt.Y), OSD.FromReal(lookAt.Z)
            };

            OSDArray positionArr = new OSDArray(3)
            {
                OSD.FromReal(pos.X),
                OSD.FromReal(pos.Y),
                OSD.FromReal(pos.Z)
            };

            OSDMap infoMap = new OSDMap(2)
            {
                { "LookAt", lookAtArr }, { "Position", positionArr }
            };

            OSDArray infoArr = new OSDArray(1)
            {
                infoMap
            };

            OSDMap agentDataMap = new OSDMap(2)
            {
                { "AgentID", OSD.FromUUID(agentID) },
                { "SessionID", OSD.FromUUID(sessionID) }
            };

            OSDArray agentDataArr = new OSDArray(1)
            {
                agentDataMap
            };

            OSDMap regionDataMap = new OSDMap(4)
            {
                { "RegionHandle", OSD.FromBinary(ulongToByteArray(handle)) },
                { "SeedCapability", OSD.FromString(capsURL) },
                { "SimIP", OSD.FromBinary(address.GetAddressBytes()) },
                { "SimPort", OSD.FromInteger(port) },
                { "RegionSizeX", OSD.FromUInteger((uint)RegionSizeX) },
                { "RegionSizeY", OSD.FromUInteger((uint)RegionSizeY) }
            };

            OSDArray regionDataArr = new OSDArray(1)
            {
                regionDataMap
            };

            OSDMap llsdBody = new OSDMap(3)
            {
                { "Info", infoArr },
                { "AgentData", agentDataArr },
                { "RegionData", regionDataArr }
            };

            return(buildEvent("CrossedRegion", llsdBody));
        }
Exemplo n.º 14
0
        /// <summary>
        /// Convert the value of the given property to OSD type.
        /// </summary>
        /// <param name="property"></param>
        /// <returns></returns>
        public OSDArray ToOSDArray()
        {
            //DebugLog.WarnFormat("[SYNCED PROPERTY] ToOSDArray called for property {0}", Property.ToString());
            lock (m_lock)
            {
                OSDArray propertyData = new OSDArray();
                propertyData.Add(OSD.FromInteger((uint)Property));
                propertyData.Add(OSD.FromLong(LastUpdateTimeStamp));
                propertyData.Add(OSD.FromString(LastUpdateSyncID));

                OSD value = null;
                switch (Property)
                {
                ///////////////////////////////////////
                //SOP properties with complex structure
                ///////////////////////////////////////
                case SyncableProperties.Type.AgentCircuitData:
                case SyncableProperties.Type.AvatarAppearance:
                    value = (OSDMap)LastUpdateValue;
                    break;

                case SyncableProperties.Type.Animations:
                    value = (OSDArray)LastUpdateValue;
                    break;

                ////////////////////////////
                // Integer/enum type properties
                ////////////////////////////
                case SyncableProperties.Type.CreationDate:              // int
                case SyncableProperties.Type.LinkNum:                   // int
                case SyncableProperties.Type.OwnershipCost:             // int
                case SyncableProperties.Type.SalePrice:                 // int
                case SyncableProperties.Type.ScriptAccessPin:           // int
                case SyncableProperties.Type.AggregateScriptEvents:     // enum
                case SyncableProperties.Type.Flags:                     // enum
                case SyncableProperties.Type.LocalFlags:                // enum
                case SyncableProperties.Type.PresenceType:              // enum
                    value = OSD.FromInteger((int)LastUpdateValue);
                    break;

                ////////////////////////////
                // Byte type properties
                ////////////////////////////
                case SyncableProperties.Type.ClickAction:
                case SyncableProperties.Type.Material:
                case SyncableProperties.Type.ObjectSaleType:
                    value = OSD.FromInteger((byte)LastUpdateValue);
                    break;

                ////////////////////////////
                // Boolean type properties
                ////////////////////////////
                case SyncableProperties.Type.AllowedDrop:
                case SyncableProperties.Type.IsAttachment:
                case SyncableProperties.Type.PassTouches:
                case SyncableProperties.Type.VolumeDetectActive:
                case SyncableProperties.Type.Flying:
                case SyncableProperties.Type.IsColliding:
                case SyncableProperties.Type.CollidingGround:
                case SyncableProperties.Type.Kinematic:
                case SyncableProperties.Type.IsSelected:
                case SyncableProperties.Type.AllowMovement:
                    value = OSD.FromBoolean((bool)LastUpdateValue);
                    break;

                ////////////////////////////
                // Vector3 type properties
                ////////////////////////////
                case SyncableProperties.Type.AngularVelocity:
                case SyncableProperties.Type.AttachedPos:
                case SyncableProperties.Type.GroupPosition:
                case SyncableProperties.Type.OffsetPosition:
                case SyncableProperties.Type.Scale:
                case SyncableProperties.Type.SitTargetPosition:
                case SyncableProperties.Type.SitTargetPositionLL:
                case SyncableProperties.Type.SOP_Acceleration:
                case SyncableProperties.Type.Velocity:
                case SyncableProperties.Type.Force:
                case SyncableProperties.Type.PA_Acceleration:
                case SyncableProperties.Type.PA_Velocity:
                case SyncableProperties.Type.PA_TargetVelocity:
                case SyncableProperties.Type.Position:
                case SyncableProperties.Type.RotationalVelocity:
                case SyncableProperties.Type.Size:
                case SyncableProperties.Type.Torque:
                case SyncableProperties.Type.AbsolutePosition:
                    value = OSD.FromVector3((Vector3)LastUpdateValue);
                    break;

                ////////////////////////////
                // UUID type properties
                ////////////////////////////
                case SyncableProperties.Type.AttachedAvatar:
                case SyncableProperties.Type.CollisionSound:
                case SyncableProperties.Type.CreatorID:
                case SyncableProperties.Type.FolderID:
                case SyncableProperties.Type.GroupID:
                case SyncableProperties.Type.LastOwnerID:
                case SyncableProperties.Type.OwnerID:
                case SyncableProperties.Type.Sound:
                    value = OSD.FromUUID((UUID)LastUpdateValue);
                    break;

                ////////////////////////////
                // UInt type properties
                ////////////////////////////
                case SyncableProperties.Type.LocalId:
                case SyncableProperties.Type.AttachmentPoint:
                case SyncableProperties.Type.BaseMask:
                case SyncableProperties.Type.Category:
                case SyncableProperties.Type.EveryoneMask:
                case SyncableProperties.Type.GroupMask:
                case SyncableProperties.Type.InventorySerial:
                case SyncableProperties.Type.NextOwnerMask:
                case SyncableProperties.Type.OwnerMask:
                case SyncableProperties.Type.AgentControlFlags:
                case SyncableProperties.Type.ParentId:
                    value = OSD.FromUInteger((uint)LastUpdateValue);
                    break;

                ////////////////////////////
                // Float type properties
                ////////////////////////////
                case SyncableProperties.Type.CollisionSoundVolume:
                case SyncableProperties.Type.Buoyancy:
                    value = OSD.FromReal((float)LastUpdateValue);
                    break;

                ////////////////////////////
                // String type properties
                ////////////////////////////
                case SyncableProperties.Type.Color:
                case SyncableProperties.Type.CreatorData:
                case SyncableProperties.Type.Description:
                case SyncableProperties.Type.MediaUrl:
                case SyncableProperties.Type.Name:
                case SyncableProperties.Type.RealRegion:
                case SyncableProperties.Type.Shape:
                case SyncableProperties.Type.SitName:
                case SyncableProperties.Type.TaskInventory:
                case SyncableProperties.Type.Text:
                case SyncableProperties.Type.TouchName:
                    value = OSD.FromString((string)LastUpdateValue);
                    break;

                ////////////////////////////
                // byte[] (binary data) type properties
                ////////////////////////////
                case SyncableProperties.Type.ParticleSystem:
                case SyncableProperties.Type.TextureAnimation:
                    value = OSD.FromBinary((byte[])LastUpdateValue);
                    break;

                ////////////////////////////
                // Quaternion type properties
                ////////////////////////////
                case SyncableProperties.Type.RotationOffset:
                case SyncableProperties.Type.SitTargetOrientation:
                case SyncableProperties.Type.SitTargetOrientationLL:
                case SyncableProperties.Type.Orientation:
                case SyncableProperties.Type.Rotation:
                    value = OSD.FromQuaternion((Quaternion)LastUpdateValue);
                    break;

                default:
                    DebugLog.WarnFormat("[SYNCED PROPERTY] ToOSDArray: No handler for property {0} ", Property);
                    break;
                }
                propertyData.Add(value);
                return(propertyData);
            }
        }
Exemplo n.º 15
0
        public virtual OSDMap Pack()
        {
            // DEBUG ON
            //MainConsole.Instance.WarnFormat("[CHILDAGENTDATAUPDATE] Pack data");
            // DEBUG OFF

            OSDMap args = new OSDMap();

            args["message_type"] = OSD.FromString("AgentData");

            args["region_id"]    = OSD.FromString(RegionID.ToString());
            args["circuit_code"] = OSD.FromString(CircuitCode.ToString());
            args["agent_uuid"]   = OSD.FromUUID(AgentID);
            args["session_uuid"] = OSD.FromUUID(SessionID);

            args["position"]  = OSD.FromString(Position.ToString());
            args["velocity"]  = OSD.FromString(Velocity.ToString());
            args["center"]    = OSD.FromString(Center.ToString());
            args["size"]      = OSD.FromString(Size.ToString());
            args["at_axis"]   = OSD.FromString(AtAxis.ToString());
            args["left_axis"] = OSD.FromString(LeftAxis.ToString());
            args["up_axis"]   = OSD.FromString(UpAxis.ToString());

            args["far"]    = OSD.FromReal(Far);
            args["aspect"] = OSD.FromReal(Aspect);

            if ((Throttles != null) && (Throttles.Length > 0))
            {
                args["throttles"] = OSD.FromBinary(Throttles);
            }

            args["locomotion_state"] = OSD.FromString(LocomotionState.ToString());
            args["head_rotation"]    = OSD.FromString(HeadRotation.ToString());
            args["body_rotation"]    = OSD.FromString(BodyRotation.ToString());
            args["control_flags"]    = OSD.FromString(ControlFlags.ToString());

            args["energy_level"]           = OSD.FromReal(EnergyLevel);
            args["speed"]                  = OSD.FromString(Speed.ToString());
            args["god_level"]              = OSD.FromString(GodLevel.ToString());
            args["draw_distance"]          = OSD.FromReal(DrawDistance);
            args["always_run"]             = OSD.FromBoolean(AlwaysRun);
            args["sent_initial_wearables"] = OSD.FromBoolean(SentInitialWearables);
            args["prey_agent"]             = OSD.FromUUID(PreyAgent);
            args["agent_access"]           = OSD.FromString(AgentAccess.ToString());

            args["active_group_id"] = OSD.FromUUID(ActiveGroupID);
            args["IsCrossing"]      = IsCrossing;

            args["SittingObjects"] = SittingObjects.PackUpdateMessage();

            if ((Anims != null) && (Anims.Length > 0))
            {
                OSDArray anims = new OSDArray(Anims.Length);
                foreach (Animation aanim in Anims)
                {
                    anims.Add(aanim.PackUpdateMessage());
                }
                args["animations"] = anims;
            }

            if (Appearance != null)
            {
                args["packed_appearance"] = Appearance.Pack();
            }

            if ((Controllers != null) && (Controllers.Length > 0))
            {
                OSDArray controls = new OSDArray(Controllers.Length);
                foreach (ControllerData ctl in Controllers)
                {
                    controls.Add(ctl.PackUpdateMessage());
                }
                args["controllers"] = controls;
            }

            return(args);
        }
Exemplo n.º 16
0
        public static OSD InstantMessageParams(UUID fromAgent, string message, UUID toAgent,
                                               string fromName, byte dialog, uint timeStamp, bool offline, int parentEstateID,
                                               Vector3 position, uint ttl, UUID transactionID, bool fromGroup, byte[] binaryBucket)
        {
            OSDMap messageParams = new OSDMap(15);

            messageParams.Add("type", new OSDInteger((int)dialog));

            OSDArray positionArray = new OSDArray(3);

            positionArray.Add(OSD.FromReal(position.X));
            positionArray.Add(OSD.FromReal(position.Y));
            positionArray.Add(OSD.FromReal(position.Z));
            messageParams.Add("position", positionArray);

            messageParams.Add("region_id", new OSDUUID(UUID.Zero));
            messageParams.Add("to_id", new OSDUUID(toAgent));
            messageParams.Add("source", new OSDInteger(0));

            OSDMap data = new OSDMap(1);

            data.Add("binary_bucket", OSD.FromBinary(binaryBucket));
            messageParams.Add("data", data);
            messageParams.Add("message", new OSDString(message));
            messageParams.Add("id", new OSDUUID(transactionID));
            messageParams.Add("from_name", new OSDString(fromName));
            messageParams.Add("timestamp", new OSDInteger((int)timeStamp));
            messageParams.Add("offline", new OSDInteger(offline ? 1 : 0));
            messageParams.Add("parent_estate_id", new OSDInteger(parentEstateID));
            messageParams.Add("ttl", new OSDInteger((int)ttl));
            messageParams.Add("from_id", new OSDUUID(fromAgent));
            messageParams.Add("from_group", new OSDInteger(fromGroup ? 1 : 0));

/*
 *          StringBuilder sb = new StringBuilder(256);
 *          LLSDxmlEncode.AddMap(sb); //messageParams
 *
 *          LLSDxmlEncode.AddElem("type", dialog, sb);
 *          LLSDxmlEncode.AddElem("position", position, sb);
 *          LLSDxmlEncode.AddElem("region_id", UUID.Zero, sb);
 *          LLSDxmlEncode.AddElem("to_id", toAgent, sb);
 *          LLSDxmlEncode.AddElem("source", 0, sb);
 *
 *          LLSDxmlEncode.AddMap("data", sb); //messageParams data
 *          LLSDxmlEncode.AddElem("binary_bucket", binaryBucket, sb);
 *          LLSDxmlEncode.AddEndMap(sb); //messageParams data
 *
 *          LLSDxmlEncode.AddElem("message", message, sb);
 *          LLSDxmlEncode.AddElem("id", transactionID, sb);
 *          LLSDxmlEncode.AddElem("from_name", fromName, sb);
 *          LLSDxmlEncode.AddElem("timestamp", timeStamp, sb);
 *          LLSDxmlEncode.AddElem("offline", (offline ? 1 : 0), sb);
 *          LLSDxmlEncode.AddElem("parent_estate_id", parentEstateID, sb);
 *          LLSDxmlEncode.AddElem("ttl", (int)ttl, sb);
 *          LLSDxmlEncode.AddElem("from_id", fromAgent, sb);
 *          LLSDxmlEncode.AddElem("from_group",fromGroup, sb);
 *
 *          LLSDxmlEncode.AddEndMap(sb); //messageParams
 *          string tt = sb.ToString();
 */
            return(messageParams);
        }
Exemplo n.º 17
0
        public override OSDMap ToOSD()
        {
            OSDMap map = new OSDMap();

            map ["GroupID"]          = OSD.FromUUID(GroupID);
            map ["IsGroupOwned"]     = OSD.FromBoolean(IsGroupOwned);
            map ["OwnerID"]          = OSD.FromUUID(OwnerID);
            map ["Maturity"]         = OSD.FromInteger(Maturity);
            map ["Area"]             = OSD.FromInteger(Area);
            map ["AuctionID"]        = OSD.FromUInteger(AuctionID);
            map ["SalePrice"]        = OSD.FromInteger(SalePrice);
            map ["Dwell"]            = OSD.FromInteger(Dwell);
            map ["Flags"]            = OSD.FromInteger((int)Flags);
            map ["Name"]             = OSD.FromString(Name);
            map ["Description"]      = OSD.FromString(Description);
            map ["LocalID"]          = OSD.FromInteger(LocalID);
            map ["GlobalID"]         = OSD.FromUUID(GlobalID);
            map ["RegionID"]         = OSD.FromUUID(RegionID);
            map ["ScopeID"]          = OSD.FromUUID(ScopeID);
            map ["MediaDescription"] = OSD.FromString(MediaDescription);
            map ["MediaWidth"]       = OSD.FromInteger(MediaWidth);
            map ["MediaHeight"]      = OSD.FromInteger(MediaHeight);
            map ["MediaLoop"]        = OSD.FromBoolean(MediaLoop);
            map ["MediaType"]        = OSD.FromString(MediaType);
            map ["ObscureMedia"]     = OSD.FromBoolean(ObscureMedia);
            map ["ObscureMusic"]     = OSD.FromBoolean(ObscureMusic);
            // 25062016 LibOMV update
            map ["SeeAVs"]        = OSD.FromBoolean(SeeAVS);
            map ["AnyAVSounds"]   = OSD.FromBoolean(AnyAVSounds);
            map ["GroupAVSounds"] = OSD.FromBoolean(GroupAVSounds);
            // End
            map ["SnapshotID"]     = OSD.FromUUID(SnapshotID);
            map ["MediaAutoScale"] = OSD.FromInteger(MediaAutoScale);
            map ["MediaLoopSet"]   = OSD.FromReal(MediaLoopSet);
            map ["MediaURL"]       = OSD.FromString(MediaURL);
            map ["MusicURL"]       = OSD.FromString(MusicURL);
            map ["Bitmap"]         = OSD.FromBinary(Bitmap);
            map ["Category"]       = OSD.FromInteger((int)Category);
            map ["FirstParty"]     = OSD.FromBoolean(FirstParty);
            map ["ClaimDate"]      = OSD.FromInteger(ClaimDate);
            map ["ClaimPrice"]     = OSD.FromInteger(ClaimPrice);
            map ["Status"]         = OSD.FromInteger((int)Status);
            map ["LandingType"]    = OSD.FromInteger(LandingType);
            map ["PassHours"]      = OSD.FromReal(PassHours);
            map ["PassPrice"]      = OSD.FromInteger(PassPrice);
            map ["AuthBuyerID"]    = OSD.FromUUID(AuthBuyerID);
            map ["OtherCleanTime"] = OSD.FromInteger(OtherCleanTime);
            map ["RegionHandle"]   = OSD.FromULong(RegionHandle);
            map ["Private"]        = OSD.FromBoolean(Private);
            map ["AuctionInfo"]    = AuctionInfo.ToOSD();

            // OSD.FromVector3 is broken for non en_US locales
            // map["UserLocation"] = OSD.FromVector3(UserLocation);
            map["ULocX"] = OSD.FromReal(UserLocation.X).ToString();
            map["ULocY"] = OSD.FromReal(UserLocation.Y).ToString();
            map["ULocZ"] = OSD.FromReal(UserLocation.Z).ToString();
            // map["UserLookAt"] = OSD.FromVector3(UserLookAt);
            map["ULookX"] = OSD.FromReal(UserLookAt.X).ToString();
            map["ULookY"] = OSD.FromReal(UserLookAt.Y).ToString();
            map["ULookZ"] = OSD.FromReal(UserLookAt.Z).ToString();

            return(map);
        }
Exemplo n.º 18
0
        public OSDMap GetOSD()
        {
            Primitive.ConstructionData primData = Prim.PrimData;
            Primitive.ObjectProperties properties = Prim.Properties;

            OSDMap pathMap = new OSDMap();
            pathMap["begin"] = OSD.FromReal(primData.PathBegin);
            pathMap["curve"] = OSD.FromInteger((int)primData.PathCurve);
            pathMap["end"] = OSD.FromReal(primData.PathEnd);
            pathMap["radius_offset"] = OSD.FromReal(primData.PathRadiusOffset);
            pathMap["revolutions"] = OSD.FromReal(primData.PathRevolutions);
            pathMap["scale_x"] = OSD.FromReal(primData.PathScaleX);
            pathMap["scale_y"] = OSD.FromReal(primData.PathScaleY);
            pathMap["shear_x"] = OSD.FromReal(primData.PathShearX);
            pathMap["shear_y"] = OSD.FromReal(primData.PathShearY);
            pathMap["skew"] = OSD.FromReal(primData.PathSkew);
            pathMap["taper_x"] = OSD.FromReal(primData.PathTaperX);
            pathMap["taper_y"] = OSD.FromReal(primData.PathTaperY);
            pathMap["twist"] = OSD.FromReal(primData.PathTwist);
            pathMap["twist_begin"] = OSD.FromReal(primData.PathTwistBegin);

            OSDMap profileMap = new OSDMap();
            profileMap["begin"] = OSD.FromReal(primData.ProfileBegin);
            profileMap["curve"] = OSD.FromInteger((int)primData.ProfileCurve);
            profileMap["hole"] = OSD.FromInteger((int)primData.ProfileHole);
            profileMap["end"] = OSD.FromReal(primData.ProfileEnd);
            profileMap["hollow"] = OSD.FromReal(primData.ProfileHollow);

            OSDMap propertiesMap = new OSDMap();

            if (properties != null)
            {
                propertiesMap["aggregate_perms"] = OSD.FromInteger(properties.AggregatePerms);
                propertiesMap["aggregate_perms_textures"] = OSD.FromInteger(properties.AggregatePermTextures);
                propertiesMap["aggregate_perms_textures_owner"] = OSD.FromInteger(properties.AggregatePermTexturesOwner);
                propertiesMap["category"] = OSD.FromInteger((int)properties.Category);
                propertiesMap["creation_date"] = OSD.FromDate(properties.CreationDate);
                propertiesMap["creator_id"] = OSD.FromUUID(properties.CreatorID);
                propertiesMap["description"] = OSD.FromString(properties.Description);
                propertiesMap["folder_id"] = OSD.FromUUID(properties.FolderID);
                propertiesMap["from_task_id"] = OSD.FromUUID(properties.FromTaskID);
                // properties.GroupID is redundant
                propertiesMap["inventory_serial"] = OSD.FromInteger(properties.InventorySerial);
                propertiesMap["item_id"] = OSD.FromUUID(properties.ItemID);
                propertiesMap["last_owner_id"] = OSD.FromUUID(properties.LastOwnerID);
                propertiesMap["name"] = OSD.FromString(properties.Name);
                // properties.ObjectID is redundant
                // properties.OwnerID is redundant
                propertiesMap["ownership_cost"] = OSD.FromInteger(properties.OwnershipCost);
                propertiesMap["permissions"] = properties.Permissions.GetOSD();
                propertiesMap["sale_price"] = OSD.FromInteger(properties.SalePrice);
                propertiesMap["sale_type"] = OSD.FromInteger((int)properties.SaleType);
                propertiesMap["sit_name"] = OSD.FromString(properties.SitName);
                propertiesMap["touch_name"] = OSD.FromString(properties.TouchName);
            }

            OSDMap primMap = new OSDMap();
            primMap["path"] = pathMap;
            primMap["profile"] = profileMap;
            primMap["properties"] = propertiesMap;

            primMap["acceleration"] = OSD.FromVector3(Prim.Acceleration);
            primMap["ang_velocity"] = OSD.FromVector3(Prim.AngularVelocity);
            primMap["click_action"] = OSD.FromInteger((int)Prim.ClickAction);
            primMap["flags"] = OSD.FromInteger((uint)Prim.Flags);
            primMap["group_id"] = OSD.FromUUID(Prim.GroupID);
            primMap["id"] = OSD.FromUUID(Prim.ID);
            primMap["local_id"] = OSD.FromInteger(Prim.LocalID);
            primMap["media_url"] = OSD.FromString(Prim.MediaURL);
            primMap["owner_id"] = OSD.FromUUID(Prim.OwnerID);
            primMap["parent_id"] = OSD.FromInteger(Prim.ParentID);
            primMap["particles"] = Prim.ParticleSys.GetOSD();
            primMap["position"] = OSD.FromVector3(Prim.Position);
            primMap["rotation"] = OSD.FromQuaternion(Prim.Rotation);
            primMap["scale"] = OSD.FromVector3(Prim.Scale);
            primMap["scratch_pad"] = OSD.FromBinary(Prim.ScratchPad);
            primMap["sound"] = OSD.FromUUID(Prim.Sound);
            primMap["sound_flags"] = OSD.FromInteger((int)Prim.SoundFlags);
            primMap["sound_gain"] = OSD.FromReal(Prim.SoundGain);
            primMap["sound_radius"] = OSD.FromReal(Prim.SoundRadius);
            primMap["text"] = OSD.FromString(Prim.Text);
            primMap["text_color"] = OSD.FromColor4(Prim.TextColor);
            primMap["texture_anim"] = Prim.TextureAnim.GetOSD();
            primMap["tree_species"] = OSD.FromInteger((int)Prim.TreeSpecies);
            primMap["velocity"] = OSD.FromVector3(Prim.Velocity);

            primMap["material"] = OSD.FromInteger((int)primData.Material);
            primMap["state"] = OSD.FromInteger(primData.State);
            primMap["pcode"] = OSD.FromInteger((int)primData.PCode);

            if (Prim.NameValues != null)
                primMap["name_values"] = OSD.FromString(NameValue.NameValuesToString(Prim.NameValues));
            if (Prim.Textures != null)
                primMap["textures"] = Prim.Textures.GetOSD();
            if (Prim.Light != null)
                primMap["light"] = Prim.Light.GetOSD();
            if (Prim.Flexible != null)
                primMap["flex"] = Prim.Flexible.GetOSD();
            if (Prim.Sculpt != null)
                primMap["sculpt"] = Prim.Sculpt.GetOSD();

            OSDMap map = new OSDMap();
            map["prim"] = primMap;
            map["sit_position"] = OSD.FromVector3(SitPosition);
            map["sit_rotation"] = OSD.FromQuaternion(SitRotation);
            map["attachment_position"] = OSD.FromVector3(AttachmentPosition);
            map["attachment_rotation"] = OSD.FromQuaternion(AttachmentRotation);
            map["last_attachment_point"] = OSD.FromInteger((int)LastAttachmentPoint);
            map["before_attachment_rotation"] = OSD.FromQuaternion(BeforeAttachmentRotation);
            map["rotation_axis"] = OSD.FromVector3(m_rotationAxis);
            map["link_number"] = OSD.FromInteger(m_linkNumber);
            map["remote_script_access_pin"] = OSD.FromInteger(RemoteScriptAccessPIN);
            map["inventory"] = OSD.FromString(Inventory.GetTaskInventoryAsset());

            OSDArray buttons = new OSDArray { 
                OSD.FromInteger(PayPriceButtons[0]),
                OSD.FromInteger(PayPriceButtons[1]),
                OSD.FromInteger(PayPriceButtons[2]),
                OSD.FromInteger(PayPriceButtons[3])
            };

            map["pay_price_buttons"] = buttons;
            map["pay_price"] = OSD.FromInteger(PayPrice);

            if (Prim.FaceMedia != null)
            {
                OSDArray faceMedia = new OSDArray(Prim.FaceMedia.Length);
                for (int i = 0; i < Prim.FaceMedia.Length; i++)
                {
                    MediaEntry entry = Prim.FaceMedia[i];
                    if (entry != null)
                        faceMedia.Add(entry.GetOSD());
                    else
                        faceMedia.Add(new OSD());
                }
                map["face_media"] = faceMedia;
            }
            map["media_version"] = OSD.FromString(Prim.MediaVersion);

            map["last_updated"] = OSD.FromDate(m_lastUpdated);

            return map;
        }
Exemplo n.º 19
0
        public static OSD GroupMembership(AgentGroupDataUpdatePacket groupUpdatePacket)
        {
            OSDMap groupUpdate = new OSDMap {
                { "message", OSD.FromString("AgentGroupDataUpdate") }
            };

            OSDMap   body         = new OSDMap();
            OSDArray agentData    = new OSDArray();
            OSDMap   agentDataMap = new OSDMap {
                { "AgentID", OSD.FromUUID(groupUpdatePacket.AgentData.AgentID) }
            };

            agentData.Add(agentDataMap);
            body.Add("AgentData", agentData);

            OSDArray groupData = new OSDArray();

            foreach (OSDMap groupDataMap in groupUpdatePacket.GroupData.Select(groupDataBlock => new OSDMap
            {
                {
                    "ListInProfile"
                    ,
                    OSD
                    .FromBoolean
                        (false)
                },
                {
                    "GroupID",
                    OSD.FromUUID(
                        groupDataBlock
                        .GroupID)
                },
                {
                    "GroupInsigniaID"
                    ,
                    OSD
                    .FromUUID(
                        groupDataBlock
                        .GroupInsigniaID)
                },
                {
                    "Contribution"
                    ,
                    OSD
                    .FromInteger
                        (groupDataBlock
                        .Contribution)
                },
                {
                    "GroupPowers",
                    OSD.FromBinary
                        (ulongToByteArray
                            (groupDataBlock
                            .GroupPowers))
                },
                {
                    "GroupName",
                    OSD.FromString
                        (Utils
                        .BytesToString
                            (groupDataBlock
                            .GroupName))
                },
                {
                    "AcceptNotices"
                    ,
                    OSD
                    .FromBoolean
                        (groupDataBlock
                        .AcceptNotices)
                }
            }))
            {
                groupData.Add(groupDataMap);
            }

            body.Add("GroupData", groupData);
            groupUpdate.Add("body", body);

            return(groupUpdate);
        }
Exemplo n.º 20
0
        public static OSD PlacesQuery(PlacesReplyPacket PlacesReply, string[] regionType)
        {
            OpenMetaverse.Messages.Linden.PlacesReplyMessage message = new PlacesReplyMessage();
            message.AgentID         = PlacesReply.AgentData.AgentID;
            message.QueryID         = PlacesReply.AgentData.QueryID;
            message.TransactionID   = PlacesReply.TransactionData.TransactionID;
            message.QueryDataBlocks = new PlacesReplyMessage.QueryData[PlacesReply.QueryData.Length];
            OSDMap placesReply = new OSDMap {
                { "message", OSD.FromString("PlacesReplyMessage") }
            };

            OSDArray QueryData = new OSDArray();

#if (!ISWIN)
            int i = 0;
            foreach (PlacesReplyPacket.QueryDataBlock groupDataBlock in PlacesReply.QueryData)
            {
                message.QueryDataBlocks[i]              = new PlacesReplyMessage.QueryData();
                message.QueryDataBlocks[i].ActualArea   = groupDataBlock.ActualArea;
                message.QueryDataBlocks[i].BillableArea = groupDataBlock.BillableArea;
                message.QueryDataBlocks[i].Description  = Utils.BytesToString(groupDataBlock.Desc);
                message.QueryDataBlocks[i].Dwell        = groupDataBlock.Dwell;
                message.QueryDataBlocks[i].Flags        = groupDataBlock.Flags;
                message.QueryDataBlocks[i].GlobalX      = groupDataBlock.GlobalX;
                message.QueryDataBlocks[i].GlobalY      = groupDataBlock.GlobalY;
                message.QueryDataBlocks[i].GlobalZ      = groupDataBlock.GlobalZ;
                message.QueryDataBlocks[i].Name         = Utils.BytesToString(groupDataBlock.Name);
                message.QueryDataBlocks[i].OwnerID      = groupDataBlock.OwnerID;
                message.QueryDataBlocks[i].SimName      = Utils.BytesToString(groupDataBlock.SimName);
                message.QueryDataBlocks[i].SnapShotID   = groupDataBlock.SnapshotID;
                message.QueryDataBlocks[i].ProductSku   = regionType[i];
                message.QueryDataBlocks[i].Price        = groupDataBlock.Price;

                i++;
            }
#else
            int[] i = { 0 };
            foreach (OSDMap QueryDataMap in PlacesReply.QueryData.Select(groupDataBlock => new OSDMap
            {
                { "ActualArea", OSD.FromInteger(groupDataBlock.ActualArea) },
                { "BillableArea", OSD.FromInteger(groupDataBlock.BillableArea) },
                { "Description", OSD.FromBinary(groupDataBlock.Desc) },
                { "Dwell", OSD.FromInteger((int)groupDataBlock.Dwell) },
                { "Flags", OSD.FromString(Convert.ToString(groupDataBlock.Flags)) },
                { "GlobalX", OSD.FromInteger((int)groupDataBlock.GlobalX) },
                { "GlobalY", OSD.FromInteger((int)groupDataBlock.GlobalY) },
                { "GlobalZ", OSD.FromInteger((int)groupDataBlock.GlobalZ) },
                { "Name", OSD.FromBinary(groupDataBlock.Name) },
                { "OwnerID", OSD.FromUUID(groupDataBlock.OwnerID) },
                { "SimName", OSD.FromBinary(groupDataBlock.SimName) },
                { "SnapShotID", OSD.FromUUID(groupDataBlock.SnapshotID) },
                { "ProductSku", OSD.FromString(regionType[i[0]]) },
                { "Price", OSD.FromInteger(groupDataBlock.Price) }
            }))
            {
                QueryData.Add(QueryDataMap);
                i[0]++;
            }
#endif
            OSDMap map = message.Serialize();
            placesReply["body"] = map;
            return(placesReply);
        }