diff options
author | Jeff Ames | 2008-05-01 14:31:30 +0000 |
---|---|---|
committer | Jeff Ames | 2008-05-01 14:31:30 +0000 |
commit | d51ce47b2d7635b17f3dd429158e8f59b78b83aa (patch) | |
tree | d3595bd5194199184059aa398b91a51dc6c799cf /OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/LLRAW.cs | |
parent | * Looks like I had the bamboo build right in the first place - it was just th... (diff) | |
download | opensim-SC-d51ce47b2d7635b17f3dd429158e8f59b78b83aa.zip opensim-SC-d51ce47b2d7635b17f3dd429158e8f59b78b83aa.tar.gz opensim-SC-d51ce47b2d7635b17f3dd429158e8f59b78b83aa.tar.bz2 opensim-SC-d51ce47b2d7635b17f3dd429158e8f59b78b83aa.tar.xz |
Update svn properties. Minor formatting cleanup.
Diffstat (limited to 'OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/LLRAW.cs')
-rw-r--r-- | OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/LLRAW.cs | 294 |
1 files changed, 147 insertions, 147 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/LLRAW.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/LLRAW.cs index 468ecc9..5d6723f 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/LLRAW.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/LLRAW.cs | |||
@@ -1,148 +1,148 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 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 | 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 | 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 | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.IO; | 29 | using System.IO; |
30 | using OpenSim.Region.Environment.Interfaces; | 30 | using OpenSim.Region.Environment.Interfaces; |
31 | 31 | ||
32 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders | 32 | namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders |
33 | { | 33 | { |
34 | public class LLRAW : ITerrainLoader | 34 | public class LLRAW : ITerrainLoader |
35 | { | 35 | { |
36 | #region ITerrainLoader Members | 36 | #region ITerrainLoader Members |
37 | 37 | ||
38 | public ITerrainChannel LoadFile(string filename) | 38 | public ITerrainChannel LoadFile(string filename) |
39 | { | 39 | { |
40 | TerrainChannel retval = new TerrainChannel(); | 40 | TerrainChannel retval = new TerrainChannel(); |
41 | 41 | ||
42 | FileInfo file = new FileInfo(filename); | 42 | FileInfo file = new FileInfo(filename); |
43 | FileStream s = file.Open(FileMode.Open, FileAccess.Read); | 43 | FileStream s = file.Open(FileMode.Open, FileAccess.Read); |
44 | BinaryReader bs = new BinaryReader(s); | 44 | BinaryReader bs = new BinaryReader(s); |
45 | int x, y; | 45 | int x, y; |
46 | for (y = 0; y < retval.Height; y++) | 46 | for (y = 0; y < retval.Height; y++) |
47 | { | 47 | { |
48 | for (x = 0; x < retval.Width; x++) | 48 | for (x = 0; x < retval.Width; x++) |
49 | { | 49 | { |
50 | retval[x, y] = (double) bs.ReadByte() * ((double) bs.ReadByte() / 127.0); | 50 | retval[x, y] = (double) bs.ReadByte() * ((double) bs.ReadByte() / 127.0); |
51 | bs.ReadBytes(11); // Advance the stream to next bytes. | 51 | bs.ReadBytes(11); // Advance the stream to next bytes. |
52 | } | 52 | } |
53 | } | 53 | } |
54 | 54 | ||
55 | bs.Close(); | 55 | bs.Close(); |
56 | s.Close(); | 56 | s.Close(); |
57 | 57 | ||
58 | return retval; | 58 | return retval; |
59 | } | 59 | } |
60 | 60 | ||
61 | public ITerrainChannel LoadFile(string filename, int x, int y, int fileWidth, int fileHeight, int w, int h) | 61 | public ITerrainChannel LoadFile(string filename, int x, int y, int fileWidth, int fileHeight, int w, int h) |
62 | { | 62 | { |
63 | throw new NotImplementedException(); | 63 | throw new NotImplementedException(); |
64 | } | 64 | } |
65 | 65 | ||
66 | public void SaveFile(string filename, ITerrainChannel map) | 66 | public void SaveFile(string filename, ITerrainChannel map) |
67 | { | 67 | { |
68 | FileInfo file = new FileInfo(filename); | 68 | FileInfo file = new FileInfo(filename); |
69 | FileStream s = file.Open(FileMode.CreateNew, FileAccess.Write); | 69 | FileStream s = file.Open(FileMode.CreateNew, FileAccess.Write); |
70 | BinaryWriter binStream = new BinaryWriter(s); | 70 | BinaryWriter binStream = new BinaryWriter(s); |
71 | 71 | ||
72 | // Generate a smegging big lookup table to speed the operation up (it needs it) | 72 | // Generate a smegging big lookup table to speed the operation up (it needs it) |
73 | double[] lookupHeightTable = new double[65536]; | 73 | double[] lookupHeightTable = new double[65536]; |
74 | int i, j, x, y; | 74 | int i, j, x, y; |
75 | for (i = 0; i < 256; i++) | 75 | for (i = 0; i < 256; i++) |
76 | { | 76 | { |
77 | for (j = 0; j < 256; j++) | 77 | for (j = 0; j < 256; j++) |
78 | { | 78 | { |
79 | lookupHeightTable[i + (j * 256)] = ((double) i * ((double) j / 127.0)); | 79 | lookupHeightTable[i + (j * 256)] = ((double) i * ((double) j / 127.0)); |
80 | } | 80 | } |
81 | } | 81 | } |
82 | 82 | ||
83 | // Output the calculated raw | 83 | // Output the calculated raw |
84 | for (y = 0; y < map.Height; y++) | 84 | for (y = 0; y < map.Height; y++) |
85 | { | 85 | { |
86 | for (x = 0; x < map.Width; x++) | 86 | for (x = 0; x < map.Width; x++) |
87 | { | 87 | { |
88 | double t = map[x, y]; | 88 | double t = map[x, y]; |
89 | double min = double.MaxValue; | 89 | double min = double.MaxValue; |
90 | int index = 0; | 90 | int index = 0; |
91 | 91 | ||
92 | for (i = 0; i < 65536; i++) | 92 | for (i = 0; i < 65536; i++) |
93 | { | 93 | { |
94 | if (Math.Abs(t - lookupHeightTable[i]) < min) | 94 | if (Math.Abs(t - lookupHeightTable[i]) < min) |
95 | { | 95 | { |
96 | min = Math.Abs(t - lookupHeightTable[i]); | 96 | min = Math.Abs(t - lookupHeightTable[i]); |
97 | index = i; | 97 | index = i; |
98 | } | 98 | } |
99 | } | 99 | } |
100 | 100 | ||
101 | byte red = (byte) (index & 0xFF); | 101 | byte red = (byte) (index & 0xFF); |
102 | byte green = (byte) ((index >> 8) & 0xFF); | 102 | byte green = (byte) ((index >> 8) & 0xFF); |
103 | byte blue = 20; | 103 | byte blue = 20; |
104 | byte alpha1 = 0; // Land Parcels | 104 | byte alpha1 = 0; // Land Parcels |
105 | byte alpha2 = 0; // For Sale Land | 105 | byte alpha2 = 0; // For Sale Land |
106 | byte alpha3 = 0; // Public Edit Object | 106 | byte alpha3 = 0; // Public Edit Object |
107 | byte alpha4 = 0; // Public Edit Land | 107 | byte alpha4 = 0; // Public Edit Land |
108 | byte alpha5 = 255; // Safe Land | 108 | byte alpha5 = 255; // Safe Land |
109 | byte alpha6 = 255; // Flying Allowed | 109 | byte alpha6 = 255; // Flying Allowed |
110 | byte alpha7 = 255; // Create Landmark | 110 | byte alpha7 = 255; // Create Landmark |
111 | byte alpha8 = 255; // Outside Scripts | 111 | byte alpha8 = 255; // Outside Scripts |
112 | byte alpha9 = red; | 112 | byte alpha9 = red; |
113 | byte alpha10 = green; | 113 | byte alpha10 = green; |
114 | 114 | ||
115 | binStream.Write(red); | 115 | binStream.Write(red); |
116 | binStream.Write(green); | 116 | binStream.Write(green); |
117 | binStream.Write(blue); | 117 | binStream.Write(blue); |
118 | binStream.Write(alpha1); | 118 | binStream.Write(alpha1); |
119 | binStream.Write(alpha2); | 119 | binStream.Write(alpha2); |
120 | binStream.Write(alpha3); | 120 | binStream.Write(alpha3); |
121 | binStream.Write(alpha4); | 121 | binStream.Write(alpha4); |
122 | binStream.Write(alpha5); | 122 | binStream.Write(alpha5); |
123 | binStream.Write(alpha6); | 123 | binStream.Write(alpha6); |
124 | binStream.Write(alpha7); | 124 | binStream.Write(alpha7); |
125 | binStream.Write(alpha8); | 125 | binStream.Write(alpha8); |
126 | binStream.Write(alpha9); | 126 | binStream.Write(alpha9); |
127 | binStream.Write(alpha10); | 127 | binStream.Write(alpha10); |
128 | } | 128 | } |
129 | } | 129 | } |
130 | 130 | ||
131 | binStream.Close(); | 131 | binStream.Close(); |
132 | s.Close(); | 132 | s.Close(); |
133 | } | 133 | } |
134 | 134 | ||
135 | 135 | ||
136 | public string FileExtension | 136 | public string FileExtension |
137 | { | 137 | { |
138 | get { return ".raw"; } | 138 | get { return ".raw"; } |
139 | } | 139 | } |
140 | 140 | ||
141 | #endregion | 141 | #endregion |
142 | 142 | ||
143 | public override string ToString() | 143 | public override string ToString() |
144 | { | 144 | { |
145 | return "LL/SL RAW"; | 145 | return "LL/SL RAW"; |
146 | } | 146 | } |
147 | } | 147 | } |
148 | } \ No newline at end of file | 148 | } \ No newline at end of file |