aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules
diff options
context:
space:
mode:
authorUbitUmarov2018-05-01 16:01:11 +0100
committerUbitUmarov2018-05-01 16:01:11 +0100
commit9ae3452e03ee54cfa0ed0c354280005df1b98f85 (patch)
treedd917ed06bbb892be5e8db8a6889f9114660b596 /OpenSim/Region/CoreModules
parentMerge branch 'master' into httptests (diff)
downloadopensim-SC-9ae3452e03ee54cfa0ed0c354280005df1b98f85.zip
opensim-SC-9ae3452e03ee54cfa0ed0c354280005df1b98f85.tar.gz
opensim-SC-9ae3452e03ee54cfa0ed0c354280005df1b98f85.tar.bz2
opensim-SC-9ae3452e03ee54cfa0ed0c354280005df1b98f85.tar.xz
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
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs94
1 files changed, 63 insertions, 31 deletions
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
index b5a6912..64eda2f 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
@@ -1399,46 +1399,78 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1399 m_log.InfoFormat( 1399 m_log.InfoFormat(
1400 "[WORLD MAP]: Exporting world map for {0} to {1}", m_scene.RegionInfo.RegionName, exportPath); 1400 "[WORLD MAP]: Exporting world map for {0} to {1}", m_scene.RegionInfo.RegionName, exportPath);
1401 1401
1402 List<MapBlockData> mapBlocks = new List<MapBlockData>(); 1402 const int TEXTURESIZE = 2048;
1403 Bitmap mapTexture = new Bitmap(TEXTURESIZE, TEXTURESIZE);
1404 Graphics g = Graphics.FromImage(mapTexture);
1405 SolidBrush sea = new SolidBrush(Color.DarkBlue);
1406 g.FillRectangle(sea, 0, 0, TEXTURESIZE, TEXTURESIZE);
1407
1408 // assumed this is 1m less than next grid line
1409 int regionsView = (int)m_scene.MaxRegionViewDistance;
1410
1411 int regionSizeX = (int)m_scene.RegionInfo.RegionSizeX;
1412 int regionSizeY = (int)m_scene.RegionInfo.RegionSizeY;
1413
1414 int regionX = (int)m_scene.RegionInfo.WorldLocX;
1415 int regionY = (int)m_scene.RegionInfo.WorldLocY;
1416
1417 int startX = regionX - regionsView;
1418 int startY = regionY - regionsView;
1419
1420 int endX = regionX + regionSizeX + regionsView;
1421 int endY = regionY + regionSizeY + regionsView;
1422
1403 List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID, 1423 List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID,
1404 (int)Util.RegionToWorldLoc(m_scene.RegionInfo.RegionLocX - 9), 1424 startX, startY, endX, endY);
1405 (int)Util.RegionToWorldLoc(m_scene.RegionInfo.RegionLocX + 9),
1406 (int)Util.RegionToWorldLoc(m_scene.RegionInfo.RegionLocY - 9),
1407 (int)Util.RegionToWorldLoc(m_scene.RegionInfo.RegionLocY + 9));
1408 List<AssetBase> textures = new List<AssetBase>();
1409 List<Image> bitImages = new List<Image>();
1410 1425
1411 foreach (GridRegion r in regions) 1426 if(regions.Count > 0)
1412 { 1427 {
1413 MapBlockData mapBlock = new MapBlockData(); 1428 Font drawFont = new Font("Arial", 32);
1414 MapBlockFromGridRegion(mapBlock, r, 0); 1429 SolidBrush drawBrush = new SolidBrush(Color.White);
1415 AssetBase texAsset = m_scene.AssetService.Get(mapBlock.MapImageId.ToString()); 1430
1431 ManagedImage managedImage = null;
1432 Image image = null;
1433
1434 startX--;
1435 startY--;
1436
1437 int spanX = endX - startX + 1;
1438 float scaleX = (float)TEXTURESIZE / (float)spanX;
1439 int spanY = endY - startY + 1;
1440 float scaleY = (float)TEXTURESIZE / (float)spanY;
1416 1441
1417 if (texAsset != null) 1442 foreach(GridRegion r in regions)
1418 { 1443 {
1419 textures.Add(texAsset); 1444 if(r.TerrainImage == UUID.Zero)
1420 } 1445 continue;
1421 }
1422 1446
1423 foreach (AssetBase asset in textures) 1447 AssetBase texAsset = m_scene.AssetService.Get(r.TerrainImage.ToString());
1424 { 1448 if(texAsset == null)
1425 ManagedImage managedImage; 1449 continue;
1426 Image image;
1427 1450
1428 if (OpenJPEG.DecodeToImage(asset.Data, out managedImage, out image)) 1451 if(OpenJPEG.DecodeToImage(texAsset.Data, out managedImage, out image))
1429 bitImages.Add(image); 1452 {
1430 } 1453 int x = (int)((r.RegionLocX - startX) * scaleX);
1454 int y = (int)((r.RegionLocY - startY ) * scaleY);
1455 int sx = (int)(r.RegionSizeX * scaleX);
1456 int sy = (int)(r.RegionSizeY * scaleY);
1457 g.DrawImage(image, x, TEXTURESIZE - y - sy, sx, sy); // y origin is top
1458 if(r.RegionHandle == m_scene.RegionInfo.RegionHandle)
1459 {
1460 SizeF stringSize = g.MeasureString(r.RegionName, drawFont);
1461 g.DrawString(r.RegionName, drawFont, drawBrush, x + 30, TEXTURESIZE - y - 30 - stringSize.Height);
1462 }
1463 }
1464 }
1431 1465
1432 Bitmap mapTexture = new Bitmap(2560, 2560); 1466 if(image != null)
1433 Graphics g = Graphics.FromImage(mapTexture); 1467 image.Dispose();
1434 SolidBrush sea = new SolidBrush(Color.DarkBlue);
1435 g.FillRectangle(sea, 0, 0, 2560, 2560);
1436 1468
1437 for (int i = 0; i < mapBlocks.Count; i++) 1469 String drawString = string.Format("{0}m x {1}m", spanX, spanY);
1438 { 1470 g.DrawString(drawString, drawFont, drawBrush, 30, 30);
1439 ushort x = (ushort)((mapBlocks[i].X - m_scene.RegionInfo.RegionLocX) + 10); 1471
1440 ushort y = (ushort)((mapBlocks[i].Y - m_scene.RegionInfo.RegionLocY) + 10); 1472 drawBrush.Dispose();
1441 g.DrawImage(bitImages[i], (x * 128), 2560 - (y * 128), 128, 128); // y origin is top 1473 drawFont.Dispose();
1442 } 1474 }
1443 1475
1444 mapTexture.Save(exportPath, ImageFormat.Jpeg); 1476 mapTexture.Save(exportPath, ImageFormat.Jpeg);