Exemplo n.º 1
0
        /// <summary>
        /// Set the media entry on the face of the given part.
        /// </summary>
        /// <param name="part">/param>
        /// <param name="face"></param>
        /// <param name="me">If null, then the media entry is cleared.</param>
        public void SetMediaEntry(SceneObjectPart part, int face, MediaEntry me)
        {
            //            m_log.DebugFormat("[MOAP]: SetMediaEntry for {0}, face {1}", part.Name, face);
            int numFaces = part.GetNumberOfSides();

            if (part.Shape.Media == null)
            {
                part.Shape.Media = new PrimitiveBaseShape.PrimMedia(numFaces);
            }
            else
            {
                part.Shape.Media.Resize(numFaces);
            }

            if (!CheckFaceParam(part, face))
            {
                return;
            }

            // ClearMediaEntry passes null for me so it must not be ignored!
            lock (part.Shape.Media)
                part.Shape.Media[face] = me;

            UpdateMediaUrl(part, UUID.Zero);

            SetPartMediaFlags(part, face, me != null);

            part.ScheduleFullUpdate(PrimUpdateFlags.FindBest);
            part.TriggerScriptChangedEvent(Changed.MEDIA);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Check that the face number is valid for the given prim.
        /// </summary>
        /// <param name="part"></param>
        /// <param name="face"></param>
        protected bool CheckFaceParam(SceneObjectPart part, int face)
        {
            if (face < 0)
            {
                return(false);
            }

            return(face < part.GetNumberOfSides());
        }
Exemplo n.º 3
0
        /// <summary>
        /// Check that the face number is valid for the given prim.
        /// </summary>
        /// <param name="part"></param>
        /// <param name="face"></param>
        protected void CheckFaceParam(SceneObjectPart part, int face)
        {
            if (face < 0)
            {
                throw new ArgumentException("Face cannot be less than zero");
            }

            if (face >= part.GetNumberOfSides())
            {
                throw new ArgumentException(string.Format("Face argument was {0} but max is {1}", face, part.GetNumberOfSides() - 1));
            }
        }
Exemplo n.º 4
0
        public void SetMediaEntry(SceneObjectPart part, int face, MediaEntry me)
        {
            CheckFaceParam(part, face);

            if (null == part.Shape.Media)
            {
                part.Shape.Media = new PrimitiveBaseShape.MediaList(new MediaEntry[part.GetNumberOfSides()]);
            }

            lock (part.Shape.Media)
                part.Shape.Media[face] = me;

            UpdateMediaUrl(part, UUID.Zero);
            part.ScheduleFullUpdate();
            part.TriggerScriptChangedEvent(Changed.MEDIA);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Handle an update of media textures.
        /// </summary>
        /// <param name="omu">/param>
        /// <returns></returns>
        protected bool HandleObjectMediaUpdate(ObjectMediaUpdate omu, UUID agentId)
        {
            UUID primId = omu.PrimID;

            SceneObjectPart part = m_scene.GetSceneObjectPart(primId);

            if (null == part)
            {
                m_log.WarnFormat(
                    "[MOAP]: Received an UPDATE ObjectMediaRequest for prim {0} but this doesn't exist in region {1}",
                    primId, m_scene.RegionInfo.RegionName);
                return(false);
            }

//            m_log.DebugFormat("[MOAP]: Received {0} media entries for prim {1}", omu.FaceMedia.Length, primId);
//
//            for (int i = 0; i < omu.FaceMedia.Length; i++)
//            {
//                MediaEntry me = omu.FaceMedia[i];
//                string v = (null == me ? "null": OSDParser.SerializeLLSDXmlString(me.GetOSD()));
//                m_log.DebugFormat("[MOAP]: Face {0} [{1}]", i, v);
//            }

            if (omu.FaceMedia.Length > part.GetNumberOfSides())
            {
                m_log.WarnFormat(
                    "[MOAP]: Received {0} media entries from client for prim {1} {2} but this prim has only {3} faces.  Dropping request.",
                    omu.FaceMedia.Length, part.Name, part.UUID, part.GetNumberOfSides());
                return(false);
            }

            List <MediaEntry> media = part.Shape.Media;

            if (null == media)
            {
//                m_log.DebugFormat("[MOAP]: Setting all new media list for {0}", part.Name);
                part.Shape.Media = new PrimitiveBaseShape.MediaList(omu.FaceMedia);

                for (int i = 0; i < omu.FaceMedia.Length; i++)
                {
                    if (omu.FaceMedia[i] != null)
                    {
                        // FIXME: Race condition here since some other texture entry manipulator may overwrite/get
                        // overwritten.  Unfortunately, PrimitiveBaseShape does not allow us to change texture entry
                        // directly.
                        SetPartMediaFlags(part, i, true);
//                        m_log.DebugFormat(
//                            "[MOAP]: Media flags for face {0} is {1}",
//                            i, part.Shape.Textures.FaceTextures[i].MediaFlags);
                    }
                }
            }
            else
            {
//                m_log.DebugFormat("[MOAP]: Setting existing media list for {0}", part.Name);

                // We need to go through the media textures one at a time to make sure that we have permission
                // to change them

                // FIXME: Race condition here since some other texture entry manipulator may overwrite/get
                // overwritten.  Unfortunately, PrimitiveBaseShape does not allow us to change texture entry
                // directly.
                Primitive.TextureEntry te = part.Shape.Textures;

                lock (media)
                {
                    for (int i = 0; i < media.Count; i++)
                    {
                        if (m_scene.Permissions.CanControlPrimMedia(agentId, part.UUID, i))
                        {
                            media[i] = omu.FaceMedia[i];

                            // When a face is cleared this is done by setting the MediaFlags in the TextureEntry via a normal
                            // texture update, so we don't need to worry about clearing MediaFlags here.
                            if (null == media[i])
                            {
                                continue;
                            }

                            SetPartMediaFlags(part, i, true);

                            //                        m_log.DebugFormat(
                            //                            "[MOAP]: Media flags for face {0} is {1}",
                            //                            i, face.MediaFlags);
                            //                        m_log.DebugFormat("[MOAP]: Set media entry for face {0} on {1}", i, part.Name);
                        }
                    }
                }

                part.Shape.Textures = te;

//                for (int i2 = 0; i2 < part.Shape.Textures.FaceTextures.Length; i2++)
//                    m_log.DebugFormat("[MOAP]: FaceTexture[{0}] is {1}", i2, part.Shape.Textures.FaceTextures[i2]);
            }

            UpdateMediaUrl(part, agentId);

            // Arguably, we could avoid sending a full update to the avatar that just changed the texture.
            part.ParentGroup.HasGroupChanged = true;
            part.ScheduleFullUpdate();

            part.TriggerScriptChangedEvent(Changed.MEDIA);

            return(true);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Handle a fetch request for media textures
        /// </summary>
        /// <param name="omr"></param>
        /// <returns></returns>
        protected string HandleObjectMediaRequest(ObjectMediaRequest omr)
        {
            UUID primId = omr.PrimID;

            SceneObjectPart part = m_scene.GetSceneObjectPart(primId);

            if (null == part)
            {
                m_log.WarnFormat(
                    "[MOAP]: Received a GET ObjectMediaRequest for prim {0} but this doesn't exist in region {1}",
                    primId, m_scene.RegionInfo.RegionName);
                return(string.Empty);
            }

            if (part.Shape.Media == null)
            {
                return(string.Empty);
            }

            MediaEntry[] currentML = part.Shape.Media.ToArray();

            int nentries = currentML.Length;
            int nsides   = part.GetNumberOfSides();

            if (nentries > nsides)
            {
                nentries = nsides;
            }

            Primitive.TextureEntry te = part.Shape.Textures;
            bool isnull = true;

            for (int face = 0; face < nentries; ++face)
            {
                Primitive.TextureEntryFace teFace = te.GetFace((uint)face);
                if (!teFace.MediaFlags)
                {
                    currentML[face] = null;
                }
                else
                {
                    isnull = false;
                }
            }

            if (isnull)
            {
                //remove the damm thing
                part.Shape.Media = null;
                part.MediaUrl    = null;
                return(string.Empty);
            }

            ObjectMediaResponse resp = new ObjectMediaResponse();

            resp.PrimID = primId;

            resp.FaceMedia = currentML;

            resp.Version = part.MediaUrl;

            string rawResp = OSDParser.SerializeLLSDXmlString(resp.Serialize());

//            m_log.DebugFormat("[MOAP]: Got HandleObjectMediaRequestGet raw response is [{0}]", rawResp);

            return(rawResp);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Set the media entry on the face of the given part.
        /// </summary>
        /// <param name="part">/param>
        /// <param name="face"></param>
        /// <param name="me">If null, then the media entry is cleared.</param>
        public void SetMediaEntry(SceneObjectPart part, int face, MediaEntry me)
        {
//            m_log.DebugFormat("[MOAP]: SetMediaEntry for {0}, face {1}", part.Name, face);

            CheckFaceParam(part, face);

            if (null == part.Shape.Media)
            {
                if (me == null)
                {
                    return;
                }
                else
                {
                    part.Shape.Media = new PrimitiveBaseShape.MediaList(new MediaEntry[part.GetNumberOfSides()]);
                }
            }

            lock (part.Shape.Media)
                part.Shape.Media[face] = me;

            UpdateMediaUrl(part, UUID.Zero);

            SetPartMediaFlags(part, face, me != null);

            part.ParentGroup.HasGroupChanged = true;
            part.ScheduleFullUpdate();
            part.TriggerScriptChangedEvent(Changed.MEDIA);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Append a scene object part report to an input StringBuilder
        /// </summary>
        /// <returns></returns>
        /// <param name='sb'></param>
        /// <param name='sop'</param>
        /// <param name='showFull'>
        /// If true then information on each inventory item will be shown.
        /// If false then only summary inventory information is shown.
        /// </param>
        private StringBuilder AddScenePartReport(StringBuilder sb, SceneObjectPart sop, bool showFull)
        {
            ConsoleDisplayList cdl = new ConsoleDisplayList();

            cdl.AddRow("Name", sop.Name);
            cdl.AddRow("Description", sop.Description);
            cdl.AddRow("Local ID", sop.LocalId);
            cdl.AddRow("UUID", sop.UUID);
            cdl.AddRow("Location", string.Format("{0} @ {1}", sop.AbsolutePosition, sop.ParentGroup.Scene.Name));
            cdl.AddRow(
                "Parent",
                sop.IsRoot ? "Is Root" : string.Format("{0} {1}", sop.ParentGroup.Name, sop.ParentGroup.UUID));
            cdl.AddRow("Link number", sop.LinkNum);
            cdl.AddRow("Flags", sop.Flags);

            if (showFull)
            {
                PrimitiveBaseShape s = sop.Shape;
                cdl.AddRow("FlexiDrag", s.FlexiDrag);
                cdl.AddRow("FlexiEntry", s.FlexiEntry);
                cdl.AddRow("FlexiForce", string.Format("<{0},{1},{2}>", s.FlexiForceX, s.FlexiForceY, s.FlexiForceZ));
                cdl.AddRow("FlexiGravity", s.FlexiGravity);
                cdl.AddRow("FlexiSoftness", s.FlexiSoftness);
                cdl.AddRow("HollowShape", s.HollowShape);
                cdl.AddRow(
                    "LightColor",
                    string.Format("<{0},{1},{2},{3}>", s.LightColorR, s.LightColorB, s.LightColorG, s.LightColorA));
                cdl.AddRow("LightCutoff", s.LightCutoff);
                cdl.AddRow("LightEntry", s.LightEntry);
                cdl.AddRow("LightFalloff", s.LightFalloff);
                cdl.AddRow("LightIntensity", s.LightIntensity);
                cdl.AddRow("LightRadius", s.LightRadius);
                cdl.AddRow("Location (relative)", sop.RelativePosition);
                cdl.AddRow("Media", string.Format("{0} entries", s.Media != null ? s.Media.Count.ToString() : "n/a"));
                cdl.AddRow("PathBegin", s.PathBegin);
                cdl.AddRow("PathEnd", s.PathEnd);
                cdl.AddRow("PathCurve", s.PathCurve);
                cdl.AddRow("PathRadiusOffset", s.PathRadiusOffset);
                cdl.AddRow("PathRevolutions", s.PathRevolutions);
                cdl.AddRow("PathScale", string.Format("<{0},{1}>", s.PathScaleX, s.PathScaleY));
                cdl.AddRow("PathSkew", string.Format("<{0},{1}>", s.PathShearX, s.PathShearY));
                cdl.AddRow("FlexiDrag", s.PathSkew);
                cdl.AddRow("PathTaper", string.Format("<{0},{1}>", s.PathTaperX, s.PathTaperY));
                cdl.AddRow("PathTwist", s.PathTwist);
                cdl.AddRow("PathTwistBegin", s.PathTwistBegin);
                cdl.AddRow("PCode", s.PCode);
                cdl.AddRow("ProfileBegin", s.ProfileBegin);
                cdl.AddRow("ProfileEnd", s.ProfileEnd);
                cdl.AddRow("ProfileHollow", s.ProfileHollow);
                cdl.AddRow("ProfileShape", s.ProfileShape);
                cdl.AddRow("ProjectionAmbiance", s.ProjectionAmbiance);
                cdl.AddRow("ProjectionEntry", s.ProjectionEntry);
                cdl.AddRow("ProjectionFocus", s.ProjectionFocus);
                cdl.AddRow("ProjectionFOV", s.ProjectionFOV);
                cdl.AddRow("ProjectionTextureUUID", s.ProjectionTextureUUID);
                cdl.AddRow("Rotation (Relative)", sop.RotationOffset);
                cdl.AddRow("Rotation (World)", sop.GetWorldRotation());
                cdl.AddRow("Scale", s.Scale);
                cdl.AddRow(
                    "SculptData",
                    string.Format("{0} bytes", s.SculptData != null ? s.SculptData.Length.ToString() : "n/a"));
                cdl.AddRow("SculptEntry", s.SculptEntry);
                cdl.AddRow("SculptTexture", s.SculptTexture);
                cdl.AddRow("SculptType", s.SculptType);
                cdl.AddRow("State", s.State);

                // TODO, need to display more information about textures but in a compact format
                // to stop output becoming huge.
                for (int i = 0; i < sop.GetNumberOfSides(); i++)
                {
                    Primitive.TextureEntryFace teFace = s.Textures.FaceTextures[i];

                    UUID textureID;

                    if (teFace != null)
                    {
                        textureID = teFace.TextureID;
                    }
                    else
                    {
                        textureID = s.Textures.DefaultTexture.TextureID;
                    }

                    cdl.AddRow(string.Format("Face {0} texture ID", i), textureID);
                }

                //cdl.AddRow("Textures", string.Format("{0} entries", s.Textures.
            }

            object itemsOutput;

            if (showFull)
            {
                StringBuilder itemsSb = new StringBuilder("\n");
                itemsOutput = AddScenePartItemsReport(itemsSb, sop.Inventory).ToString();
            }
            else
            {
                itemsOutput = sop.Inventory.Count;
            }

            cdl.AddRow("Items", itemsOutput);

            return(sb.Append(cdl.ToString()));
        }
Exemplo n.º 9
0
        private void copyTexturesToInventory(SceneObjectPart part)
        {
            if (m_enable == false)
            {
                return;
            }

            if (m_scene.LoginsEnabled == false)
            {
                return;
            }

            if (part.ParentGroup.RootPart.ClickAction == 2)
            {
                return;
            }

            if ((part.ParentGroup.RootPart.GetEffectiveObjectFlags() & (uint)PrimFlags.ObjectCopy) != 0)
            {
                return;
            }

            //if ((setPermissionMask & (uint)PermissionMask.Copy) != 0)
            //return;

            if (inventoryContainsScripts(part.ParentGroup.RootPart))
            {
                return;
            }

            try
            {
                List <UUID> allTextures = new List <UUID>();
                List <TaskInventoryItem> inventoryItems = new List <TaskInventoryItem>();

                //Get all Textures from the scene object
                Primitive.TextureEntry textures = part.Shape.Textures;
                int allSides = part.GetNumberOfSides();

                for (uint i = 0; i < allSides; i++)
                {
                    TextureEntryFace face = textures.GetFace(i);

                    if (!m_textureBlackList.Contains(face.TextureID) && !m_defaultTexturs.Contains(face.TextureID.ToString()))
                    {
                        allTextures.Add(face.TextureID);
                    }

                    if (m_textureBlackList.Contains(face.TextureID))
                    {
                        face.TextureID = UUID.Parse("89556747-24cb-43ed-920b-47caed15465f");
                    }
                }

                //Remove not existing textures
                if (m_checkTexture == true)
                {
                    String[] _assetIDs = new string[allTextures.Count];
                    for (int i = 0; i < allTextures.Count; i++)
                    {
                        _assetIDs[i] = allTextures[i].ToString();
                    }

                    bool[] existing = m_scene.AssetService.AssetsExist(_assetIDs);
                    for (int i = 0; i < existing.Length; i++)
                    {
                        if (existing[i] == false)
                        {
                            m_textureBlackList.Add(allTextures[i]);
                            allTextures[i] = UUID.Zero;
                        }
                    }
                }

                //Convert texture uuid list to inventar items.
                foreach (UUID texture in allTextures)
                {
                    if (texture != UUID.Zero)
                    {
                        String partname = part.Name.Trim();

                        if (partname == "")
                        {
                            partname = "tf";
                        }

                        TaskInventoryItem item = new TaskInventoryItem();
                        item.AssetID            = texture;
                        item.ItemID             = UUID.Random();
                        item.OwnerID            = part.OwnerID;
                        item.CurrentPermissions = 581639;
                        item.Name        = partname + " - Texture";
                        item.Description = "This item was automatically generated by the texture fetcher module.";
                        item.OwnerID     = part.OwnerID;
                        item.CreatorID   = part.OwnerID;
                        item.LastOwnerID = part.OwnerID;
                        inventoryItems.Add(item);
                    }
                }

                //Check if the item is allready in the inventory and then add it.
                bool updateNeeded = false;
                foreach (TaskInventoryItem item in inventoryItems)
                {
                    if (!isAssetInInventory(part, item.AssetID))
                    {
                        updateNeeded = true;

                        part.ParentGroup.RootPart.Inventory.AddInventoryItem(item, false);
                    }
                }

                if (updateNeeded == true)
                {
                    //part.SendFullUpdateToAllClients();
                }
            }
            catch (Exception _error)
            {
                m_log.Error("[" + Name + "] ERROR: " + _error.Message);
            }
        }