diff options
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Terrain/FileLoaders/Terragen.cs')
-rw-r--r-- | OpenSim/Region/Environment/Modules/Terrain/FileLoaders/Terragen.cs | 127 |
1 files changed, 0 insertions, 127 deletions
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 | ||