31 using OpenSim.Framework;
32 using OpenSim.Region.Framework.Interfaces;
33 using OpenSim.Region.Framework.Scenes;
39 #region ITerrainLoader Members
41 public string FileExtension
43 get {
return ".r32"; }
48 FileInfo file =
new FileInfo(filename);
49 FileStream s = file.Open(FileMode.Open, FileAccess.Read);
57 public ITerrainChannel LoadFile(
string filename,
int offsetX,
int offsetY,
int fileWidth,
int fileHeight,
int sectionWidth,
int sectionHeight)
61 FileInfo file =
new FileInfo(filename);
62 FileStream s = file.Open(FileMode.Open, FileAccess.Read);
63 BinaryReader bs =
new BinaryReader(s);
65 int currFileYOffset = 0;
69 while (currFileYOffset < offsetY)
72 int heightsToRead = sectionHeight * (fileWidth * sectionWidth);
73 bs.ReadBytes(heightsToRead * 4);
81 for (y = 0; y < sectionHeight; y++)
83 int currFileXOffset = 0;
88 while (currFileXOffset < offsetX)
90 bs.ReadBytes(sectionWidth * 4);
96 for (x = 0; x < sectionWidth; x++)
99 retval[x, y] = bs.ReadSingle();
106 while (currFileXOffset < fileWidth)
109 bs.ReadBytes(sectionWidth * 4);
124 double dimension = Math.Sqrt((double)(s.Length / 4));
132 BinaryReader bs =
new BinaryReader(s);
134 for (y = 0; y < retval.Height; y++)
137 for (x = 0; x < retval.Width; x++)
139 retval[x, y] = bs.ReadSingle();
150 FileInfo file =
new FileInfo(filename);
151 FileStream s = file.Open(FileMode.Create, FileAccess.Write);
159 BinaryWriter bs =
new BinaryWriter(s);
162 for (y = 0; y < map.Height; y++)
165 for (x = 0; x < map.Width; x++)
167 bs.Write((float) map[x, y]);
175 int offsetX,
int offsetY,
176 int fileWidth,
int fileHeight,
177 int regionSizeX,
int regionSizeY)
179 throw new System.Exception(
"Not Implemented");
ITerrainChannel LoadFile(string filename, int offsetX, int offsetY, int fileWidth, int fileHeight, int sectionWidth, int sectionHeight)
override string ToString()
void SaveStream(Stream s, ITerrainChannel map)
ITerrainChannel LoadStream(Stream s)
void SaveFile(string filename, ITerrainChannel map)
A new version of the old Channel class, simplified
virtual void SaveFile(ITerrainChannel m_channel, string filename, int offsetX, int offsetY, int fileWidth, int fileHeight, int regionSizeX, int regionSizeY)
Save a number of map tiles to a single big image file.
ITerrainChannel LoadFile(string filename)