aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/Terrain
diff options
context:
space:
mode:
authorMW2008-03-29 17:18:47 +0000
committerMW2008-03-29 17:18:47 +0000
commit7fcffa3a3a231a77d00bf2ec1772f0914073d28f (patch)
treeb5fa20f2a997edff3150f6643b7a123751e614f4 /OpenSim/Region/Environment/Modules/Terrain
parentFix compiler warnings in BulletXPlugin. (diff)
downloadopensim-SC-7fcffa3a3a231a77d00bf2ec1772f0914073d28f.zip
opensim-SC-7fcffa3a3a231a77d00bf2ec1772f0914073d28f.tar.gz
opensim-SC-7fcffa3a3a231a77d00bf2ec1772f0914073d28f.tar.bz2
opensim-SC-7fcffa3a3a231a77d00bf2ec1772f0914073d28f.tar.xz
Re-enabled terrain texture generation for the world map. Adam can clean up/ sort it out when he gets time.
Most likely doesn't really work in grid mode as the generated textures are marked as temporary and I don't think they are updated to the asset server. We have to either live with these textures being sent to the asset server, and manually clean them out from time to time or wait until there is some asset management system in place. Also currently the texture is only generated at region startup, it is not updated after terraforming.
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Terrain')
-rw-r--r--OpenSim/Region/Environment/Modules/Terrain/TerrainChannel.cs8
-rw-r--r--OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs50
2 files changed, 57 insertions, 1 deletions
diff --git a/OpenSim/Region/Environment/Modules/Terrain/TerrainChannel.cs b/OpenSim/Region/Environment/Modules/Terrain/TerrainChannel.cs
index 4ab7782..74af2c1 100644
--- a/OpenSim/Region/Environment/Modules/Terrain/TerrainChannel.cs
+++ b/OpenSim/Region/Environment/Modules/Terrain/TerrainChannel.cs
@@ -56,6 +56,14 @@ namespace OpenSim.Region.Environment.Modules.Terrain
56 return copy; 56 return copy;
57 } 57 }
58 58
59 public ITerrainChannel MakeCopy()
60 {
61 TerrainChannel copy = new TerrainChannel(false);
62 copy.map = (double[,])this.map.Clone();
63
64 return copy;
65 }
66
59 public float[] GetFloatsSerialised() 67 public float[] GetFloatsSerialised()
60 { 68 {
61 float[] heights = new float[Width * Height]; 69 float[] heights = new float[Width * Height];
diff --git a/OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs b/OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs
index cdcc648..742ea5b 100644
--- a/OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs
+++ b/OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs
@@ -27,15 +27,17 @@
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Drawing;
30using libsecondlife; 31using libsecondlife;
31using Nini.Config; 32using Nini.Config;
32using OpenSim.Framework; 33using OpenSim.Framework;
33using OpenSim.Region.Environment.Interfaces; 34using OpenSim.Region.Environment.Interfaces;
34using OpenSim.Region.Environment.Scenes; 35using OpenSim.Region.Environment.Scenes;
35 36
37
36namespace OpenSim.Region.Environment.Modules.Terrain 38namespace OpenSim.Region.Environment.Modules.Terrain
37{ 39{
38 public class TerrainModule : IRegionModule 40 public class TerrainModule : IRegionModule , ITerrainTemp
39 { 41 {
40 public enum StandardTerrainEffects : byte 42 public enum StandardTerrainEffects : byte
41 { 43 {
@@ -139,6 +141,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain
139 public void Initialise(Scene scene, IConfigSource config) 141 public void Initialise(Scene scene, IConfigSource config)
140 { 142 {
141 m_scene = scene; 143 m_scene = scene;
144 m_scene.RegisterModuleInterface<ITerrainTemp>(this);
142 m_gConfig = config; 145 m_gConfig = config;
143 146
144 // Install terrain module in the simulator 147 // Install terrain module in the simulator
@@ -312,6 +315,51 @@ namespace OpenSim.Region.Environment.Modules.Terrain
312 } 315 }
313 } 316 }
314 317
318 public byte[] WriteJpegImage(string gradientmap)
319 {
320 byte[] imageData = null;
321 try
322 {
323 Bitmap bmp = TerrainToBitmap(gradientmap);
324
325 imageData = OpenJPEGNet.OpenJPEG.EncodeFromImage(bmp, true);
326
327 }
328 catch (Exception e) // LEGIT: Catching problems caused by OpenJPEG p/invoke
329 {
330 Console.WriteLine("Failed generating terrain map: " + e.ToString());
331 }
332
333 return imageData;
334 }
335
336 private Bitmap TerrainToBitmap(string gradientmap)
337 {
338 Bitmap gradientmapLd = new Bitmap(gradientmap);
339
340 int pallete = gradientmapLd.Height;
341
342 Bitmap bmp = new Bitmap(m_channel.Width, m_channel.Height);
343 Color[] colours = new Color[pallete];
344
345 for (int i = 0; i < pallete; i++)
346 {
347 colours[i] = gradientmapLd.GetPixel(0, i);
348 }
349
350 TerrainChannel copy =(TerrainChannel) m_channel.MakeCopy();
351 for (int y = 0; y < copy.Height; y++)
352 {
353 for (int x = 0; x < copy.Width; x++)
354 {
355 // 512 is the largest possible height before colours clamp
356 int colorindex = (int)(Math.Max(Math.Min(1.0, copy[x, y] / 512.0), 0.0) * (pallete - 1));
357 bmp.SetPixel(x, copy.Height - y - 1, colours[colorindex]);
358 }
359 }
360 return bmp;
361 }
362
315 public void PostInitialise() 363 public void PostInitialise()
316 { 364 {
317 InstallDefaultEffects(); 365 InstallDefaultEffects();