RemoteAdmin - Added optional terrain loading on region create using parameter heightmap_file to specify the terrain file to be loaded

remove-scene-viewer
Michelle Argus 2011-10-21 23:12:01 +01:00 committed by Justin Clark-Casey (justincc)
parent 4241ee5dfa
commit a1f05a289d
1 changed files with 41 additions and 21 deletions

View File

@ -329,28 +329,8 @@ namespace OpenSim.ApplicationPlugins.RemoteController
responseData["accepted"] = true; responseData["accepted"] = true;
Scene region = null; LoadHeightmap(file, regionID);
if (!m_application.SceneManager.TryGetScene(regionID, out region))
throw new Exception("1: unable to get a scene with that name");
ITerrainModule terrainModule = region.RequestModuleInterface<ITerrainModule>();
if (null == terrainModule) throw new Exception("terrain module not available");
if (Uri.IsWellFormedUriString(file, UriKind.Absolute))
{
m_log.Info("[RADMIN]: Terrain path is URL");
Uri result;
if (Uri.TryCreate(file, UriKind.RelativeOrAbsolute, out result))
{
// the url is valid
string fileType = file.Substring(file.LastIndexOf('/') + 1);
terrainModule.LoadFromStream(fileType, result);
}
}
else
{
terrainModule.LoadFromFile(file);
}
responseData["success"] = false; responseData["success"] = false;
response.Value = responseData; response.Value = responseData;
@ -793,6 +773,12 @@ namespace OpenSim.ApplicationPlugins.RemoteController
} }
} }
//Load Heightmap if specified to new region
if (requestData.Contains("heightmap_file"))
{
LoadHeightmap((string)requestData["heightmap_file"], region.RegionID);
}
responseData["success"] = true; responseData["success"] = true;
responseData["region_name"] = region.RegionName; responseData["region_name"] = region.RegionName;
responseData["region_uuid"] = region.RegionID.ToString(); responseData["region_uuid"] = region.RegionID.ToString();
@ -3158,5 +3144,39 @@ namespace OpenSim.ApplicationPlugins.RemoteController
return false; return false;
} }
} }
private bool LoadHeightmap(string file, UUID regionID)
{
m_log.InfoFormat("[RADMIN]: Terrain Loading: {0}", file);
Scene region = null;
if (!m_application.SceneManager.TryGetScene(regionID, out region))
{
m_log.InfoFormat("[RADMIN]: unable to get a scene with that name: {0}", regionID.ToString());
return false;
}
ITerrainModule terrainModule = region.RequestModuleInterface<ITerrainModule>();
if (null == terrainModule) throw new Exception("terrain module not available");
if (Uri.IsWellFormedUriString(file, UriKind.Absolute))
{
m_log.Info("[RADMIN]: Terrain path is URL");
Uri result;
if (Uri.TryCreate(file, UriKind.RelativeOrAbsolute, out result))
{
// the url is valid
string fileType = file.Substring(file.LastIndexOf('/') + 1);
terrainModule.LoadFromStream(fileType, result);
}
}
else
{
terrainModule.LoadFromFile(file);
}
m_log.Info("[RADMIN]: Load height maps request complete");
return true;
}
} }
} }