aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
diff options
context:
space:
mode:
authorDiva Canto2011-04-12 19:46:27 -0700
committerDiva Canto2011-04-12 19:46:27 -0700
commit16c911dcbb883e60d7a49176db8b2cea650cc929 (patch)
treed4c83b6ce4ff415ed7e1126b0e1db7257fb9c238 /OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
parentBug fix in object serialization -- sculpt data was wrong. (diff)
downloadopensim-SC_OLD-16c911dcbb883e60d7a49176db8b2cea650cc929.zip
opensim-SC_OLD-16c911dcbb883e60d7a49176db8b2cea650cc929.tar.gz
opensim-SC_OLD-16c911dcbb883e60d7a49176db8b2cea650cc929.tar.bz2
opensim-SC_OLD-16c911dcbb883e60d7a49176db8b2cea650cc929.tar.xz
Implemented terrain save-tile command. Does the opposite of load-tile. For now, only saves to .png.
Diffstat (limited to 'OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs')
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs54
1 files changed, 54 insertions, 0 deletions
diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
index 8a79d78..9c7b2fa 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()
@@ -860,6 +893,15 @@ namespace OpenSim.Region.CoreModules.World.Terrain
860 SaveToFile((string) args[0]); 893 SaveToFile((string) args[0]);
861 } 894 }
862 895
896 private void InterfaceSaveTileFile(Object[] args)
897 {
898 SaveToFile((string)args[0],
899 (int)args[1],
900 (int)args[2],
901 (int)args[3],
902 (int)args[4]);
903 }
904
863 private void InterfaceBakeTerrain(Object[] args) 905 private void InterfaceBakeTerrain(Object[] args)
864 { 906 {
865 UpdateRevertMap(); 907 UpdateRevertMap();
@@ -1115,6 +1157,17 @@ namespace OpenSim.Region.CoreModules.World.Terrain
1115 loadFromTileCommand.AddArgument("minimum Y tile", "The Y region coordinate of the first section on the file", 1157 loadFromTileCommand.AddArgument("minimum Y tile", "The Y region coordinate of the first section on the file",
1116 "Integer"); 1158 "Integer");
1117 1159
1160 Command saveToTileCommand =
1161 new Command("save-tile", CommandIntentions.COMMAND_HAZARDOUS, InterfaceSaveTileFile, "Saves the current heightmap to the larger file.");
1162 saveToTileCommand.AddArgument("filename",
1163 "The file you wish to save to, the file extension determines the loader to be used. Supported extensions include: " +
1164 supportedFileExtensions, "String");
1165 saveToTileCommand.AddArgument("file width", "The width of the file in tiles", "Integer");
1166 saveToTileCommand.AddArgument("file height", "The height of the file in tiles", "Integer");
1167 saveToTileCommand.AddArgument("minimum X tile", "The X region coordinate of the first section on the file",
1168 "Integer");
1169 saveToTileCommand.AddArgument("minimum Y tile", "The Y region coordinate of the first section on the file",
1170 "Integer");
1118 // Terrain adjustments 1171 // Terrain adjustments
1119 Command fillRegionCommand = 1172 Command fillRegionCommand =
1120 new Command("fill", CommandIntentions.COMMAND_HAZARDOUS, InterfaceFillTerrain, "Fills the current heightmap with a specified value."); 1173 new Command("fill", CommandIntentions.COMMAND_HAZARDOUS, InterfaceFillTerrain, "Fills the current heightmap with a specified value.");
@@ -1166,6 +1219,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
1166 m_commander.RegisterCommand("load", loadFromFileCommand); 1219 m_commander.RegisterCommand("load", loadFromFileCommand);
1167 m_commander.RegisterCommand("load-tile", loadFromTileCommand); 1220 m_commander.RegisterCommand("load-tile", loadFromTileCommand);
1168 m_commander.RegisterCommand("save", saveToFileCommand); 1221 m_commander.RegisterCommand("save", saveToFileCommand);
1222 m_commander.RegisterCommand("save-tile", saveToTileCommand);
1169 m_commander.RegisterCommand("fill", fillRegionCommand); 1223 m_commander.RegisterCommand("fill", fillRegionCommand);
1170 m_commander.RegisterCommand("elevate", elevateCommand); 1224 m_commander.RegisterCommand("elevate", elevateCommand);
1171 m_commander.RegisterCommand("lower", lowerCommand); 1225 m_commander.RegisterCommand("lower", lowerCommand);