示例#1
0
        public AvatarAppearance(UUID avatarID, AvatarWearable[] wearables, Primitive.TextureEntry textureEntry,
            byte[] visualParams)
        {
            //            MainConsole.Instance.WarnFormat("[AVATAR APPEARANCE] create initialized appearance for {0}",avatarID);

            m_serial = 1;
            m_owner = avatarID;

            if (wearables != null)
                m_wearables = wearables;
            else
                SetDefaultWearables();

            if (textureEntry != null)
                m_texture = textureEntry;
            else
                SetDefaultTexture();

            if (visualParams != null)
                m_visualparams = visualParams;
            else
                SetDefaultParams();

            SetHeight();

            m_attachments = new Dictionary<int, List<AvatarAttachment>>();
        }
示例#2
0
        /// <summary>
        ///     Unpack and OSDMap and initialize the appearance
        ///     from it
        /// </summary>
        public void Unpack(OSDMap data)
        {
            if ((data != null) && (data["serial"] != null))
                m_serial = data["serial"].AsInteger();
            if ((data != null) && (data["height"] != null))
                m_avatarHeight = (float) data["height"].AsReal();

            if ((data != null) && (data["owner"] != null))
                m_owner = data["owner"].AsUUID();
            try
            {
                // Wearables
                SetDefaultWearables();
                if ((data != null) && (data["wearables"] != null) && (data["wearables"]).Type == OSDType.Array)
                {
                    OSDArray wears = (OSDArray) (data["wearables"]);
                    for (int i = 0; i < wears.Count; i++)
                        if(wears[i] is OSDArray)
                            m_wearables[i] = new AvatarWearable((OSDArray) wears[i]);
                }
                else
                {
                    MainConsole.Instance.Warn("[AVATAR APPEARANCE]: failed to unpack wearables");
                }

                // Avatar Textures
                SetDefaultTexture();
                if ((data != null) && (data["textures"] != null) && (data["textures"]).Type == OSDType.Array)
                {
                    OSDArray textures = (OSDArray) (data["textures"]);
                    for (int i = 0; i < TEXTURE_COUNT && i < textures.Count; i++)
                    {
                        UUID textureID = AppearanceManager.DEFAULT_AVATAR_TEXTURE;
                        if (textures[i] != null)
                            textureID = textures[i].AsUUID();
                        if (textureID != AppearanceManager.DEFAULT_AVATAR_TEXTURE)
                            m_texture.CreateFace((uint) i).TextureID = new UUID(textureID);
                    }
                }
                else
                {
                    MainConsole.Instance.Warn("[AVATAR APPEARANCE]: failed to unpack textures");
                }

                // Visual Parameters
                SetDefaultParams();
                if ((data != null) && (data["visualparams"] != null))
                {
                    if ((data["visualparams"].Type == OSDType.Binary) || (data["visualparams"].Type == OSDType.Array))
                        m_visualparams = data["visualparams"].AsBinary();
                }
                else
                {
                    MainConsole.Instance.Warn("[AVATAR APPEARANCE]: failed to unpack visual parameters");
                }

                // Attachments
                m_attachments = new Dictionary<int, List<AvatarAttachment>>();
                if ((data != null) && (data["attachments"] != null) && (data["attachments"]).Type == OSDType.Array)
                {
                    OSDArray attachs = (OSDArray) (data["attachments"]);
                    foreach (OSD t in attachs)
                        AppendAttachment(new AvatarAttachment((OSDMap) t));
                }
                if (data != null && data["wearableCache"] != null && data["wearableCache"] is OSDMap)
                    m_wearableCache = ((OSDMap)data["wearableCache"]).ConvertMap<UUID>((o) => o);
                SetHeight();
            }
            catch (Exception e)
            {
                MainConsole.Instance.ErrorFormat("[AVATAR APPEARANCE]: unpack failed badly: {0}, {1}", e.ToString(), OSDParser.SerializeJsonString(data));
            }
        }
示例#3
0
        public AvatarAppearance(AvatarAppearance appearance, bool copyWearables)
        {
            //            MainConsole.Instance.WarnFormat("[AVATAR APPEARANCE] create from an existing appearance");

            if (appearance == null)
            {
                m_serial = 1;
                m_owner = UUID.Zero;

                SetDefaultWearables();
                SetDefaultTexture();
                SetDefaultParams();
                SetHeight();

                m_attachments = new Dictionary<int, List<AvatarAttachment>>();

                return;
            }

            m_serial = appearance.Serial;
            m_owner = appearance.Owner;

            m_wearables = new AvatarWearable[AvatarWearable.MAX_WEARABLES];
            for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++)
                m_wearables[i] = new AvatarWearable();
            if (copyWearables && (appearance.Wearables != null))
            {
                for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++)
                    SetWearable(i, appearance.Wearables[i]);
            }

            m_texture = null;
            if (appearance.Texture != null)
            {
                byte[] tbytes = appearance.Texture.GetBytes();
                m_texture = new Primitive.TextureEntry(tbytes, 0, tbytes.Length);
            }

            m_visualparams = null;
            if (appearance.VisualParams != null)
                m_visualparams = (byte[]) appearance.VisualParams.Clone();

            // Copy the attachment, force append mode since that ensures consistency
            m_attachments = new Dictionary<int, List<AvatarAttachment>>();
            foreach (AvatarAttachment attachment in appearance.GetAttachments())
                AppendAttachment(new AvatarAttachment(attachment));
            SetHeight();
        }
示例#4
0
 public void SetWearable(int wearableId, AvatarWearable wearable)
 {
     m_wearables[wearableId].Clear();
     for (int i = 0; i < wearable.Count; i++)
         m_wearables[wearableId].Add(wearable[i].ItemID, wearable[i].AssetID);
 }
示例#5
0
 public void ClearWearables()
 {
     m_wearables = new AvatarWearable[AvatarWearable.MAX_WEARABLES];
     for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++)
         m_wearables[i] = new AvatarWearable();
 }