* Added String(FileExtension) property to ITerrainLoader to allow us to determine which file extension this loader is capable of handling.

* Added ITerrainLoader import capability to Terrain Plugins module - this allows you to write new terrain format plugins without modifying the terrain module directly.
0.6.0-stable
Adam Frisby 2008-04-27 23:54:16 +00:00
parent 54563d8dea
commit 7693a7dac9
8 changed files with 46 additions and 6 deletions

View File

@ -42,6 +42,11 @@ namespace OpenSim.Region.Environment.Modules.Terrain.FileLoaders
{
#region ITerrainLoader Members
public string FileExtension
{
get { return ".gsd"; }
}
/// <summary>
/// Loads a file from a specified filename on the disk,
/// parses the image using the System.Drawing parsers

View File

@ -36,6 +36,11 @@ namespace OpenSim.Region.Environment.Modules.Terrain.FileLoaders
{
#region ITerrainLoader Members
public string FileExtension
{
get { return ".jpg"; }
}
public ITerrainChannel LoadFile(string filename)
{
throw new NotImplementedException();

View File

@ -132,6 +132,12 @@ namespace OpenSim.Region.Environment.Modules.Terrain.FileLoaders
s.Close();
}
public string FileExtension
{
get { return ".raw"; }
}
#endregion
public override string ToString()

View File

@ -34,6 +34,11 @@ namespace OpenSim.Region.Environment.Modules.Terrain.FileLoaders
{
#region ITerrainLoader Members
public string FileExtension
{
get { return ".r32"; }
}
public ITerrainChannel LoadFile(string filename)
{
TerrainChannel retval = new TerrainChannel();

View File

@ -107,6 +107,11 @@ namespace OpenSim.Region.Environment.Modules.Terrain.FileLoaders
throw new NotImplementedException();
}
public string FileExtension
{
get { return ".ter"; }
}
public ITerrainChannel LoadFile(string filename, int x, int y, int fileWidth, int fileHeight, int w, int h)
{
throw new NotImplementedException();

View File

@ -31,6 +31,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain
{
public interface ITerrainLoader
{
string FileExtension { get; }
ITerrainChannel LoadFile(string filename);
ITerrainChannel LoadFile(string filename, int fileStartX, int fileStartY, int fileWidth, int fileHeight, int sectionWidth, int sectionHeight);
void SaveFile(string filename, ITerrainChannel map);

View File

@ -31,15 +31,15 @@ namespace OpenSim.Region.Environment.Modules.Terrain
{
public class TerrainException : Exception
{
public TerrainException(): base()
public TerrainException() : base()
{
}
public TerrainException(string msg): base(msg)
public TerrainException(string msg) : base(msg)
{
}
public TerrainException(string msg, Exception e): base(msg, e)
public TerrainException(string msg, Exception e) : base(msg, e)
{
}
}

View File

@ -185,7 +185,8 @@ namespace OpenSim.Region.Environment.Modules.Terrain
{
m_log.Error(
"[TERRAIN]: Unable to load heightmap, file not found. (A directory permissions error may also cause this)");
throw new TerrainException(String.Format("unable to load heightmap: file {0} not found (or permissions do not allow access", filename));
throw new TerrainException(
String.Format("unable to load heightmap: file {0} not found (or permissions do not allow access", filename));
}
}
CheckForTerrainUpdates();
@ -244,8 +245,20 @@ namespace OpenSim.Region.Environment.Modules.Terrain
if (pluginType.GetInterface("ITerrainEffect", false) != null)
{
ITerrainEffect terEffect = (ITerrainEffect) Activator.CreateInstance(library.GetType(pluginType.ToString()));
if (!m_plugineffects.ContainsKey(pluginType.Name))
{
m_plugineffects.Add(pluginType.Name, terEffect);
m_log.Info("... " + pluginType.Name);
m_log.Info("E ... " + pluginType.Name);
} else
{
m_log.Warn("E ... " + pluginType.Name + " (Already added)");
}
}
else if (pluginType.GetInterface("ITerrainLoader", false) != null)
{
ITerrainLoader terLoader = (ITerrainLoader) Activator.CreateInstance(library.GetType(pluginType.ToString()));
m_loaders[terLoader.FileExtension] = terLoader;
m_log.Info("L ... " + pluginType.Name);
}
}
catch (AmbiguousMatchException)