* Quick patch before I start on a bigger project
* Renamed ITerrainTemp to IMapImageGenerator * Renamed WriteJpegImage to WriteJpeg2000Image to better reflect it's function.0.6.0-stable
parent
b7ae8701ce
commit
0b4a8191a1
|
@ -71,8 +71,8 @@ namespace OpenSim.Region.Environment.Interfaces
|
||||||
byte[] ExportJpegImage(string gradientmap);
|
byte[] ExportJpegImage(string gradientmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface ITerrainTemp
|
public interface IMapImageGenerator
|
||||||
{
|
{
|
||||||
byte[] WriteJpegImage(string gradientmap);
|
byte[] WriteJpeg2000Image(string gradientmap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ using OpenSim.Region.Environment.Modules.ModuleFramework;
|
||||||
|
|
||||||
namespace OpenSim.Region.Environment.Modules.Terrain
|
namespace OpenSim.Region.Environment.Modules.Terrain
|
||||||
{
|
{
|
||||||
class MapImageModule : ITerrainTemp, IRegionModule
|
class MapImageModule : IMapImageGenerator, IRegionModule
|
||||||
{
|
{
|
||||||
private Scene m_scene;
|
private Scene m_scene;
|
||||||
#region IRegionModule Members
|
#region IRegionModule Members
|
||||||
|
@ -18,7 +18,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain
|
||||||
public void Initialise(Scene scene, IConfigSource source)
|
public void Initialise(Scene scene, IConfigSource source)
|
||||||
{
|
{
|
||||||
m_scene = scene;
|
m_scene = scene;
|
||||||
m_scene.RegisterModuleInterface<ITerrainTemp>(this);
|
m_scene.RegisterModuleInterface<IMapImageGenerator>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PostInitialise()
|
public void PostInitialise()
|
||||||
|
@ -40,15 +40,15 @@ namespace OpenSim.Region.Environment.Modules.Terrain
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public byte[] WriteJpegImage(string gradientmap)
|
public byte[] WriteJpeg2000Image(string gradientmap)
|
||||||
{
|
{
|
||||||
byte[] imageData = null;
|
byte[] imageData = null;
|
||||||
try
|
|
||||||
{
|
|
||||||
Bitmap bmp = TerrainToBitmap(gradientmap);
|
Bitmap bmp = TerrainToBitmap(gradientmap);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
imageData = OpenJPEGNet.OpenJPEG.EncodeFromImage(bmp, true);
|
imageData = OpenJPEGNet.OpenJPEG.EncodeFromImage(bmp, true);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception e) // LEGIT: Catching problems caused by OpenJPEG p/invoke
|
catch (Exception e) // LEGIT: Catching problems caused by OpenJPEG p/invoke
|
||||||
{
|
{
|
||||||
|
@ -122,6 +122,11 @@ namespace OpenSim.Region.Environment.Modules.Terrain
|
||||||
{
|
{
|
||||||
// 512 is the largest possible height before colours clamp
|
// 512 is the largest possible height before colours clamp
|
||||||
int colorindex = (int)(Math.Max(Math.Min(1.0, copy[x, y] / 512.0), 0.0) * (pallete - 1));
|
int colorindex = (int)(Math.Max(Math.Min(1.0, copy[x, y] / 512.0), 0.0) * (pallete - 1));
|
||||||
|
|
||||||
|
// Handle error conditions
|
||||||
|
if (colorindex > pallete - 1 || colorindex < 0)
|
||||||
|
bmp.SetPixel(x, copy.Height - y - 1, Color.Red);
|
||||||
|
else
|
||||||
bmp.SetPixel(x, copy.Height - y - 1, colours[colorindex]);
|
bmp.SetPixel(x, copy.Height - y - 1, colours[colorindex]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -984,12 +984,14 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void CreateTerrainTexture(bool temporary)
|
public void CreateTerrainTexture(bool temporary)
|
||||||
{
|
{
|
||||||
//TODOADAM: Move this to TerrainModule
|
|
||||||
|
|
||||||
//create a texture asset of the terrain
|
//create a texture asset of the terrain
|
||||||
ITerrainTemp terrain = RequestModuleInterface<ITerrainTemp>();
|
IMapImageGenerator terrain = RequestModuleInterface<IMapImageGenerator>();
|
||||||
|
|
||||||
if (Heightmap != null)
|
// Cannot create a map for a nonexistant heightmap yet.
|
||||||
|
if (Heightmap == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (terrain == null)
|
||||||
{
|
{
|
||||||
Bitmap mapbmp = new Bitmap(256, 256);
|
Bitmap mapbmp = new Bitmap(256, 256);
|
||||||
double[,] hm = Heightmap.GetDoubles();
|
double[,] hm = Heightmap.GetDoubles();
|
||||||
|
@ -1110,10 +1112,9 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
AssetCache.AddAsset(asset);
|
AssetCache.AddAsset(asset);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if (terrain != null)
|
|
||||||
{
|
{
|
||||||
byte[] data = terrain.WriteJpegImage("defaultstripe.png");
|
byte[] data = terrain.WriteJpeg2000Image("defaultstripe.png");
|
||||||
if (data != null)
|
if (data != null)
|
||||||
{
|
{
|
||||||
m_regInfo.EstateSettings.terrainImageID = LLUUID.Random();
|
m_regInfo.EstateSettings.terrainImageID = LLUUID.Random();
|
||||||
|
|
Loading…
Reference in New Issue