* refactor: Move export map function to world map module from scene
parent
6600a7a9bc
commit
88b273bc71
|
@ -361,6 +361,7 @@ namespace OpenSim.Framework.Console
|
|||
fn(ci.module, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
return new string[0];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -225,10 +225,6 @@ namespace OpenSim
|
|||
"command-script <script>",
|
||||
"Run a command script from file", RunCommand);
|
||||
|
||||
m_console.Commands.AddCommand("region", false, "export-map",
|
||||
"export-map <file>",
|
||||
"Save an image of the world map", RunCommand);
|
||||
|
||||
m_console.Commands.AddCommand("region", false, "remove-region",
|
||||
"remove-region <name>",
|
||||
"Remove a region from this simulator", RunCommand);
|
||||
|
@ -609,17 +605,6 @@ namespace OpenSim
|
|||
m_sceneManager.RestartCurrentScene();
|
||||
break;
|
||||
|
||||
case "export-map":
|
||||
if (cmdparams.Length > 0)
|
||||
{
|
||||
m_sceneManager.CurrentOrFirstScene.ExportWorldMap(cmdparams[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_sceneManager.CurrentOrFirstScene.ExportWorldMap("exportmap.jpg");
|
||||
}
|
||||
break;
|
||||
|
||||
case "Add-InventoryHost":
|
||||
if (cmdparams.Length > 0)
|
||||
{
|
||||
|
|
|
@ -266,10 +266,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Callback for when the image has been decoded
|
||||
/// </summary>
|
||||
|
@ -281,7 +279,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
if (m_shuttingdown)
|
||||
return;
|
||||
|
||||
|
||||
lock (PQHandles)
|
||||
{
|
||||
// Update our asset data
|
||||
|
@ -299,7 +296,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// This image has had a good life. It's now expired. Remove it off the queue
|
||||
/// </summary>
|
||||
|
@ -531,7 +527,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
DiscardLevel = 0;
|
||||
StopPacket = TexturePacketCount() - 1;
|
||||
CurrentPacket = Util.Clamp<int>(packet, 1, TexturePacketCount() - 1);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -562,7 +557,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
}
|
||||
else
|
||||
{
|
||||
|
||||
// Send first packet
|
||||
byte[] firstImageData = new byte[FIRST_IMAGE_PACKET_SIZE];
|
||||
try { Buffer.BlockCopy(m_asset_ref.Data, 0, firstImageData, 0, FIRST_IMAGE_PACKET_SIZE); }
|
||||
|
|
|
@ -121,6 +121,7 @@ namespace OpenSim.Region.CoreModules.World.Land
|
|||
client.OnParcelReclaim += new ParcelReclaim(handleParcelReclaim);
|
||||
client.OnParcelInfoRequest += new ParcelInfoRequest(handleParcelInfo);
|
||||
client.OnParcelDwellRequest += new ParcelDwellRequest(handleParcelDwell);
|
||||
|
||||
if (m_scene.Entities.ContainsKey(client.AgentId))
|
||||
{
|
||||
SendLandUpdate((ScenePresence)m_scene.Entities[client.AgentId], true);
|
||||
|
|
|
@ -54,6 +54,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
|
|||
{
|
||||
private static readonly ILog m_log =
|
||||
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private static readonly string DEFAULT_WORLD_MAP_EXPORT_PATH = "exportmap.jpg";
|
||||
|
||||
private static readonly string m_mapLayerPath = "0001/";
|
||||
|
||||
|
@ -80,14 +82,18 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
|
|||
public virtual void Initialise(Scene scene, IConfigSource config)
|
||||
{
|
||||
IConfig startupConfig = config.Configs["Startup"];
|
||||
if (startupConfig.GetString("WorldMapModule", "WorldMap") ==
|
||||
"WorldMap")
|
||||
if (startupConfig.GetString("WorldMapModule", "WorldMap") == "WorldMap")
|
||||
m_Enabled = true;
|
||||
|
||||
if (!m_Enabled)
|
||||
return;
|
||||
|
||||
m_scene = scene;
|
||||
|
||||
m_scene.AddCommand(
|
||||
this, "export-map",
|
||||
"export-map [<path>]",
|
||||
"Save an image of the world map", HandleExportWorldMapConsoleCommand);
|
||||
}
|
||||
|
||||
public virtual void PostInitialise()
|
||||
|
@ -788,6 +794,89 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Export the world map
|
||||
/// </summary>
|
||||
/// <param name="fileName"></param>
|
||||
public void HandleExportWorldMapConsoleCommand(string module, string[] cmdparams)
|
||||
{
|
||||
if (m_scene.ConsoleScene() == null)
|
||||
{
|
||||
// FIXME: If console region is root then this will be printed by every module. Currently, there is no
|
||||
// way to prevent this, short of making the entire module shared (which is complete overkill).
|
||||
// One possibility is to return a bool to signal whether the module has completely handled the command
|
||||
m_log.InfoFormat("[WORLD MAP]: Please change to a specific region in order to export its world map");
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_scene.ConsoleScene() != m_scene)
|
||||
return;
|
||||
|
||||
string exportPath;
|
||||
|
||||
if (cmdparams.Length > 1)
|
||||
exportPath = cmdparams[1];
|
||||
else
|
||||
exportPath = DEFAULT_WORLD_MAP_EXPORT_PATH;
|
||||
|
||||
m_log.InfoFormat(
|
||||
"[WORLD MAP]: Exporting world map for {0} to {1}", m_scene.RegionInfo.RegionName, exportPath);
|
||||
|
||||
List<MapBlockData> mapBlocks =
|
||||
m_scene.CommsManager.GridService.RequestNeighbourMapBlocks(
|
||||
(int)(m_scene.RegionInfo.RegionLocX - 9),
|
||||
(int)(m_scene.RegionInfo.RegionLocY - 9),
|
||||
(int)(m_scene.RegionInfo.RegionLocX + 9),
|
||||
(int)(m_scene.RegionInfo.RegionLocY + 9));
|
||||
List<AssetBase> textures = new List<AssetBase>();
|
||||
List<Image> bitImages = new List<Image>();
|
||||
|
||||
foreach (MapBlockData mapBlock in mapBlocks)
|
||||
{
|
||||
AssetBase texAsset = m_scene.CommsManager.AssetCache.GetAsset(mapBlock.MapImageId, true);
|
||||
|
||||
if (texAsset != null)
|
||||
{
|
||||
textures.Add(texAsset);
|
||||
}
|
||||
else
|
||||
{
|
||||
texAsset = m_scene.CommsManager.AssetCache.GetAsset(mapBlock.MapImageId, true);
|
||||
if (texAsset != null)
|
||||
{
|
||||
textures.Add(texAsset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (AssetBase asset in textures)
|
||||
{
|
||||
ManagedImage managedImage;
|
||||
Image image;
|
||||
|
||||
if (OpenJPEG.DecodeToImage(asset.Data, out managedImage, out image))
|
||||
bitImages.Add(image);
|
||||
}
|
||||
|
||||
Bitmap mapTexture = new Bitmap(2560, 2560);
|
||||
Graphics g = Graphics.FromImage(mapTexture);
|
||||
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), (y * 128), 128, 128);
|
||||
}
|
||||
|
||||
mapTexture.Save(exportPath, ImageFormat.Jpeg);
|
||||
|
||||
m_log.InfoFormat(
|
||||
"[WORLD MAP]: Successfully exported world map for {0} to {1}",
|
||||
m_scene.RegionInfo.RegionName, exportPath);
|
||||
}
|
||||
|
||||
public OSD HandleRemoteMapItemRequest(string path, OSD request, string endpoint)
|
||||
{
|
||||
|
|
|
@ -851,15 +851,14 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
UpdateEvents();
|
||||
|
||||
if (m_frame % m_update_backup == 0)
|
||||
{
|
||||
UpdateStorageBackup();
|
||||
}
|
||||
|
||||
if (m_frame % m_update_terrain == 0)
|
||||
UpdateTerrain();
|
||||
|
||||
if (m_frame % m_update_land == 0)
|
||||
UpdateLand();
|
||||
|
||||
otherMS = Environment.TickCount - otherMS;
|
||||
// if (m_frame%m_update_avatars == 0)
|
||||
// UpdateInWorldTime();
|
||||
|
@ -1052,57 +1051,6 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
|
||||
#region Load Terrain
|
||||
|
||||
public void ExportWorldMap(string fileName)
|
||||
{
|
||||
List<MapBlockData> mapBlocks =
|
||||
m_sceneGridService.RequestNeighbourMapBlocks((int)(RegionInfo.RegionLocX - 9),
|
||||
(int)(RegionInfo.RegionLocY - 9),
|
||||
(int)(RegionInfo.RegionLocX + 9),
|
||||
(int)(RegionInfo.RegionLocY + 9));
|
||||
List<AssetBase> textures = new List<AssetBase>();
|
||||
List<Image> bitImages = new List<Image>();
|
||||
|
||||
foreach (MapBlockData mapBlock in mapBlocks)
|
||||
{
|
||||
AssetBase texAsset = AssetCache.GetAsset(mapBlock.MapImageId, true);
|
||||
|
||||
if (texAsset != null)
|
||||
{
|
||||
textures.Add(texAsset);
|
||||
}
|
||||
else
|
||||
{
|
||||
texAsset = AssetCache.GetAsset(mapBlock.MapImageId, true);
|
||||
if (texAsset != null)
|
||||
{
|
||||
textures.Add(texAsset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (AssetBase asset in textures)
|
||||
{
|
||||
ManagedImage managedImage;
|
||||
Image image;
|
||||
|
||||
if (OpenJPEG.DecodeToImage(asset.Data, out managedImage, out image))
|
||||
bitImages.Add(image);
|
||||
}
|
||||
|
||||
Bitmap mapTexture = new Bitmap(2560, 2560);
|
||||
Graphics g = Graphics.FromImage(mapTexture);
|
||||
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 - RegionInfo.RegionLocX) + 10);
|
||||
ushort y = (ushort)((mapBlocks[i].Y - RegionInfo.RegionLocY) + 10);
|
||||
g.DrawImage(bitImages[i], (x * 128), (y * 128), 128, 128);
|
||||
}
|
||||
mapTexture.Save(fileName, ImageFormat.Jpeg);
|
||||
}
|
||||
|
||||
public void SaveTerrain()
|
||||
{
|
||||
m_storageManager.DataStore.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID);
|
||||
|
|
Loading…
Reference in New Issue