change region console comand export-map: make it work with var regions, center target region and make the display area be the region size plus MaxMaxRegionViewDistance in all 4 directions. Add the region name and total area size text info. Some of this can be made options/comand arguments in future improvements
parent
26ecba48f0
commit
9ae3452e03
|
@ -1399,46 +1399,78 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
|
||||||
m_log.InfoFormat(
|
m_log.InfoFormat(
|
||||||
"[WORLD MAP]: Exporting world map for {0} to {1}", m_scene.RegionInfo.RegionName, exportPath);
|
"[WORLD MAP]: Exporting world map for {0} to {1}", m_scene.RegionInfo.RegionName, exportPath);
|
||||||
|
|
||||||
List<MapBlockData> mapBlocks = new List<MapBlockData>();
|
const int TEXTURESIZE = 2048;
|
||||||
|
Bitmap mapTexture = new Bitmap(TEXTURESIZE, TEXTURESIZE);
|
||||||
|
Graphics g = Graphics.FromImage(mapTexture);
|
||||||
|
SolidBrush sea = new SolidBrush(Color.DarkBlue);
|
||||||
|
g.FillRectangle(sea, 0, 0, TEXTURESIZE, TEXTURESIZE);
|
||||||
|
|
||||||
|
// assumed this is 1m less than next grid line
|
||||||
|
int regionsView = (int)m_scene.MaxRegionViewDistance;
|
||||||
|
|
||||||
|
int regionSizeX = (int)m_scene.RegionInfo.RegionSizeX;
|
||||||
|
int regionSizeY = (int)m_scene.RegionInfo.RegionSizeY;
|
||||||
|
|
||||||
|
int regionX = (int)m_scene.RegionInfo.WorldLocX;
|
||||||
|
int regionY = (int)m_scene.RegionInfo.WorldLocY;
|
||||||
|
|
||||||
|
int startX = regionX - regionsView;
|
||||||
|
int startY = regionY - regionsView;
|
||||||
|
|
||||||
|
int endX = regionX + regionSizeX + regionsView;
|
||||||
|
int endY = regionY + regionSizeY + regionsView;
|
||||||
|
|
||||||
List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID,
|
List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID,
|
||||||
(int)Util.RegionToWorldLoc(m_scene.RegionInfo.RegionLocX - 9),
|
startX, startY, endX, endY);
|
||||||
(int)Util.RegionToWorldLoc(m_scene.RegionInfo.RegionLocX + 9),
|
|
||||||
(int)Util.RegionToWorldLoc(m_scene.RegionInfo.RegionLocY - 9),
|
if(regions.Count > 0)
|
||||||
(int)Util.RegionToWorldLoc(m_scene.RegionInfo.RegionLocY + 9));
|
{
|
||||||
List<AssetBase> textures = new List<AssetBase>();
|
Font drawFont = new Font("Arial", 32);
|
||||||
List<Image> bitImages = new List<Image>();
|
SolidBrush drawBrush = new SolidBrush(Color.White);
|
||||||
|
|
||||||
|
ManagedImage managedImage = null;
|
||||||
|
Image image = null;
|
||||||
|
|
||||||
|
startX--;
|
||||||
|
startY--;
|
||||||
|
|
||||||
|
int spanX = endX - startX + 1;
|
||||||
|
float scaleX = (float)TEXTURESIZE / (float)spanX;
|
||||||
|
int spanY = endY - startY + 1;
|
||||||
|
float scaleY = (float)TEXTURESIZE / (float)spanY;
|
||||||
|
|
||||||
foreach(GridRegion r in regions)
|
foreach(GridRegion r in regions)
|
||||||
{
|
{
|
||||||
MapBlockData mapBlock = new MapBlockData();
|
if(r.TerrainImage == UUID.Zero)
|
||||||
MapBlockFromGridRegion(mapBlock, r, 0);
|
continue;
|
||||||
AssetBase texAsset = m_scene.AssetService.Get(mapBlock.MapImageId.ToString());
|
|
||||||
|
|
||||||
if (texAsset != null)
|
AssetBase texAsset = m_scene.AssetService.Get(r.TerrainImage.ToString());
|
||||||
|
if(texAsset == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if(OpenJPEG.DecodeToImage(texAsset.Data, out managedImage, out image))
|
||||||
{
|
{
|
||||||
textures.Add(texAsset);
|
int x = (int)((r.RegionLocX - startX) * scaleX);
|
||||||
|
int y = (int)((r.RegionLocY - startY ) * scaleY);
|
||||||
|
int sx = (int)(r.RegionSizeX * scaleX);
|
||||||
|
int sy = (int)(r.RegionSizeY * scaleY);
|
||||||
|
g.DrawImage(image, x, TEXTURESIZE - y - sy, sx, sy); // y origin is top
|
||||||
|
if(r.RegionHandle == m_scene.RegionInfo.RegionHandle)
|
||||||
|
{
|
||||||
|
SizeF stringSize = g.MeasureString(r.RegionName, drawFont);
|
||||||
|
g.DrawString(r.RegionName, drawFont, drawBrush, x + 30, TEXTURESIZE - y - 30 - stringSize.Height);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (AssetBase asset in textures)
|
if(image != null)
|
||||||
{
|
image.Dispose();
|
||||||
ManagedImage managedImage;
|
|
||||||
Image image;
|
|
||||||
|
|
||||||
if (OpenJPEG.DecodeToImage(asset.Data, out managedImage, out image))
|
String drawString = string.Format("{0}m x {1}m", spanX, spanY);
|
||||||
bitImages.Add(image);
|
g.DrawString(drawString, drawFont, drawBrush, 30, 30);
|
||||||
}
|
|
||||||
|
|
||||||
Bitmap mapTexture = new Bitmap(2560, 2560);
|
drawBrush.Dispose();
|
||||||
Graphics g = Graphics.FromImage(mapTexture);
|
drawFont.Dispose();
|
||||||
SolidBrush sea = new SolidBrush(Color.DarkBlue);
|
|
||||||
g.FillRectangle(sea, 0, 0, 2560, 2560);
|
|
||||||
|
|
||||||
for (int i = 0; i < mapBlocks.Count; i++)
|
|
||||||
{
|
|
||||||
ushort x = (ushort)((mapBlocks[i].X - m_scene.RegionInfo.RegionLocX) + 10);
|
|
||||||
ushort y = (ushort)((mapBlocks[i].Y - m_scene.RegionInfo.RegionLocY) + 10);
|
|
||||||
g.DrawImage(bitImages[i], (x * 128), 2560 - (y * 128), 128, 128); // y origin is top
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mapTexture.Save(exportPath, ImageFormat.Jpeg);
|
mapTexture.Save(exportPath, ImageFormat.Jpeg);
|
||||||
|
|
Loading…
Reference in New Issue