123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270 |
- using System;
- using System.Collections.Generic;
- using System.Drawing;
- using OpenMetaverse;
- using Nini.Config;
- using OpenSim.Framework;
- using OpenSim.Region.Framework.Interfaces;
- using OpenSim.Region.Framework.Scenes;
- using OpenSim.Region.Framework.Scenes.Serialization;
- using OpenSim.Region.Physics.Manager;
- using log4net;
- namespace OpenSim.Region.OptionalModules.ContentManagement
- {
- public class MetaEntity
- {
- #region Constants
- public const float INVISIBLE = .95f;
-
- public const float NONE = 0f;
- public const float TRANSLUCENT = .5f;
- #endregion Constants
- #region Static Fields
-
- #endregion Static Fields
- #region Fields
- protected SceneObjectGroup m_Entity = null;
- protected uint m_metaLocalid;
- #endregion Fields
- #region Constructors
- public MetaEntity()
- {
- }
-
-
-
-
- public MetaEntity(SceneObjectGroup orig, bool physics)
- {
- m_Entity = orig.Copy(false);
- Initialize(physics);
- }
-
-
-
- public MetaEntity(string objectXML, Scene scene, bool physics)
- {
- m_Entity = SceneObjectSerializer.FromXml2Format(objectXML);
- m_Entity.SetScene(scene);
- Initialize(physics);
- }
- #endregion Constructors
- #region Public Properties
- public SceneObjectPart[] Parts
- {
- get { return m_Entity.Parts; }
- }
- public uint LocalId
- {
- get { return m_Entity.LocalId; }
- set { m_Entity.LocalId = value; }
- }
- public SceneObjectGroup ObjectGroup
- {
- get { return m_Entity; }
- }
- public int PrimCount
- {
- get { return m_Entity.PrimCount; }
- }
- public SceneObjectPart RootPart
- {
- get { return m_Entity.RootPart; }
- }
- public Scene Scene
- {
- get { return m_Entity.Scene; }
- }
- public UUID UUID
- {
- get { return m_Entity.UUID; }
- set { m_Entity.UUID = value; }
- }
- #endregion Public Properties
- #region Protected Methods
-
-
-
-
-
-
- protected void Initialize(bool physics)
- {
-
- Dictionary<UUID, SceneObjectPart> parts = new Dictionary<UUID, SceneObjectPart>();
- foreach (SceneObjectPart part in m_Entity.Parts)
- {
- part.ResetIDs(part.LinkNum);
- parts.Add(part.UUID, part);
- }
-
- m_Entity.RootPart.PhysActor = null;
- foreach (SceneObjectPart part in parts.Values)
- m_Entity.AddPart(part);
- }
- #endregion Protected Methods
- #region Public Methods
-
-
-
- public virtual void Hide(IClientAPI client)
- {
-
-
-
- foreach (SceneObjectPart part in m_Entity.Parts)
- client.SendKillObject(m_Entity.RegionHandle, part.LocalId);
- }
-
-
-
- public virtual void HideFromAll()
- {
- foreach (SceneObjectPart part in m_Entity.Parts)
- {
- m_Entity.Scene.ForEachClient(
- delegate(IClientAPI controller)
- { controller.SendKillObject(m_Entity.RegionHandle, part.LocalId); }
- );
- }
- }
- public void SendFullUpdate(IClientAPI client)
- {
-
- SendFullUpdate(client, 0);
- }
- public void SendFullUpdate(IClientAPI client, uint clientFlags)
- {
- m_Entity.SendFullUpdateToClient(client);
- }
- public void SendFullUpdateToAll()
- {
- m_Entity.Scene.ForEachClient(
- delegate(IClientAPI controller)
- { m_Entity.SendFullUpdateToClient(controller); }
- );
- }
-
-
-
-
-
-
-
-
-
-
-
- public static void SetPartTransparency(SceneObjectPart part, float transparencyAmount)
- {
- Primitive.TextureEntry tex = null;
- Color4 texcolor;
- try
- {
- tex = part.Shape.Textures;
- texcolor = new Color4();
- }
- catch(Exception)
- {
-
- return;
- }
- for (uint i = 0; i < tex.FaceTextures.Length; i++)
- {
- try {
- if (tex.FaceTextures[i] != null)
- {
- texcolor = tex.FaceTextures[i].RGBA;
- texcolor.A = transparencyAmount;
- tex.FaceTextures[i].RGBA = texcolor;
- }
- }
- catch (Exception)
- {
-
- continue;
- }
- }
- try {
- texcolor = tex.DefaultTexture.RGBA;
- texcolor.A = transparencyAmount;
- tex.DefaultTexture.RGBA = texcolor;
- part.Shape.TextureEntry = tex.GetBytes();
- }
- catch (Exception)
- {
-
- }
- }
- #endregion Public Methods
- }
- }
|