diff options
author | Adam Frisby | 2008-04-30 21:16:36 +0000 |
---|---|---|
committer | Adam Frisby | 2008-04-30 21:16:36 +0000 |
commit | f5c312bc3c2567449c7268a54a08a54119f58d53 (patch) | |
tree | 424668a4bbec6873ebc5b8256f3671db102f5e9c /OpenSim/Region/Environment/Modules/Terrain/FileLoaders | |
parent | * Adds the AuthbuyerID field to sqlite and makes use of it. (diff) | |
download | opensim-SC-f5c312bc3c2567449c7268a54a08a54119f58d53.zip opensim-SC-f5c312bc3c2567449c7268a54a08a54119f58d53.tar.gz opensim-SC-f5c312bc3c2567449c7268a54a08a54119f58d53.tar.bz2 opensim-SC-f5c312bc3c2567449c7268a54a08a54119f58d53.tar.xz |
* Refactored Environment/Modules directory - modules now reside in their own directory with any associated module-specific classes.
* Each module directory is currently inside one of the following category folders: Agent (Anything relating to do with Client<->Server communications.), Avatar (Anything to do with the avatar or presence inworld), Framework (Classes modules can use), Grid (Grid traffic, new OGS2 grid comms), Scripting (Scripting functions, etc), World (The enrivonment/scene, IE Sun/Tree modules.)
* This should be moved into a seperate project file.
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Terrain/FileLoaders')
9 files changed, 0 insertions, 897 deletions
diff --git a/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/BMP.cs b/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/BMP.cs deleted file mode 100644 index f975872..0000000 --- a/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/BMP.cs +++ /dev/null | |||
@@ -1,62 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | using System.Drawing; | ||
28 | using System.Drawing.Imaging; | ||
29 | using OpenSim.Region.Environment.Interfaces; | ||
30 | |||
31 | namespace OpenSim.Region.Environment.Modules.Terrain.FileLoaders | ||
32 | { | ||
33 | /// <summary> | ||
34 | /// A generic windows bitmap loader. | ||
35 | /// Should be capable of handling 24-bit RGB images. | ||
36 | /// | ||
37 | /// Uses the System.Drawing filesystem loader. | ||
38 | /// </summary> | ||
39 | internal class BMP : GenericSystemDrawing | ||
40 | { | ||
41 | /// <summary> | ||
42 | /// Exports a file to a image on the disk using a System.Drawing exporter. | ||
43 | /// </summary> | ||
44 | /// <param name="filename">The target filename</param> | ||
45 | /// <param name="map">The terrain channel being saved</param> | ||
46 | public override void SaveFile(string filename, ITerrainChannel map) | ||
47 | { | ||
48 | Bitmap colours = CreateGrayscaleBitmapFromMap(map); | ||
49 | |||
50 | colours.Save(filename, ImageFormat.Bmp); | ||
51 | } | ||
52 | |||
53 | /// <summary> | ||
54 | /// The human readable version of the file format(s) this loader handles | ||
55 | /// </summary> | ||
56 | /// <returns></returns> | ||
57 | public override string ToString() | ||
58 | { | ||
59 | return "BMP"; | ||
60 | } | ||
61 | } | ||
62 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/GIF.cs b/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/GIF.cs deleted file mode 100644 index cf82000..0000000 --- a/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/GIF.cs +++ /dev/null | |||
@@ -1,47 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | using System.Drawing; | ||
28 | using System.Drawing.Imaging; | ||
29 | using OpenSim.Region.Environment.Interfaces; | ||
30 | |||
31 | namespace OpenSim.Region.Environment.Modules.Terrain.FileLoaders | ||
32 | { | ||
33 | internal class GIF : GenericSystemDrawing | ||
34 | { | ||
35 | public override void SaveFile(string filename, ITerrainChannel map) | ||
36 | { | ||
37 | Bitmap colours = CreateGrayscaleBitmapFromMap(map); | ||
38 | |||
39 | colours.Save(filename, ImageFormat.Gif); | ||
40 | } | ||
41 | |||
42 | public override string ToString() | ||
43 | { | ||
44 | return "GIF"; | ||
45 | } | ||
46 | } | ||
47 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/GenericSystemDrawing.cs b/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/GenericSystemDrawing.cs deleted file mode 100644 index b05c1cd..0000000 --- a/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/GenericSystemDrawing.cs +++ /dev/null | |||
@@ -1,172 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Drawing; | ||
30 | using System.Drawing.Imaging; | ||
31 | using OpenSim.Region.Environment.Interfaces; | ||
32 | |||
33 | namespace OpenSim.Region.Environment.Modules.Terrain.FileLoaders | ||
34 | { | ||
35 | /// <summary> | ||
36 | /// A virtual class designed to have methods overloaded, | ||
37 | /// this class provides an interface for a generic image | ||
38 | /// saving and loading mechanism, but does not specify the | ||
39 | /// format. It should not be insubstantiated directly. | ||
40 | /// </summary> | ||
41 | public class GenericSystemDrawing : ITerrainLoader | ||
42 | { | ||
43 | #region ITerrainLoader Members | ||
44 | |||
45 | public string FileExtension | ||
46 | { | ||
47 | get { return ".gsd"; } | ||
48 | } | ||
49 | |||
50 | /// <summary> | ||
51 | /// Loads a file from a specified filename on the disk, | ||
52 | /// parses the image using the System.Drawing parsers | ||
53 | /// then returns a terrain channel. Values are | ||
54 | /// returned based on HSL brightness between 0m and 128m | ||
55 | /// </summary> | ||
56 | /// <param name="filename">The target image to load</param> | ||
57 | /// <returns>A terrain channel generated from the image.</returns> | ||
58 | public virtual ITerrainChannel LoadFile(string filename) | ||
59 | { | ||
60 | Bitmap file = new Bitmap(filename); | ||
61 | |||
62 | ITerrainChannel retval = new TerrainChannel(file.Width, file.Height); | ||
63 | |||
64 | int x, y; | ||
65 | for (x = 0; x < file.Width; x++) | ||
66 | { | ||
67 | for (y = 0; y < file.Height; y++) | ||
68 | { | ||
69 | retval[x, y] = file.GetPixel(x, y).GetBrightness() * 128; | ||
70 | } | ||
71 | } | ||
72 | |||
73 | return retval; | ||
74 | } | ||
75 | |||
76 | public ITerrainChannel LoadFile(string filename, int x, int y, int fileWidth, int fileHeight, int w, int h) | ||
77 | { | ||
78 | throw new NotImplementedException(); | ||
79 | } | ||
80 | |||
81 | /// <summary> | ||
82 | /// Exports a file to a image on the disk using a System.Drawing exporter. | ||
83 | /// </summary> | ||
84 | /// <param name="filename">The target filename</param> | ||
85 | /// <param name="map">The terrain channel being saved</param> | ||
86 | public virtual void SaveFile(string filename, ITerrainChannel map) | ||
87 | { | ||
88 | Bitmap colours = CreateGrayscaleBitmapFromMap(map); | ||
89 | |||
90 | colours.Save(filename, ImageFormat.Png); | ||
91 | } | ||
92 | |||
93 | #endregion | ||
94 | |||
95 | public override string ToString() | ||
96 | { | ||
97 | return "SYS.DRAWING"; | ||
98 | } | ||
99 | |||
100 | /// <summary> | ||
101 | /// Protected method, generates a grayscale bitmap | ||
102 | /// image from a specified terrain channel. | ||
103 | /// </summary> | ||
104 | /// <param name="map">The terrain channel to export to bitmap</param> | ||
105 | /// <returns>A System.Drawing.Bitmap containing a grayscale image</returns> | ||
106 | protected Bitmap CreateGrayscaleBitmapFromMap(ITerrainChannel map) | ||
107 | { | ||
108 | Bitmap bmp = new Bitmap(map.Width, map.Height); | ||
109 | |||
110 | int pallete = 256; | ||
111 | |||
112 | Color[] grays = new Color[pallete]; | ||
113 | for (int i = 0; i < grays.Length; i++) | ||
114 | { | ||
115 | grays[i] = Color.FromArgb(i, i, i); | ||
116 | } | ||
117 | |||
118 | for (int y = 0; y < map.Height; y++) | ||
119 | { | ||
120 | for (int x = 0; x < map.Width; x++) | ||
121 | { | ||
122 | // 512 is the largest possible height before colours clamp | ||
123 | int colorindex = (int) (Math.Max(Math.Min(1.0, map[x, y] / 128.0), 0.0) * (pallete - 1)); | ||
124 | |||
125 | // Handle error conditions | ||
126 | if (colorindex > pallete - 1 || colorindex < 0) | ||
127 | bmp.SetPixel(x, map.Height - y - 1, Color.Red); | ||
128 | else | ||
129 | bmp.SetPixel(x, map.Height - y - 1, grays[colorindex]); | ||
130 | } | ||
131 | } | ||
132 | return bmp; | ||
133 | } | ||
134 | |||
135 | /// <summary> | ||
136 | /// Protected method, generates a coloured bitmap | ||
137 | /// image from a specified terrain channel. | ||
138 | /// </summary> | ||
139 | /// <param name="map">The terrain channel to export to bitmap</param> | ||
140 | /// <returns>A System.Drawing.Bitmap containing a coloured image</returns> | ||
141 | protected Bitmap CreateBitmapFromMap(ITerrainChannel map) | ||
142 | { | ||
143 | Bitmap gradientmapLd = new Bitmap("defaultstripe.png"); | ||
144 | |||
145 | int pallete = gradientmapLd.Height; | ||
146 | |||
147 | Bitmap bmp = new Bitmap(map.Width, map.Height); | ||
148 | Color[] colours = new Color[pallete]; | ||
149 | |||
150 | for (int i = 0; i < pallete; i++) | ||
151 | { | ||
152 | colours[i] = gradientmapLd.GetPixel(0, i); | ||
153 | } | ||
154 | |||
155 | for (int y = 0; y < map.Height; y++) | ||
156 | { | ||
157 | for (int x = 0; x < map.Width; x++) | ||
158 | { | ||
159 | // 512 is the largest possible height before colours clamp | ||
160 | int colorindex = (int) (Math.Max(Math.Min(1.0, map[x, y] / 512.0), 0.0) * (pallete - 1)); | ||
161 | |||
162 | // Handle error conditions | ||
163 | if (colorindex > pallete - 1 || colorindex < 0) | ||
164 | bmp.SetPixel(x, map.Height - y - 1, Color.Red); | ||
165 | else | ||
166 | bmp.SetPixel(x, map.Height - y - 1, colours[colorindex]); | ||
167 | } | ||
168 | } | ||
169 | return bmp; | ||
170 | } | ||
171 | } | ||
172 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/JPEG.cs b/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/JPEG.cs deleted file mode 100644 index c2ac9d0..0000000 --- a/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/JPEG.cs +++ /dev/null | |||
@@ -1,94 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Drawing; | ||
30 | using System.Drawing.Imaging; | ||
31 | using OpenSim.Region.Environment.Interfaces; | ||
32 | |||
33 | namespace OpenSim.Region.Environment.Modules.Terrain.FileLoaders | ||
34 | { | ||
35 | public class JPEG : ITerrainLoader | ||
36 | { | ||
37 | #region ITerrainLoader Members | ||
38 | |||
39 | public string FileExtension | ||
40 | { | ||
41 | get { return ".jpg"; } | ||
42 | } | ||
43 | |||
44 | public ITerrainChannel LoadFile(string filename) | ||
45 | { | ||
46 | throw new NotImplementedException(); | ||
47 | } | ||
48 | |||
49 | public ITerrainChannel LoadFile(string filename, int x, int y, int fileWidth, int fileHeight, int w, int h) | ||
50 | { | ||
51 | throw new NotImplementedException(); | ||
52 | } | ||
53 | |||
54 | public void SaveFile(string filename, ITerrainChannel map) | ||
55 | { | ||
56 | Bitmap colours = CreateBitmapFromMap(map); | ||
57 | |||
58 | colours.Save(filename, ImageFormat.Jpeg); | ||
59 | } | ||
60 | |||
61 | #endregion | ||
62 | |||
63 | public override string ToString() | ||
64 | { | ||
65 | return "JPEG"; | ||
66 | } | ||
67 | |||
68 | private Bitmap CreateBitmapFromMap(ITerrainChannel map) | ||
69 | { | ||
70 | Bitmap gradientmapLd = new Bitmap("defaultstripe.png"); | ||
71 | |||
72 | int pallete = gradientmapLd.Height; | ||
73 | |||
74 | Bitmap bmp = new Bitmap(map.Width, map.Height); | ||
75 | Color[] colours = new Color[pallete]; | ||
76 | |||
77 | for (int i = 0; i < pallete; i++) | ||
78 | { | ||
79 | colours[i] = gradientmapLd.GetPixel(0, i); | ||
80 | } | ||
81 | |||
82 | for (int y = 0; y < map.Height; y++) | ||
83 | { | ||
84 | for (int x = 0; x < map.Width; x++) | ||
85 | { | ||
86 | // 512 is the largest possible height before colours clamp | ||
87 | int colorindex = (int) (Math.Max(Math.Min(1.0, map[x, y] / 512.0), 0.0) * (pallete - 1)); | ||
88 | bmp.SetPixel(x, map.Height - y - 1, colours[colorindex]); | ||
89 | } | ||
90 | } | ||
91 | return bmp; | ||
92 | } | ||
93 | } | ||
94 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/LLRAW.cs b/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/LLRAW.cs deleted file mode 100644 index 6ed7340..0000000 --- a/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/LLRAW.cs +++ /dev/null | |||
@@ -1,148 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.IO; | ||
30 | using OpenSim.Region.Environment.Interfaces; | ||
31 | |||
32 | namespace OpenSim.Region.Environment.Modules.Terrain.FileLoaders | ||
33 | { | ||
34 | public class LLRAW : ITerrainLoader | ||
35 | { | ||
36 | #region ITerrainLoader Members | ||
37 | |||
38 | public ITerrainChannel LoadFile(string filename) | ||
39 | { | ||
40 | TerrainChannel retval = new TerrainChannel(); | ||
41 | |||
42 | FileInfo file = new FileInfo(filename); | ||
43 | FileStream s = file.Open(FileMode.Open, FileAccess.Read); | ||
44 | BinaryReader bs = new BinaryReader(s); | ||
45 | int x, y; | ||
46 | for (y = 0; y < retval.Height; y++) | ||
47 | { | ||
48 | for (x = 0; x < retval.Width; x++) | ||
49 | { | ||
50 | retval[x, y] = (double) bs.ReadByte() * ((double) bs.ReadByte() / 127.0); | ||
51 | bs.ReadBytes(11); // Advance the stream to next bytes. | ||
52 | } | ||
53 | } | ||
54 | |||
55 | bs.Close(); | ||
56 | s.Close(); | ||
57 | |||
58 | return retval; | ||
59 | } | ||
60 | |||
61 | public ITerrainChannel LoadFile(string filename, int x, int y, int fileWidth, int fileHeight, int w, int h) | ||
62 | { | ||
63 | throw new NotImplementedException(); | ||
64 | } | ||
65 | |||
66 | public void SaveFile(string filename, ITerrainChannel map) | ||
67 | { | ||
68 | FileInfo file = new FileInfo(filename); | ||
69 | FileStream s = file.Open(FileMode.CreateNew, FileAccess.Write); | ||
70 | BinaryWriter binStream = new BinaryWriter(s); | ||
71 | |||
72 | // Generate a smegging big lookup table to speed the operation up (it needs it) | ||
73 | double[] lookupHeightTable = new double[65536]; | ||
74 | int i, j, x, y; | ||
75 | for (i = 0; i < 256; i++) | ||
76 | { | ||
77 | for (j = 0; j < 256; j++) | ||
78 | { | ||
79 | lookupHeightTable[i + (j * 256)] = ((double) i * ((double) j / 127.0)); | ||
80 | } | ||
81 | } | ||
82 | |||
83 | // Output the calculated raw | ||
84 | for (y = 0; y < map.Height; y++) | ||
85 | { | ||
86 | for (x = 0; x < map.Width; x++) | ||
87 | { | ||
88 | double t = map[x, y]; | ||
89 | double min = double.MaxValue; | ||
90 | int index = 0; | ||
91 | |||
92 | for (i = 0; i < 65536; i++) | ||
93 | { | ||
94 | if (Math.Abs(t - lookupHeightTable[i]) < min) | ||
95 | { | ||
96 | min = Math.Abs(t - lookupHeightTable[i]); | ||
97 | index = i; | ||
98 | } | ||
99 | } | ||
100 | |||
101 | byte red = (byte) (index & 0xFF); | ||
102 | byte green = (byte) ((index >> 8) & 0xFF); | ||
103 | byte blue = 20; | ||
104 | byte alpha1 = 0; // Land Parcels | ||
105 | byte alpha2 = 0; // For Sale Land | ||
106 | byte alpha3 = 0; // Public Edit Object | ||
107 | byte alpha4 = 0; // Public Edit Land | ||
108 | byte alpha5 = 255; // Safe Land | ||
109 | byte alpha6 = 255; // Flying Allowed | ||
110 | byte alpha7 = 255; // Create Landmark | ||
111 | byte alpha8 = 255; // Outside Scripts | ||
112 | byte alpha9 = red; | ||
113 | byte alpha10 = green; | ||
114 | |||
115 | binStream.Write(red); | ||
116 | binStream.Write(green); | ||
117 | binStream.Write(blue); | ||
118 | binStream.Write(alpha1); | ||
119 | binStream.Write(alpha2); | ||
120 | binStream.Write(alpha3); | ||
121 | binStream.Write(alpha4); | ||
122 | binStream.Write(alpha5); | ||
123 | binStream.Write(alpha6); | ||
124 | binStream.Write(alpha7); | ||
125 | binStream.Write(alpha8); | ||
126 | binStream.Write(alpha9); | ||
127 | binStream.Write(alpha10); | ||
128 | } | ||
129 | } | ||
130 | |||
131 | binStream.Close(); | ||
132 | s.Close(); | ||
133 | } | ||
134 | |||
135 | |||
136 | public string FileExtension | ||
137 | { | ||
138 | get { return ".raw"; } | ||
139 | } | ||
140 | |||
141 | #endregion | ||
142 | |||
143 | public override string ToString() | ||
144 | { | ||
145 | return "LL/SL RAW"; | ||
146 | } | ||
147 | } | ||
148 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/PNG.cs b/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/PNG.cs deleted file mode 100644 index 16f1e3c..0000000 --- a/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/PNG.cs +++ /dev/null | |||
@@ -1,47 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | using System.Drawing; | ||
28 | using System.Drawing.Imaging; | ||
29 | using OpenSim.Region.Environment.Interfaces; | ||
30 | |||
31 | namespace OpenSim.Region.Environment.Modules.Terrain.FileLoaders | ||
32 | { | ||
33 | internal class PNG : GenericSystemDrawing | ||
34 | { | ||
35 | public override void SaveFile(string filename, ITerrainChannel map) | ||
36 | { | ||
37 | Bitmap colours = CreateGrayscaleBitmapFromMap(map); | ||
38 | |||
39 | colours.Save(filename, ImageFormat.Png); | ||
40 | } | ||
41 | |||
42 | public override string ToString() | ||
43 | { | ||
44 | return "PNG"; | ||
45 | } | ||
46 | } | ||
47 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/RAW32.cs b/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/RAW32.cs deleted file mode 100644 index edc379b..0000000 --- a/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/RAW32.cs +++ /dev/null | |||
@@ -1,153 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System.IO; | ||
29 | using OpenSim.Region.Environment.Interfaces; | ||
30 | |||
31 | namespace OpenSim.Region.Environment.Modules.Terrain.FileLoaders | ||
32 | { | ||
33 | public class RAW32 : ITerrainLoader | ||
34 | { | ||
35 | #region ITerrainLoader Members | ||
36 | |||
37 | public string FileExtension | ||
38 | { | ||
39 | get { return ".r32"; } | ||
40 | } | ||
41 | |||
42 | public ITerrainChannel LoadFile(string filename) | ||
43 | { | ||
44 | TerrainChannel retval = new TerrainChannel(); | ||
45 | |||
46 | FileInfo file = new FileInfo(filename); | ||
47 | FileStream s = file.Open(FileMode.Open, FileAccess.Read); | ||
48 | BinaryReader bs = new BinaryReader(s); | ||
49 | int x, y; | ||
50 | for (y = 0; y < retval.Height; y++) | ||
51 | { | ||
52 | for (x = 0; x < retval.Width; x++) | ||
53 | { | ||
54 | retval[x, y] = bs.ReadSingle(); | ||
55 | } | ||
56 | } | ||
57 | |||
58 | bs.Close(); | ||
59 | s.Close(); | ||
60 | |||
61 | return retval; | ||
62 | } | ||
63 | |||
64 | public ITerrainChannel LoadFile(string filename, int offsetX, int offsetY, int fileWidth, int fileHeight, int sectionWidth, int sectionHeight) | ||
65 | { | ||
66 | TerrainChannel retval = new TerrainChannel(sectionWidth, sectionHeight); | ||
67 | |||
68 | FileInfo file = new FileInfo(filename); | ||
69 | FileStream s = file.Open(FileMode.Open, FileAccess.Read); | ||
70 | BinaryReader bs = new BinaryReader(s); | ||
71 | |||
72 | int currFileXOffset = 0; | ||
73 | int currFileYOffset = 0; | ||
74 | |||
75 | // if our region isn't on the first Y section of the areas to be landscaped, then | ||
76 | // advance to our section of the file | ||
77 | while (currFileYOffset < offsetY) | ||
78 | { | ||
79 | // read a whole strip of regions | ||
80 | int heightsToRead = sectionHeight * (fileWidth * sectionWidth); | ||
81 | bs.ReadBytes(heightsToRead * 4); // because the floats are 4 bytes in the file | ||
82 | currFileYOffset++; | ||
83 | } | ||
84 | |||
85 | // got to the Y start offset within the file of our region | ||
86 | // so read the file bits associated with our region | ||
87 | int x, y; | ||
88 | // for each Y within our Y offset | ||
89 | for (y = 0; y < sectionHeight; y++) | ||
90 | { | ||
91 | currFileXOffset = 0; | ||
92 | |||
93 | // if our region isn't the first X section of the areas to be landscaped, then | ||
94 | // advance the stream to the X start pos of our section in the file | ||
95 | // i.e. eat X upto where we start | ||
96 | while (currFileXOffset < offsetX) | ||
97 | { | ||
98 | bs.ReadBytes(sectionWidth * 4); // 4 bytes = single | ||
99 | currFileXOffset++; | ||
100 | } | ||
101 | |||
102 | // got to our X offset, so write our regions X line | ||
103 | for (x = 0; x < sectionWidth; x++) | ||
104 | { | ||
105 | // Read a strip and continue | ||
106 | retval[x, y] = bs.ReadSingle(); | ||
107 | } | ||
108 | // record that we wrote it | ||
109 | currFileXOffset++; | ||
110 | |||
111 | // if our region isn't the last X section of the areas to be landscaped, then | ||
112 | // advance the stream to the end of this Y column | ||
113 | while (currFileXOffset < fileWidth) | ||
114 | { | ||
115 | // eat the next regions x line | ||
116 | bs.ReadBytes(sectionWidth * 4); // 4 bytes = single | ||
117 | currFileXOffset++; | ||
118 | } | ||
119 | } | ||
120 | |||
121 | bs.Close(); | ||
122 | s.Close(); | ||
123 | |||
124 | return retval; | ||
125 | } | ||
126 | |||
127 | public void SaveFile(string filename, ITerrainChannel map) | ||
128 | { | ||
129 | FileInfo file = new FileInfo(filename); | ||
130 | FileStream s = file.Open(FileMode.Create, FileAccess.Write); | ||
131 | BinaryWriter bs = new BinaryWriter(s); | ||
132 | |||
133 | int x, y; | ||
134 | for (y = 0; y < map.Height; y++) | ||
135 | { | ||
136 | for (x = 0; x < map.Width; x++) | ||
137 | { | ||
138 | bs.Write((float) map[x, y]); | ||
139 | } | ||
140 | } | ||
141 | |||
142 | bs.Close(); | ||
143 | s.Close(); | ||
144 | } | ||
145 | |||
146 | #endregion | ||
147 | |||
148 | public override string ToString() | ||
149 | { | ||
150 | return "RAW32"; | ||
151 | } | ||
152 | } | ||
153 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/TIFF.cs b/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/TIFF.cs deleted file mode 100644 index 39c2428..0000000 --- a/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/TIFF.cs +++ /dev/null | |||
@@ -1,47 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | using System.Drawing; | ||
28 | using System.Drawing.Imaging; | ||
29 | using OpenSim.Region.Environment.Interfaces; | ||
30 | |||
31 | namespace OpenSim.Region.Environment.Modules.Terrain.FileLoaders | ||
32 | { | ||
33 | internal class TIFF : GenericSystemDrawing | ||
34 | { | ||
35 | public override void SaveFile(string filename, ITerrainChannel map) | ||
36 | { | ||
37 | Bitmap colours = CreateGrayscaleBitmapFromMap(map); | ||
38 | |||
39 | colours.Save(filename, ImageFormat.Tiff); | ||
40 | } | ||
41 | |||
42 | public override string ToString() | ||
43 | { | ||
44 | return "TIFF"; | ||
45 | } | ||
46 | } | ||
47 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/Terragen.cs b/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/Terragen.cs deleted file mode 100644 index 2a4a8f8..0000000 --- a/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/Terragen.cs +++ /dev/null | |||
@@ -1,127 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.IO; | ||
30 | using System.Text; | ||
31 | using OpenSim.Region.Environment.Interfaces; | ||
32 | |||
33 | namespace OpenSim.Region.Environment.Modules.Terrain.FileLoaders | ||
34 | { | ||
35 | /// <summary> | ||
36 | /// Terragen File Format Loader | ||
37 | /// Built from specification at | ||
38 | /// http://www.planetside.co.uk/terragen/dev/tgterrain.html | ||
39 | /// </summary> | ||
40 | internal class Terragen : ITerrainLoader | ||
41 | { | ||
42 | #region ITerrainLoader Members | ||
43 | |||
44 | public ITerrainChannel LoadFile(string filename) | ||
45 | { | ||
46 | TerrainChannel retval = new TerrainChannel(); | ||
47 | |||
48 | FileInfo file = new FileInfo(filename); | ||
49 | FileStream s = file.Open(FileMode.Open, FileAccess.Read); | ||
50 | BinaryReader bs = new BinaryReader(s); | ||
51 | |||
52 | bool eof = false; | ||
53 | if (ASCIIEncoding.ASCII.GetString(bs.ReadBytes(16)) == "TERRAGENTERRAIN ") | ||
54 | { | ||
55 | // Terragen file | ||
56 | while (eof == false) | ||
57 | { | ||
58 | int w = 256; | ||
59 | int h = 256; | ||
60 | string tmp = ASCIIEncoding.ASCII.GetString(bs.ReadBytes(4)); | ||
61 | switch (tmp) | ||
62 | { | ||
63 | case "SIZE": | ||
64 | int sztmp = bs.ReadInt16() + 1; | ||
65 | w = sztmp; | ||
66 | h = sztmp; | ||
67 | bs.ReadInt16(); | ||
68 | break; | ||
69 | case "XPTS": | ||
70 | w = bs.ReadInt16(); | ||
71 | bs.ReadInt16(); | ||
72 | break; | ||
73 | case "YPTS": | ||
74 | h = bs.ReadInt16(); | ||
75 | bs.ReadInt16(); | ||
76 | break; | ||
77 | case "ALTW": | ||
78 | eof = true; | ||
79 | Int16 heightScale = bs.ReadInt16(); | ||
80 | Int16 baseHeight = bs.ReadInt16(); | ||
81 | retval = new TerrainChannel(w, h); | ||
82 | int x, y; | ||
83 | for (x = 0; x < w; x++) | ||
84 | { | ||
85 | for (y = 0; y < h; y++) | ||
86 | { | ||
87 | retval[x, y] = (double) baseHeight + (double) bs.ReadInt16() * (double) heightScale / 65536.0; | ||
88 | } | ||
89 | } | ||
90 | break; | ||
91 | default: | ||
92 | bs.ReadInt32(); | ||
93 | break; | ||
94 | } | ||
95 | } | ||
96 | } | ||
97 | |||
98 | bs.Close(); | ||
99 | s.Close(); | ||
100 | |||
101 | return retval; | ||
102 | } | ||
103 | |||
104 | public void SaveFile(string filename, ITerrainChannel map) | ||
105 | { | ||
106 | char[] header = "TERRAGENTERRAIN".ToCharArray(); | ||
107 | throw new NotImplementedException(); | ||
108 | } | ||
109 | |||
110 | public string FileExtension | ||
111 | { | ||
112 | get { return ".ter"; } | ||
113 | } | ||
114 | |||
115 | public ITerrainChannel LoadFile(string filename, int x, int y, int fileWidth, int fileHeight, int w, int h) | ||
116 | { | ||
117 | throw new NotImplementedException(); | ||
118 | } | ||
119 | |||
120 | #endregion | ||
121 | |||
122 | public override string ToString() | ||
123 | { | ||
124 | return "Terragen"; | ||
125 | } | ||
126 | } | ||
127 | } \ No newline at end of file | ||