diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs | 110 |
1 files changed, 79 insertions, 31 deletions
diff --git a/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs b/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs index 8a422b0..40638f8 100644 --- a/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs +++ b/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs | |||
@@ -77,42 +77,48 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | |||
77 | { | 77 | { |
78 | bool drawPrimVolume = true; | 78 | bool drawPrimVolume = true; |
79 | bool textureTerrain = false; | 79 | bool textureTerrain = false; |
80 | bool generateMaptiles = true; | ||
81 | Bitmap mapbmp; | ||
80 | 82 | ||
81 | try | 83 | string[] configSections = new string[] { "Map", "Startup" }; |
82 | { | ||
83 | IConfig startupConfig = m_config.Configs["Startup"]; | ||
84 | drawPrimVolume = startupConfig.GetBoolean("DrawPrimOnMapTile", drawPrimVolume); | ||
85 | textureTerrain = startupConfig.GetBoolean("TextureOnMapTile", textureTerrain); | ||
86 | } | ||
87 | catch | ||
88 | { | ||
89 | m_log.Warn("[MAPTILE]: Failed to load StartupConfig"); | ||
90 | } | ||
91 | 84 | ||
92 | if (textureTerrain) | 85 | drawPrimVolume |
93 | { | 86 | = Util.GetConfigVarFromSections<bool>(m_config, "DrawPrimOnMapTile", configSections, drawPrimVolume); |
94 | terrainRenderer = new TexturedMapTileRenderer(); | 87 | textureTerrain |
95 | } | 88 | = Util.GetConfigVarFromSections<bool>(m_config, "TextureOnMapTile", configSections, textureTerrain); |
96 | else | 89 | generateMaptiles |
90 | = Util.GetConfigVarFromSections<bool>(m_config, "GenerateMaptiles", configSections, generateMaptiles); | ||
91 | |||
92 | if (generateMaptiles) | ||
97 | { | 93 | { |
98 | terrainRenderer = new ShadedMapTileRenderer(); | 94 | if (textureTerrain) |
99 | } | 95 | { |
100 | terrainRenderer.Initialise(m_scene, m_config); | 96 | terrainRenderer = new TexturedMapTileRenderer(); |
97 | } | ||
98 | else | ||
99 | { | ||
100 | terrainRenderer = new ShadedMapTileRenderer(); | ||
101 | } | ||
101 | 102 | ||
102 | Bitmap mapbmp = new Bitmap((int)Constants.RegionSize, (int)Constants.RegionSize, System.Drawing.Imaging.PixelFormat.Format24bppRgb); | 103 | terrainRenderer.Initialise(m_scene, m_config); |
103 | //long t = System.Environment.TickCount; | ||
104 | //for (int i = 0; i < 10; ++i) { | ||
105 | terrainRenderer.TerrainToBitmap(mapbmp); | ||
106 | //} | ||
107 | //t = System.Environment.TickCount - t; | ||
108 | //m_log.InfoFormat("[MAPTILE] generation of 10 maptiles needed {0} ms", t); | ||
109 | 104 | ||
105 | mapbmp = new Bitmap((int)Constants.RegionSize, (int)Constants.RegionSize, System.Drawing.Imaging.PixelFormat.Format24bppRgb); | ||
106 | //long t = System.Environment.TickCount; | ||
107 | //for (int i = 0; i < 10; ++i) { | ||
108 | terrainRenderer.TerrainToBitmap(mapbmp); | ||
109 | //} | ||
110 | //t = System.Environment.TickCount - t; | ||
111 | //m_log.InfoFormat("[MAPTILE] generation of 10 maptiles needed {0} ms", t); | ||
110 | 112 | ||
111 | if (drawPrimVolume) | 113 | if (drawPrimVolume) |
114 | { | ||
115 | DrawObjectVolume(m_scene, mapbmp); | ||
116 | } | ||
117 | } | ||
118 | else | ||
112 | { | 119 | { |
113 | DrawObjectVolume(m_scene, mapbmp); | 120 | mapbmp = FetchTexture(m_scene.RegionInfo.RegionSettings.TerrainImageID); |
114 | } | 121 | } |
115 | |||
116 | return mapbmp; | 122 | return mapbmp; |
117 | } | 123 | } |
118 | 124 | ||
@@ -139,9 +145,8 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | |||
139 | { | 145 | { |
140 | m_config = source; | 146 | m_config = source; |
141 | 147 | ||
142 | IConfig startupConfig = m_config.Configs["Startup"]; | 148 | if (Util.GetConfigVarFromSections<string>( |
143 | if (startupConfig.GetString("MapImageModule", "MapImageModule") != | 149 | m_config, "MapImageModule", new string[] { "Startup", "Map" }, "MapImageModule") != "MapImageModule") |
144 | "MapImageModule") | ||
145 | return; | 150 | return; |
146 | 151 | ||
147 | m_Enabled = true; | 152 | m_Enabled = true; |
@@ -222,6 +227,49 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | |||
222 | // } | 227 | // } |
223 | // } | 228 | // } |
224 | 229 | ||
230 | private Bitmap FetchTexture(UUID id) | ||
231 | { | ||
232 | AssetBase asset = m_scene.AssetService.Get(id.ToString()); | ||
233 | |||
234 | if (asset != null) | ||
235 | { | ||
236 | m_log.DebugFormat("[MAPTILE]: Static map image texture {0} found for {1}", id, m_scene.Name); | ||
237 | } | ||
238 | else | ||
239 | { | ||
240 | m_log.WarnFormat("[MAPTILE]: Static map image texture {0} not found for {1}", id, m_scene.Name); | ||
241 | return null; | ||
242 | } | ||
243 | |||
244 | ManagedImage managedImage; | ||
245 | Image image; | ||
246 | |||
247 | try | ||
248 | { | ||
249 | if (OpenJPEG.DecodeToImage(asset.Data, out managedImage, out image)) | ||
250 | return new Bitmap(image); | ||
251 | else | ||
252 | return null; | ||
253 | } | ||
254 | catch (DllNotFoundException) | ||
255 | { | ||
256 | m_log.ErrorFormat("[MAPTILE]: OpenJpeg is not installed correctly on this system. Asset Data is empty for {0}", id); | ||
257 | |||
258 | } | ||
259 | catch (IndexOutOfRangeException) | ||
260 | { | ||
261 | m_log.ErrorFormat("[MAPTILE]: OpenJpeg was unable to decode this. Asset Data is empty for {0}", id); | ||
262 | |||
263 | } | ||
264 | catch (Exception) | ||
265 | { | ||
266 | m_log.ErrorFormat("[MAPTILE]: OpenJpeg was unable to decode this. Asset Data is empty for {0}", id); | ||
267 | |||
268 | } | ||
269 | return null; | ||
270 | |||
271 | } | ||
272 | |||
225 | private Bitmap DrawObjectVolume(Scene whichScene, Bitmap mapbmp) | 273 | private Bitmap DrawObjectVolume(Scene whichScene, Bitmap mapbmp) |
226 | { | 274 | { |
227 | int tc = 0; | 275 | int tc = 0; |