diff options
author | Adam Frisby | 2007-05-24 05:44:53 +0000 |
---|---|---|
committer | Adam Frisby | 2007-05-24 05:44:53 +0000 |
commit | 497af009bd1aa59385b2aca86987b619f8647616 (patch) | |
tree | 0454f4317f09113660238e6e2280ee93ba5adad7 /OpenSim.Terrain.BasicTerrain/TerrainEngine.cs | |
parent | * Simulators should no longer require all their neighbours to be online to ac... (diff) | |
download | opensim-SC-497af009bd1aa59385b2aca86987b619f8647616.zip opensim-SC-497af009bd1aa59385b2aca86987b619f8647616.tar.gz opensim-SC-497af009bd1aa59385b2aca86987b619f8647616.tar.bz2 opensim-SC-497af009bd1aa59385b2aca86987b619f8647616.tar.xz |
* Reduced effect of terraforming brushes by 1000%.
* Added new exportImage() function to BasicTerrain which will output a gradient-mapped image of the terrain which can be uploaded to the grid for things like world map images. (shiinnny), will update later with an improved version using the bilinear quad method employed in client terrain rendering.
* Rebuild project & build files for basicterrain with System.Drawing dependency. Prebuild updated.
Diffstat (limited to '')
-rw-r--r-- | OpenSim.Terrain.BasicTerrain/TerrainEngine.cs | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs b/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs index 38a4989..e766f71 100644 --- a/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs +++ b/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs | |||
@@ -1,6 +1,7 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
3 | using System.Text; | 3 | using System.Text; |
4 | using System.Drawing; | ||
4 | using libTerrain; | 5 | using libTerrain; |
5 | 6 | ||
6 | namespace OpenSim.Terrain | 7 | namespace OpenSim.Terrain |
@@ -403,5 +404,45 @@ namespace OpenSim.Terrain | |||
403 | heightmap.set(x,y,(double)value); | 404 | heightmap.set(x,y,(double)value); |
404 | } | 405 | } |
405 | } | 406 | } |
407 | |||
408 | /// <summary> | ||
409 | /// Exports the current heightmap to a PNG file | ||
410 | /// </summary> | ||
411 | /// <param name="filename">The destination filename for the image</param> | ||
412 | /// <param name="gradientmap">A 1x*height* image which contains the colour gradient to export with. Must be at least 1x2 pixels, 1x256 or more is ideal.</param> | ||
413 | public void exportImage(string filename, string gradientmap) | ||
414 | { | ||
415 | try | ||
416 | { | ||
417 | Bitmap gradientmapLd = new Bitmap(gradientmap); | ||
418 | |||
419 | int pallete = gradientmapLd.Width; | ||
420 | |||
421 | Bitmap bmp = new Bitmap(heightmap.w, heightmap.h); | ||
422 | Color[] colours = new Color[pallete]; | ||
423 | |||
424 | for (int i = 0; i < pallete; i++) | ||
425 | { | ||
426 | colours[i] = gradientmapLd.GetPixel(1, i); | ||
427 | } | ||
428 | |||
429 | Channel copy = heightmap.copy(); | ||
430 | for (int x = 0; x < copy.w; x++) | ||
431 | { | ||
432 | for (int y = 0; y < copy.h; y++) | ||
433 | { | ||
434 | // 512 is the largest possible height before colours clamp | ||
435 | int colorindex = (int)(Math.Max(Math.Min(1.0, copy.get(x, y) / 512.0), 0.0) * pallete); | ||
436 | bmp.SetPixel(x, y, colours[colorindex]); | ||
437 | } | ||
438 | } | ||
439 | |||
440 | bmp.Save(filename, System.Drawing.Imaging.ImageFormat.Png); | ||
441 | } | ||
442 | catch (Exception e) | ||
443 | { | ||
444 | Console.WriteLine("Failed generating terrain map: " + e.ToString()); | ||
445 | } | ||
446 | } | ||
406 | } | 447 | } |
407 | } | 448 | } |