diff options
Diffstat (limited to 'OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/Terragen.cs')
-rw-r--r-- | OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/Terragen.cs | 142 |
1 files changed, 0 insertions, 142 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/Terragen.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/Terragen.cs deleted file mode 100644 index 44d03e3..0000000 --- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/Terragen.cs +++ /dev/null | |||
@@ -1,142 +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.Framework.Interfaces; | ||
32 | using OpenSim.Region.Framework.Scenes; | ||
33 | |||
34 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders | ||
35 | { | ||
36 | /// <summary> | ||
37 | /// Terragen File Format Loader | ||
38 | /// Built from specification at | ||
39 | /// http://www.planetside.co.uk/terragen/dev/tgterrain.html | ||
40 | /// </summary> | ||
41 | internal class Terragen : ITerrainLoader | ||
42 | { | ||
43 | #region ITerrainLoader Members | ||
44 | |||
45 | public ITerrainChannel LoadFile(string filename) | ||
46 | { | ||
47 | FileInfo file = new FileInfo(filename); | ||
48 | FileStream s = file.Open(FileMode.Open, FileAccess.Read); | ||
49 | ITerrainChannel retval = LoadStream(s); | ||
50 | |||
51 | s.Close(); | ||
52 | |||
53 | return retval; | ||
54 | } | ||
55 | |||
56 | public ITerrainChannel LoadStream(Stream s) | ||
57 | { | ||
58 | TerrainChannel retval = new TerrainChannel(); | ||
59 | |||
60 | BinaryReader bs = new BinaryReader(s); | ||
61 | |||
62 | bool eof = false; | ||
63 | if (Encoding.ASCII.GetString(bs.ReadBytes(16)) == "TERRAGENTERRAIN ") | ||
64 | { | ||
65 | int w = 256; | ||
66 | int h = 256; | ||
67 | |||
68 | // Terragen file | ||
69 | while (eof == false) | ||
70 | { | ||
71 | string tmp = Encoding.ASCII.GetString(bs.ReadBytes(4)); | ||
72 | switch (tmp) | ||
73 | { | ||
74 | case "SIZE": | ||
75 | int sztmp = bs.ReadInt16() + 1; | ||
76 | w = sztmp; | ||
77 | h = sztmp; | ||
78 | bs.ReadInt16(); | ||
79 | break; | ||
80 | case "XPTS": | ||
81 | w = bs.ReadInt16(); | ||
82 | bs.ReadInt16(); | ||
83 | break; | ||
84 | case "YPTS": | ||
85 | h = bs.ReadInt16(); | ||
86 | bs.ReadInt16(); | ||
87 | break; | ||
88 | case "ALTW": | ||
89 | eof = true; | ||
90 | Int16 heightScale = bs.ReadInt16(); | ||
91 | Int16 baseHeight = bs.ReadInt16(); | ||
92 | retval = new TerrainChannel(w, h); | ||
93 | int x; | ||
94 | for (x = 0; x < w; x++) | ||
95 | { | ||
96 | int y; | ||
97 | for (y = 0; y < h; y++) | ||
98 | { | ||
99 | retval[x, y] = baseHeight + bs.ReadInt16() * (double) heightScale / 65536.0; | ||
100 | } | ||
101 | } | ||
102 | break; | ||
103 | default: | ||
104 | bs.ReadInt32(); | ||
105 | break; | ||
106 | } | ||
107 | } | ||
108 | } | ||
109 | |||
110 | bs.Close(); | ||
111 | |||
112 | return retval; | ||
113 | } | ||
114 | |||
115 | public void SaveFile(string filename, ITerrainChannel map) | ||
116 | { | ||
117 | throw new NotImplementedException(); | ||
118 | } | ||
119 | |||
120 | public void SaveStream(Stream stream, ITerrainChannel map) | ||
121 | { | ||
122 | throw new NotImplementedException(); | ||
123 | } | ||
124 | |||
125 | public string FileExtension | ||
126 | { | ||
127 | get { return ".ter"; } | ||
128 | } | ||
129 | |||
130 | public ITerrainChannel LoadFile(string filename, int x, int y, int fileWidth, int fileHeight, int w, int h) | ||
131 | { | ||
132 | throw new NotImplementedException(); | ||
133 | } | ||
134 | |||
135 | #endregion | ||
136 | |||
137 | public override string ToString() | ||
138 | { | ||
139 | return "Terragen"; | ||
140 | } | ||
141 | } | ||
142 | } | ||