diff options
Diffstat (limited to 'OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders')
5 files changed, 38 insertions, 30 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GenericSystemDrawing.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GenericSystemDrawing.cs index 9730b16..484bb89 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GenericSystemDrawing.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GenericSystemDrawing.cs | |||
@@ -61,9 +61,10 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders | |||
61 | 61 | ||
62 | ITerrainChannel retval = new TerrainChannel(file.Width, file.Height); | 62 | ITerrainChannel retval = new TerrainChannel(file.Width, file.Height); |
63 | 63 | ||
64 | int x, y; | 64 | int x; |
65 | for (x = 0; x < file.Width; x++) | 65 | for (x = 0; x < file.Width; x++) |
66 | { | 66 | { |
67 | int y; | ||
67 | for (y = 0; y < file.Height; y++) | 68 | for (y = 0; y < file.Height; y++) |
68 | { | 69 | { |
69 | retval[x, y] = file.GetPixel(x, y).GetBrightness() * 128; | 70 | retval[x, y] = file.GetPixel(x, y).GetBrightness() * 128; |
@@ -103,11 +104,11 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders | |||
103 | /// </summary> | 104 | /// </summary> |
104 | /// <param name="map">The terrain channel to export to bitmap</param> | 105 | /// <param name="map">The terrain channel to export to bitmap</param> |
105 | /// <returns>A System.Drawing.Bitmap containing a grayscale image</returns> | 106 | /// <returns>A System.Drawing.Bitmap containing a grayscale image</returns> |
106 | protected Bitmap CreateGrayscaleBitmapFromMap(ITerrainChannel map) | 107 | protected static Bitmap CreateGrayscaleBitmapFromMap(ITerrainChannel map) |
107 | { | 108 | { |
108 | Bitmap bmp = new Bitmap(map.Width, map.Height); | 109 | Bitmap bmp = new Bitmap(map.Width, map.Height); |
109 | 110 | ||
110 | int pallete = 256; | 111 | const int pallete = 256; |
111 | 112 | ||
112 | Color[] grays = new Color[pallete]; | 113 | Color[] grays = new Color[pallete]; |
113 | for (int i = 0; i < grays.Length; i++) | 114 | for (int i = 0; i < grays.Length; i++) |
@@ -138,7 +139,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders | |||
138 | /// </summary> | 139 | /// </summary> |
139 | /// <param name="map">The terrain channel to export to bitmap</param> | 140 | /// <param name="map">The terrain channel to export to bitmap</param> |
140 | /// <returns>A System.Drawing.Bitmap containing a coloured image</returns> | 141 | /// <returns>A System.Drawing.Bitmap containing a coloured image</returns> |
141 | protected Bitmap CreateBitmapFromMap(ITerrainChannel map) | 142 | protected static Bitmap CreateBitmapFromMap(ITerrainChannel map) |
142 | { | 143 | { |
143 | Bitmap gradientmapLd = new Bitmap("defaultstripe.png"); | 144 | Bitmap gradientmapLd = new Bitmap("defaultstripe.png"); |
144 | 145 | ||
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/JPEG.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/JPEG.cs index d58926e..628c201 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/JPEG.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/JPEG.cs | |||
@@ -65,7 +65,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders | |||
65 | return "JPEG"; | 65 | return "JPEG"; |
66 | } | 66 | } |
67 | 67 | ||
68 | private Bitmap CreateBitmapFromMap(ITerrainChannel map) | 68 | private static Bitmap CreateBitmapFromMap(ITerrainChannel map) |
69 | { | 69 | { |
70 | Bitmap gradientmapLd = new Bitmap("defaultstripe.png"); | 70 | Bitmap gradientmapLd = new Bitmap("defaultstripe.png"); |
71 | 71 | ||
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/LLRAW.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/LLRAW.cs index 5d6723f..1f6208c 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/LLRAW.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/LLRAW.cs | |||
@@ -42,12 +42,13 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders | |||
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 y; |
46 | for (y = 0; y < retval.Height; y++) | 46 | for (y = 0; y < retval.Height; y++) |
47 | { | 47 | { |
48 | int x; | ||
48 | for (x = 0; x < retval.Width; x++) | 49 | for (x = 0; x < retval.Width; x++) |
49 | { | 50 | { |
50 | retval[x, y] = (double) bs.ReadByte() * ((double) bs.ReadByte() / 127.0); | 51 | retval[x, y] = bs.ReadByte() * (bs.ReadByte() / 127.0); |
51 | bs.ReadBytes(11); // Advance the stream to next bytes. | 52 | bs.ReadBytes(11); // Advance the stream to next bytes. |
52 | } | 53 | } |
53 | } | 54 | } |
@@ -71,18 +72,21 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders | |||
71 | 72 | ||
72 | // Generate a smegging big lookup table to speed the operation up (it needs it) | 73 | // Generate a smegging big lookup table to speed the operation up (it needs it) |
73 | double[] lookupHeightTable = new double[65536]; | 74 | double[] lookupHeightTable = new double[65536]; |
74 | int i, j, x, y; | 75 | int i; |
76 | int y; | ||
75 | for (i = 0; i < 256; i++) | 77 | for (i = 0; i < 256; i++) |
76 | { | 78 | { |
79 | int j; | ||
77 | for (j = 0; j < 256; j++) | 80 | for (j = 0; j < 256; j++) |
78 | { | 81 | { |
79 | lookupHeightTable[i + (j * 256)] = ((double) i * ((double) j / 127.0)); | 82 | lookupHeightTable[i + (j * 256)] = (i * (j / 127.0)); |
80 | } | 83 | } |
81 | } | 84 | } |
82 | 85 | ||
83 | // Output the calculated raw | 86 | // Output the calculated raw |
84 | for (y = 0; y < map.Height; y++) | 87 | for (y = 0; y < map.Height; y++) |
85 | { | 88 | { |
89 | int x; | ||
86 | for (x = 0; x < map.Width; x++) | 90 | for (x = 0; x < map.Width; x++) |
87 | { | 91 | { |
88 | double t = map[x, y]; | 92 | double t = map[x, y]; |
@@ -100,15 +104,15 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders | |||
100 | 104 | ||
101 | byte red = (byte) (index & 0xFF); | 105 | byte red = (byte) (index & 0xFF); |
102 | byte green = (byte) ((index >> 8) & 0xFF); | 106 | byte green = (byte) ((index >> 8) & 0xFF); |
103 | byte blue = 20; | 107 | const byte blue = 20; |
104 | byte alpha1 = 0; // Land Parcels | 108 | const byte alpha1 = 0; |
105 | byte alpha2 = 0; // For Sale Land | 109 | const byte alpha2 = 0; |
106 | byte alpha3 = 0; // Public Edit Object | 110 | const byte alpha3 = 0; |
107 | byte alpha4 = 0; // Public Edit Land | 111 | const byte alpha4 = 0; |
108 | byte alpha5 = 255; // Safe Land | 112 | const byte alpha5 = 255; |
109 | byte alpha6 = 255; // Flying Allowed | 113 | const byte alpha6 = 255; |
110 | byte alpha7 = 255; // Create Landmark | 114 | const byte alpha7 = 255; |
111 | byte alpha8 = 255; // Outside Scripts | 115 | const byte alpha8 = 255; |
112 | byte alpha9 = red; | 116 | byte alpha9 = red; |
113 | byte alpha10 = green; | 117 | byte alpha10 = green; |
114 | 118 | ||
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/RAW32.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/RAW32.cs index fd2136c..689abcf 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/RAW32.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/RAW32.cs | |||
@@ -46,9 +46,10 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders | |||
46 | FileInfo file = new FileInfo(filename); | 46 | FileInfo file = new FileInfo(filename); |
47 | FileStream s = file.Open(FileMode.Open, FileAccess.Read); | 47 | FileStream s = file.Open(FileMode.Open, FileAccess.Read); |
48 | BinaryReader bs = new BinaryReader(s); | 48 | BinaryReader bs = new BinaryReader(s); |
49 | int x, y; | 49 | int y; |
50 | for (y = 0; y < retval.Height; y++) | 50 | for (y = 0; y < retval.Height; y++) |
51 | { | 51 | { |
52 | int x; | ||
52 | for (x = 0; x < retval.Width; x++) | 53 | for (x = 0; x < retval.Width; x++) |
53 | { | 54 | { |
54 | retval[x, y] = bs.ReadSingle(); | 55 | retval[x, y] = bs.ReadSingle(); |
@@ -69,7 +70,6 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders | |||
69 | FileStream s = file.Open(FileMode.Open, FileAccess.Read); | 70 | FileStream s = file.Open(FileMode.Open, FileAccess.Read); |
70 | BinaryReader bs = new BinaryReader(s); | 71 | BinaryReader bs = new BinaryReader(s); |
71 | 72 | ||
72 | int currFileXOffset = 0; | ||
73 | int currFileYOffset = 0; | 73 | int currFileYOffset = 0; |
74 | 74 | ||
75 | // if our region isn't on the first Y section of the areas to be landscaped, then | 75 | // if our region isn't on the first Y section of the areas to be landscaped, then |
@@ -84,11 +84,11 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders | |||
84 | 84 | ||
85 | // got to the Y start offset within the file of our region | 85 | // got to the Y start offset within the file of our region |
86 | // so read the file bits associated with our region | 86 | // so read the file bits associated with our region |
87 | int x, y; | 87 | int y; |
88 | // for each Y within our Y offset | 88 | // for each Y within our Y offset |
89 | for (y = 0; y < sectionHeight; y++) | 89 | for (y = 0; y < sectionHeight; y++) |
90 | { | 90 | { |
91 | currFileXOffset = 0; | 91 | int currFileXOffset = 0; |
92 | 92 | ||
93 | // if our region isn't the first X section of the areas to be landscaped, then | 93 | // if our region isn't the first X section of the areas to be landscaped, then |
94 | // advance the stream to the X start pos of our section in the file | 94 | // advance the stream to the X start pos of our section in the file |
@@ -100,6 +100,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders | |||
100 | } | 100 | } |
101 | 101 | ||
102 | // got to our X offset, so write our regions X line | 102 | // got to our X offset, so write our regions X line |
103 | int x; | ||
103 | for (x = 0; x < sectionWidth; x++) | 104 | for (x = 0; x < sectionWidth; x++) |
104 | { | 105 | { |
105 | // Read a strip and continue | 106 | // Read a strip and continue |
@@ -130,9 +131,10 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders | |||
130 | FileStream s = file.Open(FileMode.Create, FileAccess.Write); | 131 | FileStream s = file.Open(FileMode.Create, FileAccess.Write); |
131 | BinaryWriter bs = new BinaryWriter(s); | 132 | BinaryWriter bs = new BinaryWriter(s); |
132 | 133 | ||
133 | int x, y; | 134 | int y; |
134 | for (y = 0; y < map.Height; y++) | 135 | for (y = 0; y < map.Height; y++) |
135 | { | 136 | { |
137 | int x; | ||
136 | for (x = 0; x < map.Width; x++) | 138 | for (x = 0; x < map.Width; x++) |
137 | { | 139 | { |
138 | bs.Write((float) map[x, y]); | 140 | bs.Write((float) map[x, y]); |
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/Terragen.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/Terragen.cs index 7cb4b00..fe36cf7 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/Terragen.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/Terragen.cs | |||
@@ -50,14 +50,15 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders | |||
50 | BinaryReader bs = new BinaryReader(s); | 50 | BinaryReader bs = new BinaryReader(s); |
51 | 51 | ||
52 | bool eof = false; | 52 | bool eof = false; |
53 | if (ASCIIEncoding.ASCII.GetString(bs.ReadBytes(16)) == "TERRAGENTERRAIN ") | 53 | if (Encoding.ASCII.GetString(bs.ReadBytes(16)) == "TERRAGENTERRAIN ") |
54 | { | 54 | { |
55 | int w = 256; | ||
56 | int h = 256; | ||
57 | |||
55 | // Terragen file | 58 | // Terragen file |
56 | while (eof == false) | 59 | while (eof == false) |
57 | { | 60 | { |
58 | int w = 256; | 61 | string tmp = Encoding.ASCII.GetString(bs.ReadBytes(4)); |
59 | int h = 256; | ||
60 | string tmp = ASCIIEncoding.ASCII.GetString(bs.ReadBytes(4)); | ||
61 | switch (tmp) | 62 | switch (tmp) |
62 | { | 63 | { |
63 | case "SIZE": | 64 | case "SIZE": |
@@ -79,12 +80,13 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders | |||
79 | Int16 heightScale = bs.ReadInt16(); | 80 | Int16 heightScale = bs.ReadInt16(); |
80 | Int16 baseHeight = bs.ReadInt16(); | 81 | Int16 baseHeight = bs.ReadInt16(); |
81 | retval = new TerrainChannel(w, h); | 82 | retval = new TerrainChannel(w, h); |
82 | int x, y; | 83 | int x; |
83 | for (x = 0; x < w; x++) | 84 | for (x = 0; x < w; x++) |
84 | { | 85 | { |
86 | int y; | ||
85 | for (y = 0; y < h; y++) | 87 | for (y = 0; y < h; y++) |
86 | { | 88 | { |
87 | retval[x, y] = (double) baseHeight + (double) bs.ReadInt16() * (double) heightScale / 65536.0; | 89 | retval[x, y] = baseHeight + bs.ReadInt16() * (double) heightScale / 65536.0; |
88 | } | 90 | } |
89 | } | 91 | } |
90 | break; | 92 | break; |
@@ -103,7 +105,6 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders | |||
103 | 105 | ||
104 | public void SaveFile(string filename, ITerrainChannel map) | 106 | public void SaveFile(string filename, ITerrainChannel map) |
105 | { | 107 | { |
106 | char[] header = "TERRAGENTERRAIN".ToCharArray(); | ||
107 | throw new NotImplementedException(); | 108 | throw new NotImplementedException(); |
108 | } | 109 | } |
109 | 110 | ||