aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/Scripting/DynamicTexture
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Scripting/DynamicTexture')
-rw-r--r--OpenSim/Region/Environment/Modules/Scripting/DynamicTexture/DynamicTextureModule.cs68
1 files changed, 40 insertions, 28 deletions
diff --git a/OpenSim/Region/Environment/Modules/Scripting/DynamicTexture/DynamicTextureModule.cs b/OpenSim/Region/Environment/Modules/Scripting/DynamicTexture/DynamicTextureModule.cs
index 15ce584..59d29d6 100644
--- a/OpenSim/Region/Environment/Modules/Scripting/DynamicTexture/DynamicTextureModule.cs
+++ b/OpenSim/Region/Environment/Modules/Scripting/DynamicTexture/DynamicTextureModule.cs
@@ -29,9 +29,9 @@ using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Drawing; 30using System.Drawing;
31using System.Drawing.Imaging; 31using System.Drawing.Imaging;
32using libsecondlife; 32using OpenMetaverse;
33using OpenMetaverse.Imaging;
33using Nini.Config; 34using Nini.Config;
34using OpenJPEGNet;
35using OpenSim.Framework; 35using OpenSim.Framework;
36using OpenSim.Region.Environment.Interfaces; 36using OpenSim.Region.Environment.Interfaces;
37using OpenSim.Region.Environment.Scenes; 37using OpenSim.Region.Environment.Scenes;
@@ -40,12 +40,12 @@ namespace OpenSim.Region.Environment.Modules.Scripting.DynamicTexture
40{ 40{
41 public class DynamicTextureModule : IRegionModule, IDynamicTextureManager 41 public class DynamicTextureModule : IRegionModule, IDynamicTextureManager
42 { 42 {
43 private Dictionary<LLUUID, Scene> RegisteredScenes = new Dictionary<LLUUID, Scene>(); 43 private Dictionary<UUID, Scene> RegisteredScenes = new Dictionary<UUID, Scene>();
44 44
45 private Dictionary<string, IDynamicTextureRender> RenderPlugins = 45 private Dictionary<string, IDynamicTextureRender> RenderPlugins =
46 new Dictionary<string, IDynamicTextureRender>(); 46 new Dictionary<string, IDynamicTextureRender>();
47 47
48 private Dictionary<LLUUID, DynamicTextureUpdater> Updaters = new Dictionary<LLUUID, DynamicTextureUpdater>(); 48 private Dictionary<UUID, DynamicTextureUpdater> Updaters = new Dictionary<UUID, DynamicTextureUpdater>();
49 49
50 #region IDynamicTextureManager Members 50 #region IDynamicTextureManager Members
51 51
@@ -62,7 +62,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.DynamicTexture
62 /// </summary> 62 /// </summary>
63 /// <param name="id"></param> 63 /// <param name="id"></param>
64 /// <param name="data"></param> 64 /// <param name="data"></param>
65 public void ReturnData(LLUUID id, byte[] data) 65 public void ReturnData(UUID id, byte[] data)
66 { 66 {
67 if (Updaters.ContainsKey(id)) 67 if (Updaters.ContainsKey(id))
68 { 68 {
@@ -75,13 +75,13 @@ namespace OpenSim.Region.Environment.Modules.Scripting.DynamicTexture
75 } 75 }
76 } 76 }
77 77
78 public LLUUID AddDynamicTextureURL(LLUUID simID, LLUUID primID, string contentType, string url, 78 public UUID AddDynamicTextureURL(UUID simID, UUID primID, string contentType, string url,
79 string extraParams, int updateTimer) 79 string extraParams, int updateTimer)
80 { 80 {
81 return AddDynamicTextureURL(simID, primID, contentType, url, extraParams, updateTimer, false, 255); 81 return AddDynamicTextureURL(simID, primID, contentType, url, extraParams, updateTimer, false, 255);
82 } 82 }
83 83
84 public LLUUID AddDynamicTextureURL(LLUUID simID, LLUUID primID, string contentType, string url, 84 public UUID AddDynamicTextureURL(UUID simID, UUID primID, string contentType, string url,
85 string extraParams, int updateTimer, bool SetBlending, byte AlphaValue) 85 string extraParams, int updateTimer, bool SetBlending, byte AlphaValue)
86 { 86 {
87 if (RenderPlugins.ContainsKey(contentType)) 87 if (RenderPlugins.ContainsKey(contentType))
@@ -94,7 +94,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.DynamicTexture
94 updater.ContentType = contentType; 94 updater.ContentType = contentType;
95 updater.Url = url; 95 updater.Url = url;
96 updater.UpdateTimer = updateTimer; 96 updater.UpdateTimer = updateTimer;
97 updater.UpdaterID = LLUUID.Random(); 97 updater.UpdaterID = UUID.Random();
98 updater.Params = extraParams; 98 updater.Params = extraParams;
99 updater.BlendWithOldTexture = SetBlending; 99 updater.BlendWithOldTexture = SetBlending;
100 updater.FrontAlpha = AlphaValue; 100 updater.FrontAlpha = AlphaValue;
@@ -107,16 +107,16 @@ namespace OpenSim.Region.Environment.Modules.Scripting.DynamicTexture
107 RenderPlugins[contentType].AsyncConvertUrl(updater.UpdaterID, url, extraParams); 107 RenderPlugins[contentType].AsyncConvertUrl(updater.UpdaterID, url, extraParams);
108 return updater.UpdaterID; 108 return updater.UpdaterID;
109 } 109 }
110 return LLUUID.Zero; 110 return UUID.Zero;
111 } 111 }
112 112
113 public LLUUID AddDynamicTextureData(LLUUID simID, LLUUID primID, string contentType, string data, 113 public UUID AddDynamicTextureData(UUID simID, UUID primID, string contentType, string data,
114 string extraParams, int updateTimer) 114 string extraParams, int updateTimer)
115 { 115 {
116 return AddDynamicTextureData(simID, primID, contentType, data, extraParams, updateTimer, false, 255); 116 return AddDynamicTextureData(simID, primID, contentType, data, extraParams, updateTimer, false, 255);
117 } 117 }
118 118
119 public LLUUID AddDynamicTextureData(LLUUID simID, LLUUID primID, string contentType, string data, 119 public UUID AddDynamicTextureData(UUID simID, UUID primID, string contentType, string data,
120 string extraParams, int updateTimer, bool SetBlending, byte AlphaValue) 120 string extraParams, int updateTimer, bool SetBlending, byte AlphaValue)
121 { 121 {
122 if (RenderPlugins.ContainsKey(contentType)) 122 if (RenderPlugins.ContainsKey(contentType))
@@ -127,7 +127,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.DynamicTexture
127 updater.ContentType = contentType; 127 updater.ContentType = contentType;
128 updater.BodyData = data; 128 updater.BodyData = data;
129 updater.UpdateTimer = updateTimer; 129 updater.UpdateTimer = updateTimer;
130 updater.UpdaterID = LLUUID.Random(); 130 updater.UpdaterID = UUID.Random();
131 updater.Params = extraParams; 131 updater.Params = extraParams;
132 updater.BlendWithOldTexture = SetBlending; 132 updater.BlendWithOldTexture = SetBlending;
133 updater.FrontAlpha = AlphaValue; 133 updater.FrontAlpha = AlphaValue;
@@ -140,7 +140,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.DynamicTexture
140 RenderPlugins[contentType].AsyncConvertData(updater.UpdaterID, data, extraParams); 140 RenderPlugins[contentType].AsyncConvertData(updater.UpdaterID, data, extraParams);
141 return updater.UpdaterID; 141 return updater.UpdaterID;
142 } 142 }
143 return LLUUID.Zero; 143 return UUID.Zero;
144 } 144 }
145 145
146 #endregion 146 #endregion
@@ -184,18 +184,18 @@ namespace OpenSim.Region.Environment.Modules.Scripting.DynamicTexture
184 public string BodyData; 184 public string BodyData;
185 public string ContentType; 185 public string ContentType;
186 public byte FrontAlpha = 255; 186 public byte FrontAlpha = 255;
187 public LLUUID LastAssetID; 187 public UUID LastAssetID;
188 public string Params; 188 public string Params;
189 public LLUUID PrimID; 189 public UUID PrimID;
190 public bool SetNewFrontAlpha = false; 190 public bool SetNewFrontAlpha = false;
191 public LLUUID SimUUID; 191 public UUID SimUUID;
192 public LLUUID UpdaterID; 192 public UUID UpdaterID;
193 public int UpdateTimer; 193 public int UpdateTimer;
194 public string Url; 194 public string Url;
195 195
196 public DynamicTextureUpdater() 196 public DynamicTextureUpdater()
197 { 197 {
198 LastAssetID = LLUUID.Zero; 198 LastAssetID = UUID.Zero;
199 UpdateTimer = 0; 199 UpdateTimer = 0;
200 BodyData = null; 200 BodyData = null;
201 } 201 }
@@ -211,7 +211,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.DynamicTexture
211 211
212 if (BlendWithOldTexture) 212 if (BlendWithOldTexture)
213 { 213 {
214 LLUUID lastTextureID = part.Shape.Textures.DefaultTexture.TextureID; 214 UUID lastTextureID = part.Shape.Textures.DefaultTexture.TextureID;
215 oldAsset = scene.AssetCache.GetAsset(lastTextureID, true); 215 oldAsset = scene.AssetCache.GetAsset(lastTextureID, true);
216 if (oldAsset != null) 216 if (oldAsset != null)
217 { 217 {
@@ -231,7 +231,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.DynamicTexture
231 231
232 // Create a new asset for user 232 // Create a new asset for user
233 AssetBase asset = new AssetBase(); 233 AssetBase asset = new AssetBase();
234 asset.FullID = LLUUID.Random(); 234 asset.FullID = UUID.Random();
235 asset.Data = assetData; 235 asset.Data = assetData;
236 asset.Name = "DynamicImage" + Util.RandomClass.Next(1, 10000); 236 asset.Name = "DynamicImage" + Util.RandomClass.Next(1, 10000);
237 asset.Type = 0; 237 asset.Type = 0;
@@ -243,10 +243,10 @@ namespace OpenSim.Region.Environment.Modules.Scripting.DynamicTexture
243 LastAssetID = asset.FullID; 243 LastAssetID = asset.FullID;
244 244
245 // mostly keep the values from before 245 // mostly keep the values from before
246 LLObject.TextureEntry tmptex = part.Shape.Textures; 246 Primitive.TextureEntry tmptex = part.Shape.Textures;
247 247
248 // remove the old asset from the cache 248 // remove the old asset from the cache
249 LLUUID oldID = tmptex.DefaultTexture.TextureID; 249 UUID oldID = tmptex.DefaultTexture.TextureID;
250 scene.AssetCache.ExpireAsset(oldID); 250 scene.AssetCache.ExpireAsset(oldID);
251 251
252 tmptex.DefaultTexture.TextureID = asset.FullID; 252 tmptex.DefaultTexture.TextureID = asset.FullID;
@@ -259,15 +259,27 @@ namespace OpenSim.Region.Environment.Modules.Scripting.DynamicTexture
259 259
260 private byte[] BlendTextures(byte[] frontImage, byte[] backImage, bool setNewAlpha, byte newAlpha) 260 private byte[] BlendTextures(byte[] frontImage, byte[] backImage, bool setNewAlpha, byte newAlpha)
261 { 261 {
262 Bitmap image1 = new Bitmap(OpenJPEG.DecodeToImage(frontImage)); 262 ManagedImage managedImage;
263 Bitmap image2 = new Bitmap(OpenJPEG.DecodeToImage(backImage)); 263 Image image;
264 if (setNewAlpha) 264
265 if (OpenJPEG.DecodeToImage(frontImage, out managedImage, out image))
265 { 266 {
266 SetAlpha(ref image1, newAlpha); 267 Bitmap image1 = new Bitmap(image);
268
269 if (OpenJPEG.DecodeToImage(backImage, out managedImage, out image))
270 {
271 Bitmap image2 = new Bitmap(image);
272
273 if (setNewAlpha)
274 SetAlpha(ref image1, newAlpha);
275
276 Bitmap joint = MergeBitMaps(image1, image2);
277
278 return OpenJPEG.EncodeFromImage(joint, true);
279 }
267 } 280 }
268 Bitmap joint = MergeBitMaps(image1, image2);
269 281
270 return OpenJPEG.EncodeFromImage(joint, true); 282 return null;
271 } 283 }
272 284
273 public Bitmap MergeBitMaps(Bitmap front, Bitmap back) 285 public Bitmap MergeBitMaps(Bitmap front, Bitmap back)