From 87b07c19ef3612c9f330770ea3e0eb066f062284 Mon Sep 17 00:00:00 2001 From: MW Date: Sun, 18 Nov 2007 12:04:21 +0000 Subject: [PATCH] Added "export-map " console command to the region server that will export a jpg image of the world map covering a 20 X 20 regions area centred on the current active region (ie the one set with change-region). While this should work in grid mode (if using the grid asset server and if my last commit did fix the world map), you might need to call the "export-map" command then wait a little while (60 seconds?) and then call it again so that you make sure the region has got all the texture assets from the asset server. --- OpenSim/Region/Application/OpenSimMain.cs | 14 ++++++++ OpenSim/Region/Environment/Scenes/Scene.cs | 42 ++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs index ce2b856322..eb09de3809 100644 --- a/OpenSim/Region/Application/OpenSimMain.cs +++ b/OpenSim/Region/Application/OpenSimMain.cs @@ -688,6 +688,20 @@ namespace OpenSim break; + case "export-map": + if (m_sceneManager.CurrentScene != null) + { + if (cmdparams.Length > 0) + { + m_sceneManager.CurrentScene.ExportWorldMap(cmdparams[0]); + } + else + { + m_sceneManager.CurrentScene.ExportWorldMap("exportmap.jpg"); + } + } + break; + default: m_log.Error("Unknown command"); break; diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 1400e609e5..bc4fa3c8d4 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -470,6 +470,48 @@ namespace OpenSim.Region.Environment.Scenes #region Load Terrain + public void ExportWorldMap(string fileName) + { + List mapBlocks = this.CommsManager.GridService.RequestNeighbourMapBlocks((int)(this.RegionInfo.RegionLocX - 9), (int)(this.RegionInfo.RegionLocY - 9), (int)(this.RegionInfo.RegionLocX + 9), (int)(this.RegionInfo.RegionLocY + 9)); + List textures = new List(); + List bitImages = new List(); + + foreach (MapBlockData mapBlock in mapBlocks) + { + AssetBase texAsset = this.AssetCache.GetAsset(mapBlock.MapImageId, true); + + if (texAsset != null) + { + textures.Add(texAsset); + } + else + { + texAsset = this.AssetCache.GetAsset(mapBlock.MapImageId, true); + if (texAsset != null) + { + textures.Add(texAsset); + } + } + } + + foreach(AssetBase asset in textures) + { + System.Drawing.Image image= OpenJPEGNet.OpenJPEG.DecodeToImage(asset.Data); + bitImages.Add(image); + } + + System.Drawing.Bitmap mapTexture = new System.Drawing.Bitmap(2560, 2560); + System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(mapTexture); + + for(int i =0; i /// Loads the World heightmap ///