diff options
author | Adam Frisby | 2008-03-03 08:35:59 +0000 |
---|---|---|
committer | Adam Frisby | 2008-03-03 08:35:59 +0000 |
commit | c5d1f87cd202663f2f26ca90a973d9763070dda3 (patch) | |
tree | b1941867d13d1d3b29b46483e6b58cba536c72ca /OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs | |
parent | * Applying Ahzz's profile patch. Thanks Ahzz! (diff) | |
download | opensim-SC-c5d1f87cd202663f2f26ca90a973d9763070dda3.zip opensim-SC-c5d1f87cd202663f2f26ca90a973d9763070dda3.tar.gz opensim-SC-c5d1f87cd202663f2f26ca90a973d9763070dda3.tar.bz2 opensim-SC-c5d1f87cd202663f2f26ca90a973d9763070dda3.tar.xz |
* Removed and sorted using clauses in a number of files.
* Cleaned up ITerrainChannel
* Implemented Raise, Lower, Smooth, Flatten, Noise Terrain Paint Brushes
* Implemented Raise, Lower, Smooth, Flatten, Noise Terrain Fill Brushes
* Implemented Export functionality for RAW32 terrain loader
* Implemented Import/Export for SLRAW terrain loader
* Implemented Export for JPEG terrain loader
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs | 79 |
1 files changed, 64 insertions, 15 deletions
diff --git a/OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs b/OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs index 22b5fd9..1542230 100644 --- a/OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs +++ b/OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs | |||
@@ -26,16 +26,13 @@ | |||
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | 28 | ||
29 | using Nini.Config; | ||
30 | using System; | 29 | using System; |
31 | using System.Collections; | ||
32 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using libsecondlife; | ||
32 | using Nini.Config; | ||
33 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
34 | using OpenSim.Framework.Console; | ||
35 | using OpenSim.Region.Environment.Modules; | ||
36 | using OpenSim.Region.Environment.Interfaces; | 34 | using OpenSim.Region.Environment.Interfaces; |
37 | using OpenSim.Region.Environment.Scenes; | 35 | using OpenSim.Region.Environment.Scenes; |
38 | using libsecondlife; | ||
39 | 36 | ||
40 | namespace OpenSim.Region.Environment.Modules.Terrain | 37 | namespace OpenSim.Region.Environment.Modules.Terrain |
41 | { | 38 | { |
@@ -57,7 +54,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain | |||
57 | public interface ITerrainLoader | 54 | public interface ITerrainLoader |
58 | { | 55 | { |
59 | ITerrainChannel LoadFile(string filename); | 56 | ITerrainChannel LoadFile(string filename); |
60 | void SaveFile(string filename); | 57 | void SaveFile(string filename, ITerrainChannel map); |
61 | } | 58 | } |
62 | 59 | ||
63 | /// <summary> | 60 | /// <summary> |
@@ -85,6 +82,19 @@ namespace OpenSim.Region.Environment.Modules.Terrain | |||
85 | return copy; | 82 | return copy; |
86 | } | 83 | } |
87 | 84 | ||
85 | public float[] GetFloatsSerialised() | ||
86 | { | ||
87 | float[] heights = new float[Width * Height]; | ||
88 | int i; | ||
89 | |||
90 | for (i = 0; i < Width * Height; i++) | ||
91 | { | ||
92 | heights[i] = (float)map[i % Width, i / Width]; | ||
93 | } | ||
94 | |||
95 | return heights; | ||
96 | } | ||
97 | |||
88 | public double this[int x, int y] | 98 | public double this[int x, int y] |
89 | { | 99 | { |
90 | get | 100 | get |
@@ -102,6 +112,11 @@ namespace OpenSim.Region.Environment.Modules.Terrain | |||
102 | map = new double[Constants.RegionSize, Constants.RegionSize]; | 112 | map = new double[Constants.RegionSize, Constants.RegionSize]; |
103 | } | 113 | } |
104 | 114 | ||
115 | public TerrainChannel(double[,] import) | ||
116 | { | ||
117 | map = import; | ||
118 | } | ||
119 | |||
105 | public TerrainChannel(bool createMap) | 120 | public TerrainChannel(bool createMap) |
106 | { | 121 | { |
107 | if (createMap) | 122 | if (createMap) |
@@ -139,13 +154,27 @@ namespace OpenSim.Region.Environment.Modules.Terrain | |||
139 | 154 | ||
140 | private void InstallDefaultEffects() | 155 | private void InstallDefaultEffects() |
141 | { | 156 | { |
142 | m_painteffects[StandardTerrainEffects.Raise] = new PaintBrushes.RaiseSphere(); | 157 | // Draggable Paint Brush Effects |
143 | m_floodeffects[StandardTerrainEffects.Raise] = new FloodBrushes.RaiseArea(); | 158 | m_painteffects[StandardTerrainEffects.Raise] = new PaintBrushes.RaiseSphere(); |
144 | 159 | m_painteffects[StandardTerrainEffects.Lower] = new PaintBrushes.LowerSphere(); | |
145 | // Float[256,256] array format (RAW32) | 160 | m_painteffects[StandardTerrainEffects.Smooth] = new PaintBrushes.SmoothSphere(); |
161 | m_painteffects[StandardTerrainEffects.Noise] = new PaintBrushes.NoiseSphere(); | ||
162 | m_painteffects[StandardTerrainEffects.Flatten] = new PaintBrushes.FlattenSphere(); | ||
163 | |||
164 | // Area of effect selection effects | ||
165 | m_floodeffects[StandardTerrainEffects.Raise] = new FloodBrushes.RaiseArea(); | ||
166 | m_floodeffects[StandardTerrainEffects.Lower] = new FloodBrushes.LowerArea(); | ||
167 | m_floodeffects[StandardTerrainEffects.Smooth] = new FloodBrushes.SmoothArea(); | ||
168 | m_floodeffects[StandardTerrainEffects.Noise] = new FloodBrushes.NoiseArea(); | ||
169 | m_floodeffects[StandardTerrainEffects.Flatten] = new FloodBrushes.FlattenArea(); | ||
170 | |||
171 | // Filesystem load/save loaders | ||
146 | m_loaders[".r32"] = new FileLoaders.RAW32(); | 172 | m_loaders[".r32"] = new FileLoaders.RAW32(); |
147 | m_loaders[".f32"] = m_loaders[".r32"]; | 173 | m_loaders[".f32"] = m_loaders[".r32"]; |
148 | m_loaders[".ter"] = new FileLoaders.Terragen(); | 174 | m_loaders[".ter"] = new FileLoaders.Terragen(); |
175 | m_loaders[".raw"] = new FileLoaders.LLRAW(); | ||
176 | m_loaders[".jpg"] = new FileLoaders.JPEG(); | ||
177 | m_loaders[".jpeg"] = m_loaders[".jpg"]; | ||
149 | } | 178 | } |
150 | 179 | ||
151 | public void LoadFromFile(string filename) | 180 | public void LoadFromFile(string filename) |
@@ -162,14 +191,21 @@ namespace OpenSim.Region.Environment.Modules.Terrain | |||
162 | 191 | ||
163 | public void SaveToFile(string filename) | 192 | public void SaveToFile(string filename) |
164 | { | 193 | { |
165 | foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders) | 194 | try |
166 | { | 195 | { |
167 | if (filename.EndsWith(loader.Key)) | 196 | foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders) |
168 | { | 197 | { |
169 | loader.Value.SaveFile(filename); | 198 | if (filename.EndsWith(loader.Key)) |
170 | return; | 199 | { |
200 | loader.Value.SaveFile(filename, m_channel); | ||
201 | return; | ||
202 | } | ||
171 | } | 203 | } |
172 | } | 204 | } |
205 | catch (NotImplementedException) | ||
206 | { | ||
207 | m_log.Error("Unable to save to " + filename + ", saving of this file format has not been implemented."); | ||
208 | } | ||
173 | } | 209 | } |
174 | 210 | ||
175 | public void Initialise(Scene scene, IConfigSource config) | 211 | public void Initialise(Scene scene, IConfigSource config) |
@@ -177,7 +213,20 @@ namespace OpenSim.Region.Environment.Modules.Terrain | |||
177 | m_scene = scene; | 213 | m_scene = scene; |
178 | m_gConfig = config; | 214 | m_gConfig = config; |
179 | 215 | ||
180 | m_channel = new TerrainChannel(); | 216 | // Install terrain module in the simulator |
217 | if (m_scene.Heightmap == null) | ||
218 | { | ||
219 | lock (m_scene) | ||
220 | { | ||
221 | m_channel = new TerrainChannel(); | ||
222 | m_scene.Heightmap = m_channel; | ||
223 | } | ||
224 | } | ||
225 | else | ||
226 | { | ||
227 | m_channel = m_scene.Heightmap; | ||
228 | } | ||
229 | |||
181 | m_scene.EventManager.OnNewClient += EventManager_OnNewClient; | 230 | m_scene.EventManager.OnNewClient += EventManager_OnNewClient; |
182 | } | 231 | } |
183 | 232 | ||