aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Framework/Scenes/UuidGatherer.cs66
1 files changed, 66 insertions, 0 deletions
diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
index ad33607..0e83781 100644
--- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
+++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
@@ -34,6 +34,7 @@ using System.Threading;
34using log4net; 34using log4net;
35using OpenMetaverse; 35using OpenMetaverse;
36using OpenMetaverse.Assets; 36using OpenMetaverse.Assets;
37using OpenMetaverse.StructuredData;
37using OpenSim.Framework; 38using OpenSim.Framework;
38using OpenSim.Region.Framework.Scenes.Serialization; 39using OpenSim.Region.Framework.Scenes.Serialization;
39using OpenSim.Services.Interfaces; 40using OpenSim.Services.Interfaces;
@@ -184,6 +185,9 @@ namespace OpenSim.Region.Framework.Scenes
184 if (!assetUuids.ContainsKey(tii.AssetID)) 185 if (!assetUuids.ContainsKey(tii.AssetID))
185 GatherAssetUuids(tii.AssetID, (AssetType)tii.Type, assetUuids); 186 GatherAssetUuids(tii.AssetID, (AssetType)tii.Type, assetUuids);
186 } 187 }
188
189 // get any texture UUIDs used for materials such as normal and specular maps
190 GatherMaterialsUuids(part, assetUuids);
187 } 191 }
188 catch (Exception e) 192 catch (Exception e)
189 { 193 {
@@ -208,6 +212,68 @@ namespace OpenSim.Region.Framework.Scenes
208// } 212// }
209// } 213// }
210 214
215
216 /// <summary>
217 /// Gather all of the texture asset UUIDs used to reference "Materials" such as normal and specular maps
218 /// </summary>
219 /// <param name="part"></param>
220 /// <param name="assetUuids"></param>
221 public void GatherMaterialsUuids(SceneObjectPart part, IDictionary<UUID, AssetType> assetUuids)
222 {
223 // scan thru the dynAttrs map of this part for any textures used as materials
224 OSDMap OSMaterials = null;
225
226 lock (part.DynAttrs)
227 {
228 if (part.DynAttrs.ContainsKey("OS:Materials"))
229 OSMaterials = part.DynAttrs["OS:Materials"];
230 if (OSMaterials != null && OSMaterials.ContainsKey("Materials"))
231 {
232 OSD osd = OSMaterials["Materials"];
233 //m_log.Info("[UUID Gatherer]: found Materials: " + OSDParser.SerializeJsonString(osd));
234
235 if (osd is OSDArray)
236 {
237 OSDArray matsArr = osd as OSDArray;
238 foreach (OSDMap matMap in matsArr)
239 {
240 try
241 {
242 if (matMap.ContainsKey("Material"))
243 {
244 OSDMap mat = matMap["Material"] as OSDMap;
245 if (mat.ContainsKey("NormMap"))
246 {
247 UUID normalMapId = mat["NormMap"].AsUUID();
248 if (normalMapId != UUID.Zero)
249 {
250 assetUuids[normalMapId] = AssetType.Texture;
251 //m_log.Info("[UUID Gatherer]: found normal map ID: " + normalMapId.ToString());
252 }
253 }
254 if (mat.ContainsKey("SpecMap"))
255 {
256 UUID specularMapId = mat["SpecMap"].AsUUID();
257 if (specularMapId != UUID.Zero)
258 {
259 assetUuids[specularMapId] = AssetType.Texture;
260 //m_log.Info("[UUID Gatherer]: found specular map ID: " + specularMapId.ToString());
261 }
262 }
263 }
264
265 }
266 catch (Exception e)
267 {
268 m_log.Warn("[UUID Gatherer]: exception getting materials: " + e.Message);
269 }
270 }
271 }
272 }
273 }
274 }
275
276
211 /// <summary> 277 /// <summary>
212 /// Get an asset synchronously, potentially using an asynchronous callback. If the 278 /// Get an asset synchronously, potentially using an asynchronous callback. If the
213 /// asynchronous callback is used, we will wait for it to complete. 279 /// asynchronous callback is used, we will wait for it to complete.