From 5dc5214c5e7377df743a7e489811c8acdb6a5689 Mon Sep 17 00:00:00 2001
From: Adam Frisby
Date: Tue, 26 Feb 2008 16:18:57 +0000
Subject: * Implemented - Terragen File Format Loader for new Terrain Module.
---
.../Modules/Terrain/FloodBrushes/RaiseArea.cs | 2 +-
.../Modules/Terrain/PaintBrushes/RaiseSphere.cs | 2 +-
.../Environment/Modules/Terrain/TerrainModule.cs | 35 ++++++++++++++++++++++
3 files changed, 37 insertions(+), 2 deletions(-)
(limited to 'OpenSim/Region/Environment/Modules/Terrain')
diff --git a/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/RaiseArea.cs b/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/RaiseArea.cs
index 8fd957b..258b363 100644
--- a/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/RaiseArea.cs
+++ b/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/RaiseArea.cs
@@ -6,7 +6,7 @@ using OpenSim.Region.Environment.Interfaces;
namespace OpenSim.Region.Environment.Modules.Terrain.FloodBrushes
{
- class RaiseArea : ITerrainFloodEffect
+ public class RaiseArea : ITerrainFloodEffect
{
#region ITerrainFloodEffect Members
diff --git a/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/RaiseSphere.cs b/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/RaiseSphere.cs
index be4a0b7..ff7ec0b 100644
--- a/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/RaiseSphere.cs
+++ b/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/RaiseSphere.cs
@@ -6,7 +6,7 @@ using OpenSim.Region.Environment.Interfaces;
namespace OpenSim.Region.Environment.Modules.Terrain.PaintBrushes
{
- class RaiseSphere : ITerrainPaintableEffect
+ public class RaiseSphere : ITerrainPaintableEffect
{
#region ITerrainPaintableEffect Members
diff --git a/OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs b/OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs
index 24b3f50..f704835 100644
--- a/OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs
+++ b/OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs
@@ -54,6 +54,12 @@ namespace OpenSim.Region.Environment.Modules.Terrain
void RunEffect(ITerrainChannel map, double strength);
}
+ public interface ITerrainLoader
+ {
+ ITerrainChannel LoadFile(string filename);
+ void SaveFile(string filename);
+ }
+
///
/// A new version of the old Channel class, simplified
///
@@ -126,6 +132,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain
new Dictionary();
private Dictionary m_floodeffects =
new Dictionary();
+ private Dictionary m_loaders = new Dictionary();
Scene m_scene;
ITerrainChannel m_channel;
private IConfigSource m_gConfig;
@@ -134,6 +141,34 @@ namespace OpenSim.Region.Environment.Modules.Terrain
{
m_painteffects[StandardTerrainEffects.Raise] = new PaintBrushes.RaiseSphere();
m_floodeffects[StandardTerrainEffects.Raise] = new FloodBrushes.RaiseArea();
+
+ // Float[256,256] array format (RAW32)
+ m_loaders[".r32"] = new FileLoaders.RAW32();
+ m_loaders[".f32"] = m_loaders[".r32"];
+ }
+
+ public void LoadFromFile(string filename)
+ {
+ foreach (KeyValuePair loader in m_loaders)
+ {
+ if (filename.EndsWith(loader.Key))
+ {
+ loader.Value.LoadFile(filename);
+ return;
+ }
+ }
+ }
+
+ public void SaveToFile(string filename)
+ {
+ foreach (KeyValuePair loader in m_loaders)
+ {
+ if (filename.EndsWith(loader.Key))
+ {
+ loader.Value.SaveFile(filename);
+ return;
+ }
+ }
}
public void Initialise(Scene scene, IConfigSource config)
--
cgit v1.1