aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/Terragen.cs
diff options
context:
space:
mode:
authorAdam Frisby2008-04-30 21:16:36 +0000
committerAdam Frisby2008-04-30 21:16:36 +0000
commitf5c312bc3c2567449c7268a54a08a54119f58d53 (patch)
tree424668a4bbec6873ebc5b8256f3671db102f5e9c /OpenSim/Region/Environment/Modules/Terrain/FileLoaders/Terragen.cs
parent* Adds the AuthbuyerID field to sqlite and makes use of it. (diff)
downloadopensim-SC_OLD-f5c312bc3c2567449c7268a54a08a54119f58d53.zip
opensim-SC_OLD-f5c312bc3c2567449c7268a54a08a54119f58d53.tar.gz
opensim-SC_OLD-f5c312bc3c2567449c7268a54a08a54119f58d53.tar.bz2
opensim-SC_OLD-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 '')
-rw-r--r--OpenSim/Region/Environment/Modules/Terrain/FileLoaders/Terragen.cs127
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
28using System;
29using System.IO;
30using System.Text;
31using OpenSim.Region.Environment.Interfaces;
32
33namespace 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