Allow Region specific static maptiles to be loaded from file.

0.8.0.3
Jak Daniels 2014-03-17 20:39:36 +00:00 committed by Robert Adams
parent cf97535d9e
commit 61353dde80
5 changed files with 95 additions and 22 deletions

View File

@ -143,6 +143,7 @@ namespace OpenSim.Framework
public string RemotingAddress; public string RemotingAddress;
public UUID ScopeID = UUID.Zero; public UUID ScopeID = UUID.Zero;
private UUID m_maptileStaticUUID = UUID.Zero; private UUID m_maptileStaticUUID = UUID.Zero;
public string m_maptileStaticFile;
public uint WorldLocX = 0; public uint WorldLocX = 0;
public uint WorldLocY = 0; public uint WorldLocY = 0;
@ -349,6 +350,11 @@ namespace OpenSim.Framework
{ {
get { return m_maptileStaticUUID; } get { return m_maptileStaticUUID; }
} }
public string MaptileStaticFile
{
get { return m_maptileStaticFile; }
}
/// <summary> /// <summary>
/// The port by which http communication occurs with the region (most noticeably, CAPS communication) /// The port by which http communication occurs with the region (most noticeably, CAPS communication)
@ -716,6 +722,9 @@ namespace OpenSim.Framework
{ {
config.Set("MaptileStaticUUID", m_maptileStaticUUID.ToString()); config.Set("MaptileStaticUUID", m_maptileStaticUUID.ToString());
} }
m_maptileStaticFile = config.GetString("MaptileStaticFile", String.Empty);
allKeys.Remove("MaptileStaticFile");
#endregion #endregion
@ -843,6 +852,9 @@ namespace OpenSim.Framework
if (m_maptileStaticUUID != UUID.Zero) if (m_maptileStaticUUID != UUID.Zero)
config.Set("MaptileStaticUUID", m_maptileStaticUUID.ToString()); config.Set("MaptileStaticUUID", m_maptileStaticUUID.ToString());
if (m_maptileStaticFile != String.Empty)
config.Set("MaptileStaticFile", m_maptileStaticFile);
} }
public bool ignoreIncomingConfiguration(string configuration_key, object configuration_result) public bool ignoreIncomingConfiguration(string configuration_key, object configuration_result)
@ -952,6 +964,9 @@ namespace OpenSim.Framework
configMember.addConfigurationOption("region_static_maptile", ConfigurationOption.ConfigurationTypes.TYPE_UUID, configMember.addConfigurationOption("region_static_maptile", ConfigurationOption.ConfigurationTypes.TYPE_UUID,
"UUID of a texture to use as the map for this region", m_maptileStaticUUID.ToString(), true); "UUID of a texture to use as the map for this region", m_maptileStaticUUID.ToString(), true);
configMember.addConfigurationOption("region_static_mapfile", ConfigurationOption.ConfigurationTypes.TYPE_STRING,
"Filename of a texture to use as the map for this region", m_maptileStaticFile, true);
} }
public void loadConfigurationOptions() public void loadConfigurationOptions()
@ -1016,6 +1031,9 @@ namespace OpenSim.Framework
configMember.addConfigurationOption("region_static_maptile", ConfigurationOption.ConfigurationTypes.TYPE_UUID, configMember.addConfigurationOption("region_static_maptile", ConfigurationOption.ConfigurationTypes.TYPE_UUID,
"UUID of a texture to use as the map for this region", String.Empty, true); "UUID of a texture to use as the map for this region", String.Empty, true);
configMember.addConfigurationOption("region_static_mapfile", ConfigurationOption.ConfigurationTypes.TYPE_STRING,
"Filename of a texture to use as the map for this region", String.Empty, true);
} }
public bool handleIncomingConfiguration(string configuration_key, object configuration_result) public bool handleIncomingConfiguration(string configuration_key, object configuration_result)
@ -1097,6 +1115,9 @@ namespace OpenSim.Framework
case "region_static_maptile": case "region_static_maptile":
m_maptileStaticUUID = (UUID)configuration_result; m_maptileStaticUUID = (UUID)configuration_result;
break; break;
case "region_static_mapfile":
m_maptileStaticFile = (string)configuration_result;
break;
} }
return true; return true;

View File

@ -91,29 +91,46 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
if (generateMaptiles) if (generateMaptiles)
{ {
if (textureTerrain) if (String.IsNullOrEmpty(m_scene.RegionInfo.m_maptileStaticFile))
{ {
terrainRenderer = new TexturedMapTileRenderer(); if (textureTerrain)
{
terrainRenderer = new TexturedMapTileRenderer();
}
else
{
terrainRenderer = new ShadedMapTileRenderer();
}
terrainRenderer.Initialise(m_scene, m_config);
mapbmp = new Bitmap((int)m_scene.Heightmap.Width, (int)m_scene.Heightmap.Height,
System.Drawing.Imaging.PixelFormat.Format24bppRgb);
//long t = System.Environment.TickCount;
//for (int i = 0; i < 10; ++i) {
terrainRenderer.TerrainToBitmap(mapbmp);
//}
//t = System.Environment.TickCount - t;
//m_log.InfoFormat("[MAPTILE] generation of 10 maptiles needed {0} ms", t);
if (drawPrimVolume)
{
DrawObjectVolume(m_scene, mapbmp);
}
} }
else else
{ {
terrainRenderer = new ShadedMapTileRenderer(); try
} {
mapbmp = new Bitmap("maptiles/" + m_scene.RegionInfo.m_maptileStaticFile);
terrainRenderer.Initialise(m_scene, m_config); }
catch (Exception e)
mapbmp = new Bitmap((int)m_scene.Heightmap.Width, (int)m_scene.Heightmap.Height, {
System.Drawing.Imaging.PixelFormat.Format24bppRgb); m_log.ErrorFormat("[MAPTILE]: Failed to load Static map image texture file: {0} for {1}", "maptiles/" + m_scene.RegionInfo.m_maptileStaticFile, m_scene.Name);
//long t = System.Environment.TickCount; //mapbmp = new Bitmap((int)m_scene.Heightmap.Width, (int)m_scene.Heightmap.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
//for (int i = 0; i < 10; ++i) { mapbmp = null;
terrainRenderer.TerrainToBitmap(mapbmp); }
//} if (mapbmp != null) m_log.DebugFormat("[MAPTILE]: Static map image texture file {0} found for {1}", "maptiles/" + m_scene.RegionInfo.m_maptileStaticFile, m_scene.Name);
//t = System.Environment.TickCount - t;
//m_log.InfoFormat("[MAPTILE] generation of 10 maptiles needed {0} ms", t);
if (drawPrimVolume)
{
DrawObjectVolume(m_scene, mapbmp);
} }
} }
else else

View File

@ -903,7 +903,8 @@ namespace OpenSim.Region.Framework.Scenes
if (m_generateMaptiles) if (m_generateMaptiles)
{ {
int maptileRefresh = startupConfig.GetInt("MaptileRefresh", 0); int maptileRefresh = Util.GetConfigVarFromSections<int>(config, "MaptileRefresh", possibleMapConfigSections, 0);
m_log.InfoFormat("[SCENE]: Region {0}, WORLD MAP refresh time set to {1} seconds", RegionInfo.RegionName, maptileRefresh);
if (maptileRefresh != 0) if (maptileRefresh != 0)
{ {
m_mapGenerationTimer.Interval = maptileRefresh * 1000; m_mapGenerationTimer.Interval = maptileRefresh * 1000;

View File

@ -297,6 +297,7 @@
;# {MaptileStaticUUID} {} {Asset ID for static map texture} {} 00000000-0000-0000-0000-000000000000 ;# {MaptileStaticUUID} {} {Asset ID for static map texture} {} 00000000-0000-0000-0000-000000000000
;; If not generating maptiles, use this static texture asset ID ;; If not generating maptiles, use this static texture asset ID
;; This may be overridden on a per region basis in Regions.ini
; MaptileStaticUUID = "00000000-0000-0000-0000-000000000000" ; MaptileStaticUUID = "00000000-0000-0000-0000-000000000000"
;# {TextureOnMapTile} {} {Use terrain textures for map tiles?} {true false} true ;# {TextureOnMapTile} {} {Use terrain textures for map tiles?} {true false} true

View File

@ -46,7 +46,40 @@ ExternalHostName = "SYSTEMIP"
; RegionType = "Mainland" ; RegionType = "Mainland"
; * Region Specific Static Maptiles:
; * Important: To use any kind of texture *assets* as a static maptile, the following
; * things must be set in the [Map] section of OpenSim.ini :
; * ; *
; * UUID of texture to use as a maptile for this region. ; * MapImageModule = "MapImageModule"
; * Only set if you have disabled dynamic generation of the map tile from the region contents. ; * GenerateMaptiles = false
; *
; * Now, there is a setting in [Map] in OpenSim.ini called
; *
; * MaptileStaticUUID = "00000000-0000-0000-0000-000000000000"
; *
; * where, given the criteria above, lets you specify the UUID of a texture asset to use
; * as a maptile *Simulator Wide*. Here, you can override that on a per region basis for
; * Simulators that run multiple regions:
; MaptileStaticUUID = "00000000-0000-0000-0000-000000000000" ; MaptileStaticUUID = "00000000-0000-0000-0000-000000000000"
; * Region Specific Static Maptiles from file:
; * It is also possible to create maptiles using external image files of the right size
; * and supported formats (bmp,tga,png,jpg in RGB 24bpp format)
; *
; * Important: To use any kind of texture *files* as a static maptile, the following
; * things must be set in the [Map] section of OpenSim.ini :
; *
; * MapImageModule = "MapImageModule"
; * GenerateMaptiles = true
; *
; * The image must be the same size in pixels as the region or varregion is in meters.
; * i.e. 256x256 pixels for single region of 256x256m, or 1280x1280 pixels for a varregion
; * of size 1280x1280m. The image is loaded from OpenSim's bin/maptiles/ directory.
; *
; * If this setting is used, then the base map is generated from this file instead of being
; * built using MapImageModule's terrain and prim renderer. Parcel 'for sale' overlays are
; * still drawn on top of the static map by the World Map module.
; MaptileStaticFile = "SomeFile.png"