aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/Terrain/FileLoaders
diff options
context:
space:
mode:
authorJeff Ames2008-03-03 09:29:21 +0000
committerJeff Ames2008-03-03 09:29:21 +0000
commitd50eb9d2b3f210da32440746451e98b57388c9cd (patch)
tree01f8a47dccac35f82e59ae78dcd61c9f65e7a16d /OpenSim/Region/Environment/Modules/Terrain/FileLoaders
parentFixed typo. (diff)
downloadopensim-SC_OLD-d50eb9d2b3f210da32440746451e98b57388c9cd.zip
opensim-SC_OLD-d50eb9d2b3f210da32440746451e98b57388c9cd.tar.gz
opensim-SC_OLD-d50eb9d2b3f210da32440746451e98b57388c9cd.tar.bz2
opensim-SC_OLD-d50eb9d2b3f210da32440746451e98b57388c9cd.tar.xz
Updated svn properties.
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Terrain/FileLoaders')
-rw-r--r--OpenSim/Region/Environment/Modules/Terrain/FileLoaders/JPEG.cs156
-rw-r--r--OpenSim/Region/Environment/Modules/Terrain/FileLoaders/LLRAW.cs264
2 files changed, 210 insertions, 210 deletions
diff --git a/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/JPEG.cs b/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/JPEG.cs
index 20e5277..79d6840 100644
--- a/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/JPEG.cs
+++ b/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/JPEG.cs
@@ -1,79 +1,79 @@
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*/
28using System; 28using System;
29using System.IO; 29using System.IO;
30using System.Drawing; 30using System.Drawing;
31using OpenSim.Region.Environment.Interfaces; 31using OpenSim.Region.Environment.Interfaces;
32 32
33namespace OpenSim.Region.Environment.Modules.Terrain.FileLoaders 33namespace OpenSim.Region.Environment.Modules.Terrain.FileLoaders
34{ 34{
35 public class JPEG : ITerrainLoader 35 public class JPEG : ITerrainLoader
36 { 36 {
37 #region ITerrainLoader Members 37 #region ITerrainLoader Members
38 38
39 public ITerrainChannel LoadFile(string filename) 39 public ITerrainChannel LoadFile(string filename)
40 { 40 {
41 throw new NotImplementedException(); 41 throw new NotImplementedException();
42 } 42 }
43 43
44 private Bitmap CreateBitmapFromMap(ITerrainChannel map) 44 private Bitmap CreateBitmapFromMap(ITerrainChannel map)
45 { 45 {
46 Bitmap gradientmapLd = new Bitmap("defaultstripe.png"); 46 Bitmap gradientmapLd = new Bitmap("defaultstripe.png");
47 47
48 int pallete = gradientmapLd.Height; 48 int pallete = gradientmapLd.Height;
49 49
50 Bitmap bmp = new Bitmap(map.Width, map.Height); 50 Bitmap bmp = new Bitmap(map.Width, map.Height);
51 Color[] colours = new Color[pallete]; 51 Color[] colours = new Color[pallete];
52 52
53 for (int i = 0; i < pallete; i++) 53 for (int i = 0; i < pallete; i++)
54 { 54 {
55 colours[i] = gradientmapLd.GetPixel(0, i); 55 colours[i] = gradientmapLd.GetPixel(0, i);
56 } 56 }
57 57
58 for (int y = 0; y < map.Height; y++) 58 for (int y = 0; y < map.Height; y++)
59 { 59 {
60 for (int x = 0; x < map.Width; x++) 60 for (int x = 0; x < map.Width; x++)
61 { 61 {
62 // 512 is the largest possible height before colours clamp 62 // 512 is the largest possible height before colours clamp
63 int colorindex = (int)(Math.Max(Math.Min(1.0, map[x, y] / 512.0), 0.0) * (pallete - 1)); 63 int colorindex = (int)(Math.Max(Math.Min(1.0, map[x, y] / 512.0), 0.0) * (pallete - 1));
64 bmp.SetPixel(x, map.Height - y - 1, colours[colorindex]); 64 bmp.SetPixel(x, map.Height - y - 1, colours[colorindex]);
65 } 65 }
66 } 66 }
67 return bmp; 67 return bmp;
68 } 68 }
69 69
70 public void SaveFile(string filename, ITerrainChannel map) 70 public void SaveFile(string filename, ITerrainChannel map)
71 { 71 {
72 Bitmap colours = CreateBitmapFromMap(map); 72 Bitmap colours = CreateBitmapFromMap(map);
73 73
74 colours.Save(filename, System.Drawing.Imaging.ImageFormat.Jpeg); 74 colours.Save(filename, System.Drawing.Imaging.ImageFormat.Jpeg);
75 } 75 }
76 76
77 #endregion 77 #endregion
78 } 78 }
79} \ No newline at end of file 79} \ 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
index 58dc6c7..64f8751 100644
--- a/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/LLRAW.cs
+++ b/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/LLRAW.cs
@@ -1,132 +1,132 @@
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*/
28using System; 28using System;
29using System.IO; 29using System.IO;
30using OpenSim.Region.Environment.Interfaces; 30using OpenSim.Region.Environment.Interfaces;
31 31
32namespace OpenSim.Region.Environment.Modules.Terrain.FileLoaders 32namespace OpenSim.Region.Environment.Modules.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 void SaveFile(string filename, ITerrainChannel map) 61 public void SaveFile(string filename, ITerrainChannel map)
62 { 62 {
63 FileInfo file = new FileInfo(filename); 63 FileInfo file = new FileInfo(filename);
64 FileStream s = file.Open(FileMode.CreateNew, FileAccess.Write); 64 FileStream s = file.Open(FileMode.CreateNew, FileAccess.Write);
65 BinaryWriter binStream = new BinaryWriter(s); 65 BinaryWriter binStream = new BinaryWriter(s);
66 66
67 // Generate a smegging big lookup table to speed the operation up (it needs it) 67 // Generate a smegging big lookup table to speed the operation up (it needs it)
68 double[] lookupHeightTable = new double[65536]; 68 double[] lookupHeightTable = new double[65536];
69 int i, j, x, y; 69 int i, j, x, y;
70 for (i = 0; i < 256; i++) 70 for (i = 0; i < 256; i++)
71 { 71 {
72 for (j = 0; j < 256; j++) 72 for (j = 0; j < 256; j++)
73 { 73 {
74 lookupHeightTable[i + (j * 256)] = ((double)i * ((double)j / 127.0)); 74 lookupHeightTable[i + (j * 256)] = ((double)i * ((double)j / 127.0));
75 } 75 }
76 } 76 }
77 77
78 // Output the calculated raw 78 // Output the calculated raw
79 for (y = 0; y < map.Height; y++) 79 for (y = 0; y < map.Height; y++)
80 { 80 {
81 for (x = 0; x < map.Width; x++) 81 for (x = 0; x < map.Width; x++)
82 { 82 {
83 double t = map[x, y]; 83 double t = map[x, y];
84 double min = double.MaxValue; 84 double min = double.MaxValue;
85 int index = 0; 85 int index = 0;
86 86
87 for (i = 0; i < 65536; i++) 87 for (i = 0; i < 65536; i++)
88 { 88 {
89 if (Math.Abs(t - lookupHeightTable[i]) < min) 89 if (Math.Abs(t - lookupHeightTable[i]) < min)
90 { 90 {
91 min = Math.Abs(t - lookupHeightTable[i]); 91 min = Math.Abs(t - lookupHeightTable[i]);
92 index = i; 92 index = i;
93 } 93 }
94 } 94 }
95 95
96 byte red = (byte)(index & 0xFF); 96 byte red = (byte)(index & 0xFF);
97 byte green = (byte)((index >> 8) & 0xFF); 97 byte green = (byte)((index >> 8) & 0xFF);
98 byte blue = 20; 98 byte blue = 20;
99 byte alpha1 = 0; // Land Parcels 99 byte alpha1 = 0; // Land Parcels
100 byte alpha2 = 0; // For Sale Land 100 byte alpha2 = 0; // For Sale Land
101 byte alpha3 = 0; // Public Edit Object 101 byte alpha3 = 0; // Public Edit Object
102 byte alpha4 = 0; // Public Edit Land 102 byte alpha4 = 0; // Public Edit Land
103 byte alpha5 = 255; // Safe Land 103 byte alpha5 = 255; // Safe Land
104 byte alpha6 = 255; // Flying Allowed 104 byte alpha6 = 255; // Flying Allowed
105 byte alpha7 = 255; // Create Landmark 105 byte alpha7 = 255; // Create Landmark
106 byte alpha8 = 255; // Outside Scripts 106 byte alpha8 = 255; // Outside Scripts
107 byte alpha9 = red; 107 byte alpha9 = red;
108 byte alpha10 = green; 108 byte alpha10 = green;
109 109
110 binStream.Write(red); 110 binStream.Write(red);
111 binStream.Write(green); 111 binStream.Write(green);
112 binStream.Write(blue); 112 binStream.Write(blue);
113 binStream.Write(alpha1); 113 binStream.Write(alpha1);
114 binStream.Write(alpha2); 114 binStream.Write(alpha2);
115 binStream.Write(alpha3); 115 binStream.Write(alpha3);
116 binStream.Write(alpha4); 116 binStream.Write(alpha4);
117 binStream.Write(alpha5); 117 binStream.Write(alpha5);
118 binStream.Write(alpha6); 118 binStream.Write(alpha6);
119 binStream.Write(alpha7); 119 binStream.Write(alpha7);
120 binStream.Write(alpha8); 120 binStream.Write(alpha8);
121 binStream.Write(alpha9); 121 binStream.Write(alpha9);
122 binStream.Write(alpha10); 122 binStream.Write(alpha10);
123 } 123 }
124 } 124 }
125 125
126 binStream.Close(); 126 binStream.Close();
127 s.Close(); 127 s.Close();
128 } 128 }
129 129
130 #endregion 130 #endregion
131 } 131 }
132} 132}