aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/MapImageModule.cs50
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/ShadedMapTileRenderer.cs5
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/TexturedMapTileRenderer.cs5
-rw-r--r--OpenSim/Region/Framework/Interfaces/ITerrain.cs1
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs84
5 files changed, 114 insertions, 31 deletions
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapImageModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapImageModule.cs
index b71b5f6..b96d95a 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/MapImageModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/MapImageModule.cs
@@ -70,10 +70,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
70 70
71 #region IMapImageGenerator Members 71 #region IMapImageGenerator Members
72 72
73 public byte[] WriteJpeg2000Image(string gradientmap) 73 public Bitmap CreateMapTile(string gradientmap)
74 { 74 {
75 byte[] imageData = null;
76
77 bool drawPrimVolume = true; 75 bool drawPrimVolume = true;
78 bool textureTerrain = false; 76 bool textureTerrain = false;
79 77
@@ -98,32 +96,36 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
98 } 96 }
99 terrainRenderer.Initialise(m_scene, m_config); 97 terrainRenderer.Initialise(m_scene, m_config);
100 98
101 using (Bitmap mapbmp = new Bitmap((int)Constants.RegionSize, (int)Constants.RegionSize)) 99 Bitmap mapbmp = new Bitmap((int)Constants.RegionSize, (int)Constants.RegionSize, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
102 { 100 //long t = System.Environment.TickCount;
103 //long t = System.Environment.TickCount; 101 //for (int i = 0; i < 10; ++i) {
104 //for (int i = 0; i < 10; ++i) { 102 terrainRenderer.TerrainToBitmap(mapbmp);
105 terrainRenderer.TerrainToBitmap(mapbmp); 103 //}
106 //} 104 //t = System.Environment.TickCount - t;
107 //t = System.Environment.TickCount - t; 105 //m_log.InfoFormat("[MAPTILE] generation of 10 maptiles needed {0} ms", t);
108 //m_log.InfoFormat("[MAPTILE] generation of 10 maptiles needed {0} ms", t);
109 106
110 107
111 if (drawPrimVolume) 108 if (drawPrimVolume)
112 { 109 {
113 DrawObjectVolume(m_scene, mapbmp); 110 DrawObjectVolume(m_scene, mapbmp);
114 } 111 }
115 112
116 try 113 return mapbmp;
117 { 114 }
118 imageData = OpenJPEG.EncodeFromImage(mapbmp, true); 115
119 } 116 public byte[] WriteJpeg2000Image(string gradientmap)
120 catch (Exception e) // LEGIT: Catching problems caused by OpenJPEG p/invoke 117 {
121 { 118 try
122 m_log.Error("Failed generating terrain map: " + e); 119 {
123 } 120 using (Bitmap mapbmp = CreateMapTile(gradientmap))
121 return OpenJPEG.EncodeFromImage(mapbmp, true);
122 }
123 catch (Exception e) // LEGIT: Catching problems caused by OpenJPEG p/invoke
124 {
125 m_log.Error("Failed generating terrain map: " + e);
124 } 126 }
125 127
126 return imageData; 128 return null;
127 } 129 }
128 130
129 #endregion 131 #endregion
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/ShadedMapTileRenderer.cs b/OpenSim/Region/CoreModules/World/WorldMap/ShadedMapTileRenderer.cs
index a297cf3..fef2ef3 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/ShadedMapTileRenderer.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/ShadedMapTileRenderer.cs
@@ -37,6 +37,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
37{ 37{
38 public class ShadedMapTileRenderer : IMapTileTerrainRenderer 38 public class ShadedMapTileRenderer : IMapTileTerrainRenderer
39 { 39 {
40 private static readonly Color WATER_COLOR = Color.FromArgb(29, 71, 95);
41
40 private static readonly ILog m_log = 42 private static readonly ILog m_log =
41 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 43 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
42 44
@@ -221,8 +223,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
221 223
222 try 224 try
223 { 225 {
224 Color water = Color.FromArgb((int)heightvalue, (int)heightvalue, 255); 226 mapbmp.SetPixel(x, yr, WATER_COLOR);
225 mapbmp.SetPixel(x, yr, water);
226 } 227 }
227 catch (ArgumentException) 228 catch (ArgumentException)
228 { 229 {
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/TexturedMapTileRenderer.cs b/OpenSim/Region/CoreModules/World/WorldMap/TexturedMapTileRenderer.cs
index 4ecad74..8b34f6e 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/TexturedMapTileRenderer.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/TexturedMapTileRenderer.cs
@@ -136,6 +136,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
136 private static readonly UUID defaultTerrainTexture4 = new UUID("53a2f406-4895-1d13-d541-d2e3b86bc19c"); 136 private static readonly UUID defaultTerrainTexture4 = new UUID("53a2f406-4895-1d13-d541-d2e3b86bc19c");
137 private static readonly Color defaultColor4 = Color.FromArgb(200, 200, 200); 137 private static readonly Color defaultColor4 = Color.FromArgb(200, 200, 200);
138 138
139 private static readonly Color WATER_COLOR = Color.FromArgb(29, 71, 95);
140
139 #endregion 141 #endregion
140 142
141 143
@@ -406,8 +408,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
406 408
407 heightvalue = 100f - (heightvalue * 100f) / 19f; // 0 - 19 => 100 - 0 409 heightvalue = 100f - (heightvalue * 100f) / 19f; // 0 - 19 => 100 - 0
408 410
409 Color water = Color.FromArgb((int)heightvalue, (int)heightvalue, 255); 411 mapbmp.SetPixel(x, yr, WATER_COLOR);
410 mapbmp.SetPixel(x, yr, water);
411 } 412 }
412 } 413 }
413 } 414 }
diff --git a/OpenSim/Region/Framework/Interfaces/ITerrain.cs b/OpenSim/Region/Framework/Interfaces/ITerrain.cs
index f5662cb..b42e872 100644
--- a/OpenSim/Region/Framework/Interfaces/ITerrain.cs
+++ b/OpenSim/Region/Framework/Interfaces/ITerrain.cs
@@ -73,6 +73,7 @@ namespace OpenSim.Region.Framework.Interfaces
73 73
74 public interface IMapImageGenerator 74 public interface IMapImageGenerator
75 { 75 {
76 System.Drawing.Bitmap CreateMapTile(string gradientmap);
76 byte[] WriteJpeg2000Image(string gradientmap); 77 byte[] WriteJpeg2000Image(string gradientmap);
77 } 78 }
78} 79}
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs
index 3a61226..cc8080f 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs
@@ -28,17 +28,18 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Collections.Specialized; 30using System.Collections.Specialized;
31using System.Drawing;
32using System.Drawing.Imaging;
33using System.IO;
31using System.Net; 34using System.Net;
32using System.Reflection; 35using System.Reflection;
33using log4net; 36using log4net;
34using Mono.Addins; 37using Mono.Addins;
35using Nini.Config; 38using Nini.Config;
36using OpenSim.Framework; 39using OpenSim.Framework;
37using OpenSim.Framework.Servers.HttpServer;
38using OpenSim.Region.Framework.Interfaces; 40using OpenSim.Region.Framework.Interfaces;
39using OpenSim.Region.Framework.Scenes; 41using OpenSim.Region.Framework.Scenes;
40using OpenSim.Services.Interfaces; 42using OpenSim.Services.Interfaces;
41using OpenSim.Server.Base;
42using OpenMetaverse; 43using OpenMetaverse;
43using OpenMetaverse.StructuredData; 44using OpenMetaverse.StructuredData;
44 45
@@ -62,7 +63,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
62 #region ISharedRegionModule 63 #region ISharedRegionModule
63 64
64 public Type ReplaceableInterface { get { return null; } } 65 public Type ReplaceableInterface { get { return null; } }
65 public void RegionLoaded(Scene scene) { } 66 public void RegionLoaded(Scene scene) { UploadMapTile(scene); }
66 public void PostInitialise() { } 67 public void PostInitialise() { }
67 public void Close() { } 68 public void Close() { }
68 69
@@ -356,6 +357,83 @@ namespace OpenSim.Services.Connectors.SimianGrid
356 357
357 #endregion IGridService 358 #endregion IGridService
358 359
360 private void UploadMapTile(IScene scene)
361 {
362 string errorMessage = null;
363
364 // Create a PNG map tile and upload it to the AddMapTile API
365 byte[] pngData = Utils.EmptyBytes;
366 IMapImageGenerator tileGenerator = scene.RequestModuleInterface<IMapImageGenerator>();
367 if (tileGenerator == null)
368 {
369 m_log.Warn("[SIMIAN GRID CONNECTOR]: Cannot upload PNG map tile without an IMapImageGenerator");
370 return;
371 }
372
373 using (Image mapTile = tileGenerator.CreateMapTile("defaultstripe.png"))
374 {
375 using (MemoryStream stream = new MemoryStream())
376 {
377 mapTile.Save(stream, ImageFormat.Png);
378 pngData = stream.ToArray();
379 }
380 }
381
382 List<MultipartForm.Element> postParameters = new List<MultipartForm.Element>()
383 {
384 new MultipartForm.Parameter("X", scene.RegionInfo.RegionLocX.ToString()),
385 new MultipartForm.Parameter("Y", scene.RegionInfo.RegionLocY.ToString()),
386 new MultipartForm.File("Tile", "tile.png", "image/png", pngData)
387 };
388
389 // Make the remote storage request
390 try
391 {
392 HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(m_serverUrl);
393
394 HttpWebResponse response = MultipartForm.Post(request, postParameters);
395 using (Stream responseStream = response.GetResponseStream())
396 {
397 string responseStr = null;
398
399 try
400 {
401 responseStr = responseStream.GetStreamString();
402 OSD responseOSD = OSDParser.Deserialize(responseStr);
403 if (responseOSD.Type == OSDType.Map)
404 {
405 OSDMap responseMap = (OSDMap)responseOSD;
406 if (responseMap["Success"].AsBoolean())
407 m_log.Info("[SIMIAN GRID CONNECTOR]: Uploaded " + pngData.Length + " byte PNG map tile to AddMapTile");
408 else
409 errorMessage = "Upload failed: " + responseMap["Message"].AsString();
410 }
411 else
412 {
413 errorMessage = "Response format was invalid:\n" + responseStr;
414 }
415 }
416 catch (Exception ex)
417 {
418 if (!String.IsNullOrEmpty(responseStr))
419 errorMessage = "Failed to parse the response:\n" + responseStr;
420 else
421 errorMessage = "Failed to retrieve the response: " + ex.Message;
422 }
423 }
424 }
425 catch (WebException ex)
426 {
427 errorMessage = ex.Message;
428 }
429
430 if (!String.IsNullOrEmpty(errorMessage))
431 {
432 m_log.WarnFormat("[SIMIAN GRID CONNECTOR]: Failed to store {0} byte PNG map tile for {1}: {2}",
433 pngData.Length, scene.RegionInfo.RegionName, errorMessage);
434 }
435 }
436
359 private GridRegion GetNearestRegion(Vector3d position, bool onlyEnabled) 437 private GridRegion GetNearestRegion(Vector3d position, bool onlyEnabled)
360 { 438 {
361 NameValueCollection requestArgs = new NameValueCollection 439 NameValueCollection requestArgs = new NameValueCollection