Added "export-map <filename>" 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.

This commit is contained in:
MW
2007-11-18 12:04:21 +00:00
parent 7f99644864
commit 87b07c19ef
2 changed files with 56 additions and 0 deletions

View File

@@ -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;

View File

@@ -470,6 +470,48 @@ namespace OpenSim.Region.Environment.Scenes
#region Load Terrain
public void ExportWorldMap(string fileName)
{
List<MapBlockData> 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<AssetBase> textures = new List<AssetBase>();
List<System.Drawing.Image> bitImages = new List<System.Drawing.Image>();
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<mapBlocks.Count; i++)
{
ushort x = (ushort) ((mapBlocks[i].X - this.RegionInfo.RegionLocX) + 10);
ushort y = (ushort) ((mapBlocks[i].Y - this.RegionInfo.RegionLocY) + 10);
g.DrawImage(bitImages[i], (x*128), (y*128), 128, 128);
}
mapTexture.Save(fileName, System.Drawing.Imaging.ImageFormat.Jpeg);
}
/// <summary>
/// Loads the World heightmap
/// </summary>