diff options
author | Dr Scofield | 2009-05-22 16:22:49 +0000 |
---|---|---|
committer | Dr Scofield | 2009-05-22 16:22:49 +0000 |
commit | 3b689e506f82ea45fcf703b22eb50a00e40baa4f (patch) | |
tree | 4c99a98342400d3f9f49670e3f6754554d3c8235 /OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs | |
parent | From: Alan Webb <alan_webb@us.ibm.com> (diff) | |
download | opensim-SC_OLD-3b689e506f82ea45fcf703b22eb50a00e40baa4f.zip opensim-SC_OLD-3b689e506f82ea45fcf703b22eb50a00e40baa4f.tar.gz opensim-SC_OLD-3b689e506f82ea45fcf703b22eb50a00e40baa4f.tar.bz2 opensim-SC_OLD-3b689e506f82ea45fcf703b22eb50a00e40baa4f.tar.xz |
From: Alan Webb <alan_webb@us.ibm.com>
Changes to support client-side image pre-caching in the region. This
commit adds an additional calling sequence to the DynamicTexture data
and URL calls. The new interface allows a dynamic image to be loaded
into a specific object face (rather than the mandatory ALL_SIDES
supported today.
This is in part fulfilment of ticket #458.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs | 59 |
1 files changed, 48 insertions, 11 deletions
diff --git a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs index 259a333..6509bf3 100644 --- a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs | |||
@@ -42,6 +42,10 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture | |||
42 | { | 42 | { |
43 | public class DynamicTextureModule : IRegionModule, IDynamicTextureManager | 43 | public class DynamicTextureModule : IRegionModule, IDynamicTextureManager |
44 | { | 44 | { |
45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
46 | |||
47 | private const int ALL_SIDES = -1; | ||
48 | |||
45 | private Dictionary<UUID, Scene> RegisteredScenes = new Dictionary<UUID, Scene>(); | 49 | private Dictionary<UUID, Scene> RegisteredScenes = new Dictionary<UUID, Scene>(); |
46 | 50 | ||
47 | private Dictionary<string, IDynamicTextureRender> RenderPlugins = | 51 | private Dictionary<string, IDynamicTextureRender> RenderPlugins = |
@@ -106,6 +110,12 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture | |||
106 | public UUID AddDynamicTextureURL(UUID simID, UUID primID, string contentType, string url, | 110 | public UUID AddDynamicTextureURL(UUID simID, UUID primID, string contentType, string url, |
107 | string extraParams, int updateTimer, bool SetBlending, byte AlphaValue) | 111 | string extraParams, int updateTimer, bool SetBlending, byte AlphaValue) |
108 | { | 112 | { |
113 | return AddDynamicTextureURL(simID, primID, contentType, url, extraParams, updateTimer, SetBlending, AlphaValue, ALL_SIDES); | ||
114 | } | ||
115 | |||
116 | public UUID AddDynamicTextureURL(UUID simID, UUID primID, string contentType, string url, | ||
117 | string extraParams, int updateTimer, bool SetBlending, byte AlphaValue, int face) | ||
118 | { | ||
109 | if (RenderPlugins.ContainsKey(contentType)) | 119 | if (RenderPlugins.ContainsKey(contentType)) |
110 | { | 120 | { |
111 | //m_log.Debug("dynamic texture being created: " + url + " of type " + contentType); | 121 | //m_log.Debug("dynamic texture being created: " + url + " of type " + contentType); |
@@ -120,6 +130,7 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture | |||
120 | updater.Params = extraParams; | 130 | updater.Params = extraParams; |
121 | updater.BlendWithOldTexture = SetBlending; | 131 | updater.BlendWithOldTexture = SetBlending; |
122 | updater.FrontAlpha = AlphaValue; | 132 | updater.FrontAlpha = AlphaValue; |
133 | updater.Face = face; | ||
123 | 134 | ||
124 | lock (Updaters) | 135 | lock (Updaters) |
125 | { | 136 | { |
@@ -144,6 +155,12 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture | |||
144 | public UUID AddDynamicTextureData(UUID simID, UUID primID, string contentType, string data, | 155 | public UUID AddDynamicTextureData(UUID simID, UUID primID, string contentType, string data, |
145 | string extraParams, int updateTimer, bool SetBlending, byte AlphaValue) | 156 | string extraParams, int updateTimer, bool SetBlending, byte AlphaValue) |
146 | { | 157 | { |
158 | return AddDynamicTextureData(simID, primID, contentType, data, extraParams, updateTimer, SetBlending, AlphaValue, ALL_SIDES); | ||
159 | } | ||
160 | |||
161 | public UUID AddDynamicTextureData(UUID simID, UUID primID, string contentType, string data, | ||
162 | string extraParams, int updateTimer, bool SetBlending, byte AlphaValue, int face) | ||
163 | { | ||
147 | if (RenderPlugins.ContainsKey(contentType)) | 164 | if (RenderPlugins.ContainsKey(contentType)) |
148 | { | 165 | { |
149 | DynamicTextureUpdater updater = new DynamicTextureUpdater(); | 166 | DynamicTextureUpdater updater = new DynamicTextureUpdater(); |
@@ -156,6 +173,8 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture | |||
156 | updater.Params = extraParams; | 173 | updater.Params = extraParams; |
157 | updater.BlendWithOldTexture = SetBlending; | 174 | updater.BlendWithOldTexture = SetBlending; |
158 | updater.FrontAlpha = AlphaValue; | 175 | updater.FrontAlpha = AlphaValue; |
176 | updater.Face = face; | ||
177 | updater.Url = "Local image"; | ||
159 | 178 | ||
160 | lock (Updaters) | 179 | lock (Updaters) |
161 | { | 180 | { |
@@ -232,6 +251,7 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture | |||
232 | public UUID SimUUID; | 251 | public UUID SimUUID; |
233 | public UUID UpdaterID; | 252 | public UUID UpdaterID; |
234 | public int UpdateTimer; | 253 | public int UpdateTimer; |
254 | public int Face; | ||
235 | public string Url; | 255 | public string Url; |
236 | 256 | ||
237 | public DynamicTextureUpdater() | 257 | public DynamicTextureUpdater() |
@@ -249,7 +269,7 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture | |||
249 | 269 | ||
250 | SceneObjectPart part = scene.GetSceneObjectPart(PrimID); | 270 | SceneObjectPart part = scene.GetSceneObjectPart(PrimID); |
251 | 271 | ||
252 | if (data == null) | 272 | if (data == null || data.Length <= 1) |
253 | { | 273 | { |
254 | string msg = | 274 | string msg = |
255 | String.Format("DynamicTextureModule: Error preparing image using URL {0}", Url); | 275 | String.Format("DynamicTextureModule: Error preparing image using URL {0}", Url); |
@@ -287,34 +307,51 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture | |||
287 | asset.Data = assetData; | 307 | asset.Data = assetData; |
288 | asset.Name = "DynamicImage" + Util.RandomClass.Next(1, 10000); | 308 | asset.Name = "DynamicImage" + Util.RandomClass.Next(1, 10000); |
289 | asset.Type = 0; | 309 | asset.Type = 0; |
290 | asset.Description = "dynamic image"; | 310 | asset.Description = String.Format("URL image : {0}", Url); |
291 | asset.Local = false; | 311 | asset.Local = false; |
292 | asset.Temporary = true; | 312 | asset.Temporary = true; |
293 | scene.AssetService.Store(asset); | 313 | scene.AssetService.Store(asset); |
294 | 314 | ||
295 | LastAssetID = asset.FullID; | ||
296 | |||
297 | IJ2KDecoder cacheLayerDecode = scene.RequestModuleInterface<IJ2KDecoder>(); | 315 | IJ2KDecoder cacheLayerDecode = scene.RequestModuleInterface<IJ2KDecoder>(); |
298 | if (cacheLayerDecode != null) | 316 | if (cacheLayerDecode != null) |
299 | { | 317 | { |
300 | cacheLayerDecode.syncdecode(asset.FullID, asset.Data); | 318 | cacheLayerDecode.syncdecode(asset.FullID, asset.Data); |
319 | cacheLayerDecode = null; | ||
320 | LastAssetID = asset.FullID; | ||
301 | } | 321 | } |
302 | cacheLayerDecode = null; | ||
303 | 322 | ||
304 | // mostly keep the values from before | 323 | // mostly keep the values from before |
305 | Primitive.TextureEntry tmptex = part.Shape.Textures; | 324 | Primitive.TextureEntry tmptex = part.Shape.Textures; |
306 | 325 | ||
307 | // remove the old asset from the cache | 326 | // remove the old asset from the cache later |
308 | // UUID oldID = tmptex.DefaultTexture.TextureID; | 327 | UUID oldID = tmptex.DefaultTexture.TextureID; |
309 | 328 | ||
310 | tmptex.DefaultTexture.TextureID = asset.FullID; | 329 | if (Face == ALL_SIDES) |
330 | { | ||
331 | tmptex.DefaultTexture.TextureID = asset.FullID; | ||
332 | } | ||
333 | else | ||
334 | { | ||
335 | try | ||
336 | { | ||
337 | Primitive.TextureEntryFace texface = tmptex.CreateFace((uint)Face); | ||
338 | texface.TextureID = asset.FullID; | ||
339 | tmptex.FaceTextures[Face] = texface; | ||
340 | } | ||
341 | catch(Exception) | ||
342 | { | ||
343 | tmptex.DefaultTexture.TextureID = asset.FullID; | ||
344 | } | ||
345 | } | ||
346 | |||
311 | // I'm pretty sure we always want to force this to true | 347 | // I'm pretty sure we always want to force this to true |
312 | // I'm pretty sure noone whats to set fullbright true if it wasn't true before. | 348 | // I'm pretty sure noone whats to set fullbright true if it wasn't true before. |
313 | // tmptex.DefaultTexture.Fullbright = true; | 349 | // tmptex.DefaultTexture.Fullbright = true; |
314 | 350 | ||
315 | part.Shape.Textures = tmptex; | 351 | part.UpdateTexture(tmptex); |
316 | part.ScheduleFullUpdate(); | 352 | |
317 | 353 | // scene.CommsManager.AssetCache.ExpireAsset(oldID); | |
354 | scene.AssetService.Delete(oldID.ToString()); | ||
318 | } | 355 | } |
319 | 356 | ||
320 | private byte[] BlendTextures(byte[] frontImage, byte[] backImage, bool setNewAlpha, byte newAlpha) | 357 | private byte[] BlendTextures(byte[] frontImage, byte[] backImage, bool setNewAlpha, byte newAlpha) |