mirror of
https://github.com/opensim/opensim.git
synced 2026-08-05 17:05:55 +08:00
* Added a new method to IMapImageGenerator for getting the map tile before it is JPEG2000 compressed
* Aesthetically improved map tile water * SimianGrid connector now uploads a PNG tile to the AddMapTile API
This commit is contained in:
@@ -70,10 +70,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
|
||||
|
||||
#region IMapImageGenerator Members
|
||||
|
||||
public byte[] WriteJpeg2000Image(string gradientmap)
|
||||
public Bitmap CreateMapTile(string gradientmap)
|
||||
{
|
||||
byte[] imageData = null;
|
||||
|
||||
bool drawPrimVolume = true;
|
||||
bool textureTerrain = false;
|
||||
|
||||
@@ -98,32 +96,36 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
|
||||
}
|
||||
terrainRenderer.Initialise(m_scene, m_config);
|
||||
|
||||
using (Bitmap mapbmp = new Bitmap((int)Constants.RegionSize, (int)Constants.RegionSize))
|
||||
Bitmap mapbmp = new Bitmap((int)Constants.RegionSize, (int)Constants.RegionSize, 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)
|
||||
{
|
||||
//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);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
imageData = OpenJPEG.EncodeFromImage(mapbmp, true);
|
||||
}
|
||||
catch (Exception e) // LEGIT: Catching problems caused by OpenJPEG p/invoke
|
||||
{
|
||||
m_log.Error("Failed generating terrain map: " + e);
|
||||
}
|
||||
DrawObjectVolume(m_scene, mapbmp);
|
||||
}
|
||||
|
||||
return imageData;
|
||||
return mapbmp;
|
||||
}
|
||||
|
||||
public byte[] WriteJpeg2000Image(string gradientmap)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (Bitmap mapbmp = CreateMapTile(gradientmap))
|
||||
return OpenJPEG.EncodeFromImage(mapbmp, true);
|
||||
}
|
||||
catch (Exception e) // LEGIT: Catching problems caused by OpenJPEG p/invoke
|
||||
{
|
||||
m_log.Error("Failed generating terrain map: " + e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -37,6 +37,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
|
||||
{
|
||||
public class ShadedMapTileRenderer : IMapTileTerrainRenderer
|
||||
{
|
||||
private static readonly Color WATER_COLOR = Color.FromArgb(29, 71, 95);
|
||||
|
||||
private static readonly ILog m_log =
|
||||
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
@@ -221,8 +223,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
|
||||
|
||||
try
|
||||
{
|
||||
Color water = Color.FromArgb((int)heightvalue, (int)heightvalue, 255);
|
||||
mapbmp.SetPixel(x, yr, water);
|
||||
mapbmp.SetPixel(x, yr, WATER_COLOR);
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
|
||||
@@ -136,6 +136,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
|
||||
private static readonly UUID defaultTerrainTexture4 = new UUID("53a2f406-4895-1d13-d541-d2e3b86bc19c");
|
||||
private static readonly Color defaultColor4 = Color.FromArgb(200, 200, 200);
|
||||
|
||||
private static readonly Color WATER_COLOR = Color.FromArgb(29, 71, 95);
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -406,8 +408,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
|
||||
|
||||
heightvalue = 100f - (heightvalue * 100f) / 19f; // 0 - 19 => 100 - 0
|
||||
|
||||
Color water = Color.FromArgb((int)heightvalue, (int)heightvalue, 255);
|
||||
mapbmp.SetPixel(x, yr, water);
|
||||
mapbmp.SetPixel(x, yr, WATER_COLOR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user