aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs')
-rw-r--r--OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs80
1 files changed, 44 insertions, 36 deletions
diff --git a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs
index c369d87..090cb7d 100644
--- a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs
@@ -135,17 +135,13 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
135 m_reuseableDynamicTextures.Store( 135 m_reuseableDynamicTextures.Store(
136 GenerateReusableTextureKey(texture.InputCommands, texture.InputParams), newTextureID); 136 GenerateReusableTextureKey(texture.InputCommands, texture.InputParams), newTextureID);
137 } 137 }
138 updater.newTextureID = newTextureID;
138 } 139 }
139 }
140 140
141 if (updater.UpdateTimer == 0)
142 {
143 lock (Updaters) 141 lock (Updaters)
144 { 142 {
145 if (!Updaters.ContainsKey(updater.UpdaterID)) 143 if (Updaters.ContainsKey(updater.UpdaterID))
146 {
147 Updaters.Remove(updater.UpdaterID); 144 Updaters.Remove(updater.UpdaterID);
148 }
149 } 145 }
150 } 146 }
151 } 147 }
@@ -172,21 +168,20 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
172 } 168 }
173 169
174 public UUID AddDynamicTextureURL(UUID simID, UUID primID, string contentType, string url, 170 public UUID AddDynamicTextureURL(UUID simID, UUID primID, string contentType, string url,
175 string extraParams, int updateTimer) 171 string extraParams)
176 { 172 {
177 return AddDynamicTextureURL(simID, primID, contentType, url, extraParams, updateTimer, false, 255); 173 return AddDynamicTextureURL(simID, primID, contentType, url, extraParams, false, 255);
178 } 174 }
179 175
180 public UUID AddDynamicTextureURL(UUID simID, UUID primID, string contentType, string url, 176 public UUID AddDynamicTextureURL(UUID simID, UUID primID, string contentType, string url,
181 string extraParams, int updateTimer, bool SetBlending, byte AlphaValue) 177 string extraParams, bool SetBlending, byte AlphaValue)
182 { 178 {
183 return AddDynamicTextureURL(simID, primID, contentType, url, 179 return AddDynamicTextureURL(simID, primID, contentType, url, extraParams, SetBlending,
184 extraParams, updateTimer, SetBlending, 180 (DISP_TEMP|DISP_EXPIRE), AlphaValue, ALL_SIDES);
185 (int)(DISP_TEMP|DISP_EXPIRE), AlphaValue, ALL_SIDES);
186 } 181 }
187 182
188 public UUID AddDynamicTextureURL(UUID simID, UUID primID, string contentType, string url, 183 public UUID AddDynamicTextureURL(UUID simID, UUID primID, string contentType, string url,
189 string extraParams, int updateTimer, bool SetBlending, 184 string extraParams, bool SetBlending,
190 int disp, byte AlphaValue, int face) 185 int disp, byte AlphaValue, int face)
191 { 186 {
192 if (RenderPlugins.ContainsKey(contentType)) 187 if (RenderPlugins.ContainsKey(contentType))
@@ -196,7 +191,6 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
196 updater.PrimID = primID; 191 updater.PrimID = primID;
197 updater.ContentType = contentType; 192 updater.ContentType = contentType;
198 updater.Url = url; 193 updater.Url = url;
199 updater.UpdateTimer = updateTimer;
200 updater.UpdaterID = UUID.Random(); 194 updater.UpdaterID = UUID.Random();
201 updater.Params = extraParams; 195 updater.Params = extraParams;
202 updater.BlendWithOldTexture = SetBlending; 196 updater.BlendWithOldTexture = SetBlending;
@@ -213,26 +207,27 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
213 } 207 }
214 208
215 RenderPlugins[contentType].AsyncConvertUrl(updater.UpdaterID, url, extraParams); 209 RenderPlugins[contentType].AsyncConvertUrl(updater.UpdaterID, url, extraParams);
216 return updater.UpdaterID; 210 return updater.newTextureID;
217 } 211 }
218 return UUID.Zero; 212 return UUID.Zero;
219 } 213 }
220 214
221 public UUID AddDynamicTextureData(UUID simID, UUID primID, string contentType, string data, 215 public UUID AddDynamicTextureData(UUID simID, UUID primID, string contentType, string data,
222 string extraParams, int updateTimer) 216 string extraParams)
223 { 217 {
224 return AddDynamicTextureData(simID, primID, contentType, data, extraParams, updateTimer, false, 255); 218 return AddDynamicTextureData(simID, primID, contentType, data, extraParams, false,
219 (DISP_TEMP|DISP_EXPIRE), 255, ALL_SIDES);
225 } 220 }
226 221
227 public UUID AddDynamicTextureData(UUID simID, UUID primID, string contentType, string data, 222 public UUID AddDynamicTextureData(UUID simID, UUID primID, string contentType, string data,
228 string extraParams, int updateTimer, bool SetBlending, byte AlphaValue) 223 string extraParams, bool SetBlending, byte AlphaValue)
229 { 224 {
230 return AddDynamicTextureData(simID, primID, contentType, data, extraParams, updateTimer, SetBlending, 225 return AddDynamicTextureData(simID, primID, contentType, data, extraParams, SetBlending,
231 (int) (DISP_TEMP|DISP_EXPIRE), AlphaValue, ALL_SIDES); 226 (DISP_TEMP|DISP_EXPIRE), AlphaValue, ALL_SIDES);
232 } 227 }
233 228
234 public UUID AddDynamicTextureData(UUID simID, UUID primID, string contentType, string data, 229 public UUID AddDynamicTextureData(UUID simID, UUID primID, string contentType, string data,
235 string extraParams, int updateTimer, bool SetBlending, int disp, byte AlphaValue, int face) 230 string extraParams, bool SetBlending, int disp, byte AlphaValue, int face)
236 { 231 {
237 if (!RenderPlugins.ContainsKey(contentType)) 232 if (!RenderPlugins.ContainsKey(contentType))
238 return UUID.Zero; 233 return UUID.Zero;
@@ -258,7 +253,6 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
258 updater.PrimID = primID; 253 updater.PrimID = primID;
259 updater.ContentType = contentType; 254 updater.ContentType = contentType;
260 updater.BodyData = data; 255 updater.BodyData = data;
261 updater.UpdateTimer = updateTimer;
262 updater.UpdaterID = UUID.Random(); 256 updater.UpdaterID = UUID.Random();
263 updater.Params = extraParams; 257 updater.Params = extraParams;
264 updater.BlendWithOldTexture = SetBlending; 258 updater.BlendWithOldTexture = SetBlending;
@@ -314,7 +308,7 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
314 updater.UpdatePart(part, (UUID)objReusableTextureUUID); 308 updater.UpdatePart(part, (UUID)objReusableTextureUUID);
315 } 309 }
316 310
317 return updater.UpdaterID; 311 return updater.newTextureID;
318 } 312 }
319 313
320 private string GenerateReusableTextureKey(string data, string extraParams) 314 private string GenerateReusableTextureKey(string data, string extraParams)
@@ -404,17 +398,15 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
404 public byte FrontAlpha = 255; 398 public byte FrontAlpha = 255;
405 public string Params; 399 public string Params;
406 public UUID PrimID; 400 public UUID PrimID;
407 public bool SetNewFrontAlpha = false;
408 public UUID SimUUID; 401 public UUID SimUUID;
409 public UUID UpdaterID; 402 public UUID UpdaterID;
410 public int UpdateTimer;
411 public int Face; 403 public int Face;
412 public int Disp; 404 public int Disp;
413 public string Url; 405 public string Url;
406 public UUID newTextureID;
414 407
415 public DynamicTextureUpdater() 408 public DynamicTextureUpdater()
416 { 409 {
417 UpdateTimer = 0;
418 BodyData = null; 410 BodyData = null;
419 } 411 }
420 412
@@ -436,16 +428,23 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
436 // FIXME: Need to return the appropriate ID if only a single face is replaced. 428 // FIXME: Need to return the appropriate ID if only a single face is replaced.
437 oldID = tmptex.DefaultTexture.TextureID; 429 oldID = tmptex.DefaultTexture.TextureID;
438 430
431 // not using parts number of faces because that fails on old meshs
439 if (Face == ALL_SIDES) 432 if (Face == ALL_SIDES)
440 { 433 {
441 oldID = tmptex.DefaultTexture.TextureID; 434 oldID = tmptex.DefaultTexture.TextureID;
442 tmptex.DefaultTexture.TextureID = textureID; 435 tmptex.DefaultTexture.TextureID = textureID;
436 for(int i = 0; i < tmptex.FaceTextures.Length; i++)
437 {
438 if(tmptex.FaceTextures[i] != null)
439 tmptex.FaceTextures[i].TextureID = textureID;
440 }
443 } 441 }
444 else 442 else
445 { 443 {
446 try 444 try
447 { 445 {
448 Primitive.TextureEntryFace texface = tmptex.CreateFace((uint)Face); 446 Primitive.TextureEntryFace texface = tmptex.CreateFace((uint)Face);
447 oldID = texface.TextureID;
449 texface.TextureID = textureID; 448 texface.TextureID = textureID;
450 tmptex.FaceTextures[Face] = texface; 449 tmptex.FaceTextures[Face] = texface;
451 } 450 }
@@ -455,10 +454,6 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
455 } 454 }
456 } 455 }
457 456
458 // I'm pretty sure we always want to force this to true
459 // I'm pretty sure noone whats to set fullbright true if it wasn't true before.
460 // tmptex.DefaultTexture.Fullbright = true;
461
462 part.UpdateTextureEntry(tmptex.GetBytes()); 457 part.UpdateTextureEntry(tmptex.GetBytes());
463 } 458 }
464 459
@@ -491,13 +486,26 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
491 486
492 if (BlendWithOldTexture) 487 if (BlendWithOldTexture)
493 { 488 {
494 Primitive.TextureEntryFace defaultFace = part.Shape.Textures.DefaultTexture; 489 Primitive.TextureEntryFace curFace;
495 if (defaultFace != null) 490 if(Face == ALL_SIDES)
491 curFace = part.Shape.Textures.DefaultTexture;
492 else
493 {
494 try
495 {
496 curFace = part.Shape.Textures.GetFace((uint)Face);
497 }
498 catch
499 {
500 curFace = null;
501 }
502 }
503 if (curFace != null)
496 { 504 {
497 oldAsset = scene.AssetService.Get(defaultFace.TextureID.ToString()); 505 oldAsset = scene.AssetService.Get(curFace.TextureID.ToString());
498 506
499 if (oldAsset != null) 507 if (oldAsset != null)
500 assetData = BlendTextures(data, oldAsset.Data, SetNewFrontAlpha, FrontAlpha); 508 assetData = BlendTextures(data, oldAsset.Data, FrontAlpha);
501 } 509 }
502 } 510 }
503 511
@@ -548,7 +556,7 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
548 return asset.FullID; 556 return asset.FullID;
549 } 557 }
550 558
551 private byte[] BlendTextures(byte[] frontImage, byte[] backImage, bool setNewAlpha, byte newAlpha) 559 private byte[] BlendTextures(byte[] frontImage, byte[] backImage, byte newAlpha)
552 { 560 {
553 ManagedImage managedImage; 561 ManagedImage managedImage;
554 Image image; 562 Image image;
@@ -568,7 +576,7 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
568 Bitmap image2 = new Bitmap(image); 576 Bitmap image2 = new Bitmap(image);
569 image.Dispose(); 577 image.Dispose();
570 578
571 if (setNewAlpha) 579 if (newAlpha < 255)
572 SetAlpha(ref image1, newAlpha); 580 SetAlpha(ref image1, newAlpha);
573 581
574 using(Bitmap joint = MergeBitMaps(image1, image2)) 582 using(Bitmap joint = MergeBitMaps(image1, image2))