aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r--OpenSim/Framework/AvatarAppearance.cs14
-rw-r--r--OpenSim/Framework/WearableCacheItem.cs118
2 files changed, 129 insertions, 3 deletions
diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs
index 4df4fb6..ffc3527 100644
--- a/OpenSim/Framework/AvatarAppearance.cs
+++ b/OpenSim/Framework/AvatarAppearance.cs
@@ -66,7 +66,9 @@ namespace OpenSim.Framework
66 protected Vector3 m_avatarBoxSize = new Vector3(0.45f, 0.6f, 1.9f); 66 protected Vector3 m_avatarBoxSize = new Vector3(0.45f, 0.6f, 1.9f);
67 protected float m_avatarFeetOffset = 0; 67 protected float m_avatarFeetOffset = 0;
68 protected float m_avatarAnimOffset = 0; 68 protected float m_avatarAnimOffset = 0;
69 protected WearableCacheItem[] cacheitems; 69 protected WearableCacheItem[] m_cacheitems;
70 protected bool m_cacheItemsDirty = true;
71
70 public virtual int Serial 72 public virtual int Serial
71 { 73 {
72 get { return m_serial; } 74 get { return m_serial; }
@@ -118,8 +120,14 @@ namespace OpenSim.Framework
118 120
119 public virtual WearableCacheItem[] WearableCacheItems 121 public virtual WearableCacheItem[] WearableCacheItems
120 { 122 {
121 get { return cacheitems; } 123 get { return m_cacheitems; }
122 set { cacheitems = value; } 124 set { m_cacheitems = value; }
125 }
126
127 public virtual bool WearableCacheItemsDirty
128 {
129 get { return m_cacheItemsDirty; }
130 set { m_cacheItemsDirty = value; }
123 } 131 }
124 132
125 public AvatarAppearance() 133 public AvatarAppearance()
diff --git a/OpenSim/Framework/WearableCacheItem.cs b/OpenSim/Framework/WearableCacheItem.cs
index 83b1346..1aecf79 100644
--- a/OpenSim/Framework/WearableCacheItem.cs
+++ b/OpenSim/Framework/WearableCacheItem.cs
@@ -26,14 +26,132 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections.Generic;
29using OpenMetaverse; 30using OpenMetaverse;
31using OpenMetaverse.StructuredData;
30 32
31namespace OpenSim.Framework 33namespace OpenSim.Framework
32{ 34{
35 [Serializable]
33 public class WearableCacheItem 36 public class WearableCacheItem
34 { 37 {
35 public uint TextureIndex { get; set; } 38 public uint TextureIndex { get; set; }
36 public UUID CacheId { get; set; } 39 public UUID CacheId { get; set; }
37 public UUID TextureID { get; set; } 40 public UUID TextureID { get; set; }
41 public AssetBase TextureAsset { get; set; }
42
43
44 public static WearableCacheItem[] GetDefaultCacheItem()
45 {
46 int itemmax = 21;
47 WearableCacheItem[] retitems = new WearableCacheItem[itemmax];
48 for (uint i=0;i<itemmax;i++)
49 retitems[i] = new WearableCacheItem() {CacheId = UUID.Zero, TextureID = UUID.Zero, TextureIndex = i + 1};
50 return retitems;
51 }
52 public static WearableCacheItem[] FromOSD(OSD pInput, IImprovedAssetCache dataCache)
53 {
54 List<WearableCacheItem> ret = new List<WearableCacheItem>();
55 if (pInput.Type == OSDType.Array)
56 {
57 OSDArray itemarray = (OSDArray) pInput;
58 foreach (OSDMap item in itemarray)
59 {
60 ret.Add(new WearableCacheItem()
61 {
62 TextureIndex = item["textureindex"].AsUInteger(),
63 CacheId = item["cacheid"].AsUUID(),
64 TextureID = item["textureid"].AsUUID()
65 });
66
67 if (dataCache != null && item.ContainsKey("assetdata"))
68 {
69 AssetBase asset = new AssetBase(item["textureid"].AsUUID(),"BakedTexture",(sbyte)AssetType.Texture,UUID.Zero.ToString());
70 asset.Temporary = true;
71 asset.Data = item["assetdata"].AsBinary();
72 dataCache.Cache(asset);
73 }
74 }
75 }
76 else if (pInput.Type == OSDType.Map)
77 {
78 OSDMap item = (OSDMap) pInput;
79 ret.Add(new WearableCacheItem(){
80 TextureIndex = item["textureindex"].AsUInteger(),
81 CacheId = item["cacheid"].AsUUID(),
82 TextureID = item["textureid"].AsUUID()
83 });
84 if (dataCache != null && item.ContainsKey("assetdata"))
85 {
86 string assetCreator = item["assetcreator"].AsString();
87 string assetName = item["assetname"].AsString();
88 AssetBase asset = new AssetBase(item["textureid"].AsUUID(), assetName, (sbyte)AssetType.Texture, assetCreator);
89 asset.Temporary = true;
90 asset.Data = item["assetdata"].AsBinary();
91 dataCache.Cache(asset);
92 }
93 }
94 else
95 {
96 return new WearableCacheItem[0];
97 }
98 return ret.ToArray();
99
100 }
101 public static OSD ToOSD(WearableCacheItem[] pcacheItems, IImprovedAssetCache dataCache)
102 {
103 OSDArray arr = new OSDArray();
104 foreach (WearableCacheItem item in pcacheItems)
105 {
106 OSDMap itemmap = new OSDMap();
107 itemmap.Add("textureindex", OSD.FromUInteger(item.TextureIndex));
108 itemmap.Add("cacheid", OSD.FromUUID(item.CacheId));
109 itemmap.Add("textureid", OSD.FromUUID(item.TextureID));
110 if (dataCache != null)
111 {
112 if (dataCache.Check(item.TextureID.ToString()))
113 {
114 AssetBase assetItem = dataCache.Get(item.TextureID.ToString());
115 if (assetItem != null)
116 {
117 itemmap.Add("assetdata", OSD.FromBinary(assetItem.Data));
118 itemmap.Add("assetcreator", OSD.FromString(assetItem.CreatorID));
119 itemmap.Add("assetname", OSD.FromString(assetItem.Name));
120 }
121 }
122 }
123 arr.Add(itemmap);
124 }
125 return arr;
126 }
127 public static WearableCacheItem SearchTextureIndex(uint pTextureIndex,WearableCacheItem[] pcacheItems)
128 {
129 for (int i = 0; i < pcacheItems.Length; i++)
130 {
131 if (pcacheItems[i].TextureIndex == pTextureIndex)
132 return pcacheItems[i];
133 }
134 return null;
135 }
136 public static WearableCacheItem SearchTextureCacheId(UUID pCacheId, WearableCacheItem[] pcacheItems)
137 {
138 for (int i = 0; i < pcacheItems.Length; i++)
139 {
140 if (pcacheItems[i].CacheId == pCacheId)
141 return pcacheItems[i];
142 }
143 return null;
144 }
145 public static WearableCacheItem SearchTextureTextureId(UUID pTextureId, WearableCacheItem[] pcacheItems)
146 {
147 for (int i = 0; i < pcacheItems.Length; i++)
148 {
149 if (pcacheItems[i].TextureID == pTextureId)
150 return pcacheItems[i];
151 }
152 return null;
153 }
38 } 154 }
155
156
39} 157}