diff options
author | Melanie | 2011-04-17 18:48:53 +0100 |
---|---|---|
committer | Melanie | 2011-04-17 18:48:53 +0100 |
commit | 474910c9d624b53c010232ddb32b4002f58f1de0 (patch) | |
tree | 45ddab37c6afa0b095ffa0503640b9fe235bc400 /OpenSim/Region/CoreModules/World/Terrain | |
parent | Merge branch 'master' into careminster-presence-refactor (diff) | |
parent | More descriptive debug msg for ServiceOSDRequest failures. (diff) | |
download | opensim-SC_OLD-474910c9d624b53c010232ddb32b4002f58f1de0.zip opensim-SC_OLD-474910c9d624b53c010232ddb32b4002f58f1de0.tar.gz opensim-SC_OLD-474910c9d624b53c010232ddb32b4002f58f1de0.tar.bz2 opensim-SC_OLD-474910c9d624b53c010232ddb32b4002f58f1de0.tar.xz |
Merge branch 'master' into careminster-presence-refactor
Diffstat (limited to 'OpenSim/Region/CoreModules/World/Terrain')
7 files changed, 132 insertions, 0 deletions
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs index d6fa093..21a9999 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs | |||
@@ -124,6 +124,52 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders | |||
124 | colours.Save(stream, ImageFormat.Png); | 124 | colours.Save(stream, ImageFormat.Png); |
125 | } | 125 | } |
126 | 126 | ||
127 | public virtual void SaveFile(ITerrainChannel m_channel, string filename, | ||
128 | int offsetX, int offsetY, | ||
129 | int fileWidth, int fileHeight, | ||
130 | int regionSizeX, int regionSizeY) | ||
131 | |||
132 | { | ||
133 | // We need to do this because: | ||
134 | // "Saving the image to the same file it was constructed from is not allowed and throws an exception." | ||
135 | string tempName = offsetX + "_ " + offsetY + "_" + filename; | ||
136 | |||
137 | Bitmap entireBitmap = null; | ||
138 | Bitmap thisBitmap = null; | ||
139 | if (File.Exists(filename)) | ||
140 | { | ||
141 | File.Copy(filename, tempName); | ||
142 | entireBitmap = new Bitmap(tempName); | ||
143 | if (entireBitmap.Width != fileWidth * regionSizeX || entireBitmap.Height != fileHeight * regionSizeY) | ||
144 | { | ||
145 | // old file, let's overwrite it | ||
146 | entireBitmap = new Bitmap(fileWidth * regionSizeX, fileHeight * regionSizeY); | ||
147 | } | ||
148 | } | ||
149 | else | ||
150 | { | ||
151 | entireBitmap = new Bitmap(fileWidth * regionSizeX, fileHeight * regionSizeY); | ||
152 | } | ||
153 | |||
154 | thisBitmap = CreateGrayscaleBitmapFromMap(m_channel); | ||
155 | Console.WriteLine("offsetX=" + offsetX + " offsetY=" + offsetY); | ||
156 | for (int x = 0; x < regionSizeX; x++) | ||
157 | for (int y = 0; y < regionSizeY; y++) | ||
158 | entireBitmap.SetPixel(x + offsetX * regionSizeX, y + (fileHeight - 1 - offsetY) * regionSizeY, thisBitmap.GetPixel(x, y)); | ||
159 | |||
160 | Save(entireBitmap, filename); | ||
161 | thisBitmap.Dispose(); | ||
162 | entireBitmap.Dispose(); | ||
163 | |||
164 | if (File.Exists(tempName)) | ||
165 | File.Delete(tempName); | ||
166 | } | ||
167 | |||
168 | protected virtual void Save(Bitmap bmp, string filename) | ||
169 | { | ||
170 | bmp.Save(filename, ImageFormat.Png); | ||
171 | } | ||
172 | |||
127 | #endregion | 173 | #endregion |
128 | 174 | ||
129 | public override string ToString() | 175 | public override string ToString() |
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/JPEG.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/JPEG.cs index 8667607..1a0d8ec 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/JPEG.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/JPEG.cs | |||
@@ -76,6 +76,14 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders | |||
76 | colours.Save(stream, ImageFormat.Jpeg); | 76 | colours.Save(stream, ImageFormat.Jpeg); |
77 | } | 77 | } |
78 | 78 | ||
79 | public virtual void SaveFile(ITerrainChannel m_channel, string filename, | ||
80 | int offsetX, int offsetY, | ||
81 | int fileWidth, int fileHeight, | ||
82 | int regionSizeX, int regionSizeY) | ||
83 | { | ||
84 | throw new System.Exception("Not Implemented"); | ||
85 | } | ||
86 | |||
79 | #endregion | 87 | #endregion |
80 | 88 | ||
81 | public override string ToString() | 89 | public override string ToString() |
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/LLRAW.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/LLRAW.cs index a70ef13..fad7641 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/LLRAW.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/LLRAW.cs | |||
@@ -240,6 +240,14 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders | |||
240 | get { return ".raw"; } | 240 | get { return ".raw"; } |
241 | } | 241 | } |
242 | 242 | ||
243 | public virtual void SaveFile(ITerrainChannel m_channel, string filename, | ||
244 | int offsetX, int offsetY, | ||
245 | int fileWidth, int fileHeight, | ||
246 | int regionSizeX, int regionSizeY) | ||
247 | { | ||
248 | throw new System.Exception("Not Implemented"); | ||
249 | } | ||
250 | |||
243 | #endregion | 251 | #endregion |
244 | 252 | ||
245 | public override string ToString() | 253 | public override string ToString() |
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/RAW32.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/RAW32.cs index 3c76665..ba073ca 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/RAW32.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/RAW32.cs | |||
@@ -160,6 +160,13 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders | |||
160 | bs.Close(); | 160 | bs.Close(); |
161 | } | 161 | } |
162 | 162 | ||
163 | public virtual void SaveFile(ITerrainChannel m_channel, string filename, | ||
164 | int offsetX, int offsetY, | ||
165 | int fileWidth, int fileHeight, | ||
166 | int regionSizeX, int regionSizeY) | ||
167 | { | ||
168 | throw new System.Exception("Not Implemented"); | ||
169 | } | ||
163 | #endregion | 170 | #endregion |
164 | 171 | ||
165 | public override string ToString() | 172 | public override string ToString() |
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/Terragen.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/Terragen.cs index 2919897..2f37d9d 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/Terragen.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/Terragen.cs | |||
@@ -308,6 +308,14 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders | |||
308 | get { return ".ter"; } | 308 | get { return ".ter"; } |
309 | } | 309 | } |
310 | 310 | ||
311 | public virtual void SaveFile(ITerrainChannel m_channel, string filename, | ||
312 | int offsetX, int offsetY, | ||
313 | int fileWidth, int fileHeight, | ||
314 | int regionSizeX, int regionSizeY) | ||
315 | { | ||
316 | throw new System.Exception("Not Implemented"); | ||
317 | } | ||
318 | |||
311 | #endregion | 319 | #endregion |
312 | 320 | ||
313 | public override string ToString() | 321 | public override string ToString() |
diff --git a/OpenSim/Region/CoreModules/World/Terrain/ITerrainLoader.cs b/OpenSim/Region/CoreModules/World/Terrain/ITerrainLoader.cs index 7403281..7237f90 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/ITerrainLoader.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/ITerrainLoader.cs | |||
@@ -38,5 +38,6 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
38 | ITerrainChannel LoadStream(Stream stream); | 38 | ITerrainChannel LoadStream(Stream stream); |
39 | void SaveFile(string filename, ITerrainChannel map); | 39 | void SaveFile(string filename, ITerrainChannel map); |
40 | void SaveStream(Stream stream, ITerrainChannel map); | 40 | void SaveStream(Stream stream, ITerrainChannel map); |
41 | void SaveFile(ITerrainChannel map, string filename, int offsetX, int offsetY, int fileWidth, int fileHeight, int regionSizeX, int regionSizeY); | ||
41 | } | 42 | } |
42 | } \ No newline at end of file | 43 | } \ No newline at end of file |
diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs index 9d968e7..2da6458 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs | |||
@@ -541,6 +541,39 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
541 | } | 541 | } |
542 | 542 | ||
543 | /// <summary> | 543 | /// <summary> |
544 | /// Saves the terrain to a larger terrain file. | ||
545 | /// </summary> | ||
546 | /// <param name="filename">The terrain file to save</param> | ||
547 | /// <param name="fileWidth">The width of the file in units</param> | ||
548 | /// <param name="fileHeight">The height of the file in units</param> | ||
549 | /// <param name="fileStartX">Where to begin our slice</param> | ||
550 | /// <param name="fileStartY">Where to begin our slice</param> | ||
551 | public void SaveToFile(string filename, int fileWidth, int fileHeight, int fileStartX, int fileStartY) | ||
552 | { | ||
553 | int offsetX = (int)m_scene.RegionInfo.RegionLocX - fileStartX; | ||
554 | int offsetY = (int)m_scene.RegionInfo.RegionLocY - fileStartY; | ||
555 | |||
556 | if (offsetX >= 0 && offsetX < fileWidth && offsetY >= 0 && offsetY < fileHeight) | ||
557 | { | ||
558 | // this region is included in the tile request | ||
559 | foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders) | ||
560 | { | ||
561 | if (filename.EndsWith(loader.Key)) | ||
562 | { | ||
563 | lock (m_scene) | ||
564 | { | ||
565 | loader.Value.SaveFile(m_channel, filename, offsetX, offsetY, | ||
566 | fileWidth, fileHeight, | ||
567 | (int)Constants.RegionSize, | ||
568 | (int)Constants.RegionSize); | ||
569 | } | ||
570 | return; | ||
571 | } | ||
572 | } | ||
573 | } | ||
574 | } | ||
575 | |||
576 | /// <summary> | ||
544 | /// Performs updates to the region periodically, synchronising physics and other heightmap aware sections | 577 | /// Performs updates to the region periodically, synchronising physics and other heightmap aware sections |
545 | /// </summary> | 578 | /// </summary> |
546 | private void EventManager_OnTerrainTick() | 579 | private void EventManager_OnTerrainTick() |
@@ -862,6 +895,15 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
862 | SaveToFile((string) args[0]); | 895 | SaveToFile((string) args[0]); |
863 | } | 896 | } |
864 | 897 | ||
898 | private void InterfaceSaveTileFile(Object[] args) | ||
899 | { | ||
900 | SaveToFile((string)args[0], | ||
901 | (int)args[1], | ||
902 | (int)args[2], | ||
903 | (int)args[3], | ||
904 | (int)args[4]); | ||
905 | } | ||
906 | |||
865 | private void InterfaceBakeTerrain(Object[] args) | 907 | private void InterfaceBakeTerrain(Object[] args) |
866 | { | 908 | { |
867 | UpdateRevertMap(); | 909 | UpdateRevertMap(); |
@@ -1117,6 +1159,17 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
1117 | loadFromTileCommand.AddArgument("minimum Y tile", "The Y region coordinate of the first section on the file", | 1159 | loadFromTileCommand.AddArgument("minimum Y tile", "The Y region coordinate of the first section on the file", |
1118 | "Integer"); | 1160 | "Integer"); |
1119 | 1161 | ||
1162 | Command saveToTileCommand = | ||
1163 | new Command("save-tile", CommandIntentions.COMMAND_HAZARDOUS, InterfaceSaveTileFile, "Saves the current heightmap to the larger file."); | ||
1164 | saveToTileCommand.AddArgument("filename", | ||
1165 | "The file you wish to save to, the file extension determines the loader to be used. Supported extensions include: " + | ||
1166 | supportedFileExtensions, "String"); | ||
1167 | saveToTileCommand.AddArgument("file width", "The width of the file in tiles", "Integer"); | ||
1168 | saveToTileCommand.AddArgument("file height", "The height of the file in tiles", "Integer"); | ||
1169 | saveToTileCommand.AddArgument("minimum X tile", "The X region coordinate of the first section on the file", | ||
1170 | "Integer"); | ||
1171 | saveToTileCommand.AddArgument("minimum Y tile", "The Y region coordinate of the first section on the file", | ||
1172 | "Integer"); | ||
1120 | // Terrain adjustments | 1173 | // Terrain adjustments |
1121 | Command fillRegionCommand = | 1174 | Command fillRegionCommand = |
1122 | new Command("fill", CommandIntentions.COMMAND_HAZARDOUS, InterfaceFillTerrain, "Fills the current heightmap with a specified value."); | 1175 | new Command("fill", CommandIntentions.COMMAND_HAZARDOUS, InterfaceFillTerrain, "Fills the current heightmap with a specified value."); |
@@ -1168,6 +1221,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
1168 | m_commander.RegisterCommand("load", loadFromFileCommand); | 1221 | m_commander.RegisterCommand("load", loadFromFileCommand); |
1169 | m_commander.RegisterCommand("load-tile", loadFromTileCommand); | 1222 | m_commander.RegisterCommand("load-tile", loadFromTileCommand); |
1170 | m_commander.RegisterCommand("save", saveToFileCommand); | 1223 | m_commander.RegisterCommand("save", saveToFileCommand); |
1224 | m_commander.RegisterCommand("save-tile", saveToTileCommand); | ||
1171 | m_commander.RegisterCommand("fill", fillRegionCommand); | 1225 | m_commander.RegisterCommand("fill", fillRegionCommand); |
1172 | m_commander.RegisterCommand("elevate", elevateCommand); | 1226 | m_commander.RegisterCommand("elevate", elevateCommand); |
1173 | m_commander.RegisterCommand("lower", lowerCommand); | 1227 | m_commander.RegisterCommand("lower", lowerCommand); |