aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim.Terrain.BasicTerrain
diff options
context:
space:
mode:
authorAdam Frisby2007-05-24 05:44:53 +0000
committerAdam Frisby2007-05-24 05:44:53 +0000
commit497af009bd1aa59385b2aca86987b619f8647616 (patch)
tree0454f4317f09113660238e6e2280ee93ba5adad7 /OpenSim.Terrain.BasicTerrain
parent* Simulators should no longer require all their neighbours to be online to ac... (diff)
downloadopensim-SC_OLD-497af009bd1aa59385b2aca86987b619f8647616.zip
opensim-SC_OLD-497af009bd1aa59385b2aca86987b619f8647616.tar.gz
opensim-SC_OLD-497af009bd1aa59385b2aca86987b619f8647616.tar.bz2
opensim-SC_OLD-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/OpenSim.Terrain.BasicTerrain.csproj4
-rw-r--r--OpenSim.Terrain.BasicTerrain/OpenSim.Terrain.BasicTerrain.dll.build1
-rw-r--r--OpenSim.Terrain.BasicTerrain/TerrainEngine.cs41
3 files changed, 46 insertions, 0 deletions
diff --git a/OpenSim.Terrain.BasicTerrain/OpenSim.Terrain.BasicTerrain.csproj b/OpenSim.Terrain.BasicTerrain/OpenSim.Terrain.BasicTerrain.csproj
index 1cdfaf6..5a73897 100644
--- a/OpenSim.Terrain.BasicTerrain/OpenSim.Terrain.BasicTerrain.csproj
+++ b/OpenSim.Terrain.BasicTerrain/OpenSim.Terrain.BasicTerrain.csproj
@@ -66,6 +66,10 @@
66 <HintPath>System.dll</HintPath> 66 <HintPath>System.dll</HintPath>
67 <Private>False</Private> 67 <Private>False</Private>
68 </Reference> 68 </Reference>
69 <Reference Include="System.Drawing" >
70 <HintPath>System.Drawing.dll</HintPath>
71 <Private>False</Private>
72 </Reference>
69 <Reference Include="System.Data" > 73 <Reference Include="System.Data" >
70 <HintPath>System.Data.dll</HintPath> 74 <HintPath>System.Data.dll</HintPath>
71 <Private>False</Private> 75 <Private>False</Private>
diff --git a/OpenSim.Terrain.BasicTerrain/OpenSim.Terrain.BasicTerrain.dll.build b/OpenSim.Terrain.BasicTerrain/OpenSim.Terrain.BasicTerrain.dll.build
index d2e6c9f..86c6a5c 100644
--- a/OpenSim.Terrain.BasicTerrain/OpenSim.Terrain.BasicTerrain.dll.build
+++ b/OpenSim.Terrain.BasicTerrain/OpenSim.Terrain.BasicTerrain.dll.build
@@ -21,6 +21,7 @@
21 </lib> 21 </lib>
22 <include name="../bin/libTerrain-BSD.dll" /> 22 <include name="../bin/libTerrain-BSD.dll" />
23 <include name="System.dll" /> 23 <include name="System.dll" />
24 <include name="System.Drawing.dll" />
24 <include name="System.Data.dll" /> 25 <include name="System.Data.dll" />
25 <include name="System.Xml.dll" /> 26 <include name="System.Xml.dll" />
26 </references> 27 </references>
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 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.Text; 3using System.Text;
4using System.Drawing;
4using libTerrain; 5using libTerrain;
5 6
6namespace OpenSim.Terrain 7namespace 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}