예제 #1
0
        public void SetMediaEntry(ISceneChildEntity part, int face, MediaEntry me)
        {
            CheckFaceParam(part, face);

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

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

            if (part.Shape.Media [face] == null) //If it doesn't exist, set the default parameters for it
            {
                me.InteractPermissions = MediaPermission.All;
            }

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

            UpdateMediaUrl(part, UUID.Zero);

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

            part.ScheduleUpdate(PrimUpdateFlags.FullUpdate);
            part.TriggerScriptChangedEvent(Changed.MEDIA);
        }
예제 #2
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(ISceneChildEntity part, int face)
        {
            if (face < 0)
            {
                throw new ArgumentException("Face cannot be less than zero");
            }

            int maxFaces = part.GetNumberOfSides() - 1;

            if (face > maxFaces)
            {
                throw new ArgumentException(
                          string.Format("Face argument was {0} but max is {1}", face, maxFaces));
            }
        }
예제 #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 (ISceneChildEntity part, int face)
 {
     if (face < 0)
         throw new ArgumentException("Face cannot be less than zero");
                        
     int maxFaces = part.GetNumberOfSides() - 1;
     if (face > maxFaces)
         throw new ArgumentException(
             string.Format("Face argument was {0} but max is {1}", face, maxFaces));
 }
예제 #4
0
        public void SetMediaEntry (ISceneChildEntity part, int face, MediaEntry me)
        {
            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.ScheduleUpdate(PrimUpdateFlags.FullUpdate);
            part.TriggerScriptChangedEvent(Changed.MEDIA);
        }
예제 #5
0
        /// <summary>
        ///     Handle an update of media textures.
        /// </summary>
        /// <param name="path">Path on which this request was made</param>
        /// <param name="omu"></param>
        /// <returns></returns>
        protected byte[] HandleObjectMediaUpdate(string path, ObjectMediaUpdate omu)
        {
            UUID primId = omu.PrimID;

            ISceneChildEntity part = m_scene.GetSceneObjectPart(primId);

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

//            MainConsole.Instance.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()));
//                MainConsole.Instance.DebugFormat("[MOAP]: Face {0} [{1}]", i, v);
//            }

            if (omu.FaceMedia.Length > part.GetNumberOfSides())
            {
                MainConsole.Instance.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(MainServer.BlankResponse);
            }

            UUID agentId = default(UUID);

            lock (m_omCapUsers)
                agentId = m_omCapUsers[path];

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

            if (null == media)
            {
//                MainConsole.Instance.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);
//                        MainConsole.Instance.DebugFormat(
//                            "[MOAP]: Media flags for face {0} is {1}",
//                            i, part.Shape.Textures.FaceTextures[i].MediaFlags);
                    }
                }
            }
            else
            {
                // 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);

                            //                        MainConsole.Instance.DebugFormat(
                            //                            "[MOAP]: Media flags for face {0} is {1}",
                            //                            i, face.MediaFlags);
                            //                        MainConsole.Instance.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++)
//                    MainConsole.Instance.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.ScheduleUpdate(PrimUpdateFlags.FullUpdate);

            part.TriggerScriptChangedEvent(Changed.MEDIA);

            return(MainServer.BlankResponse);
        }
예제 #6
0
파일: LSL_Api.cs 프로젝트: rknop/Aurora-Sim
        protected int GetNumberOfSides (ISceneChildEntity part)
        {
            int sides = part.GetNumberOfSides();

            if (part.GetPrimType() == PrimType.SPHERE && part.Shape.ProfileHollow > 0)
            {
                // Make up for a bug where LSL shows 4 sides rather than 2
                sides += 2;
            }

            return sides;
        }
예제 #7
0
        private void ClearPrimMedia (ISceneChildEntity entity, LSL_Integer face)
        {
            // LSL Spec http://wiki.secondlife.com/wiki/LlClearPrimMedia says to fail silently if face is invalid
            // Assuming silently fail means sending back LSL_STATUS_OK.  Ideally, need to check this.
            // FIXME: Don't perform the media check directly
            if(face < 0 || face > entity.GetNumberOfSides() - 1)
                return;

            IMoapModule module = World.RequestModuleInterface<IMoapModule>();
            if(null == module)
                throw new Exception("Media on a prim functions not available");

            module.ClearMediaEntry(entity, face);
        }
예제 #8
0
        public void SetMediaEntry(ISceneChildEntity part, int face, MediaEntry me)
        {
            CheckFaceParam(part, face);

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

            if (part.Shape.Media[face] == null) //If it doesn't exist, set the default parameters for it
                me.InteractPermissions = MediaPermission.All;
            lock (part.Shape.Media)
                part.Shape.Media[face] = me;

            UpdateMediaUrl(part, UUID.Zero);

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

            part.ScheduleUpdate(PrimUpdateFlags.FullUpdate);
            part.TriggerScriptChangedEvent(Changed.MEDIA);
        }
예제 #9
0
        public void SetMediaEntry(ISceneChildEntity part, int face, MediaEntry me)
        {
            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.ScheduleUpdate(PrimUpdateFlags.FullUpdate);
            part.TriggerScriptChangedEvent(Changed.MEDIA);
        }