diff options
author | Dr Scofield | 2009-02-10 13:10:57 +0000 |
---|---|---|
committer | Dr Scofield | 2009-02-10 13:10:57 +0000 |
commit | 180be7de07014aa33bc6066f12a0819b731c1c9d (patch) | |
tree | 3aa13af3cda4b808fa9453655875327699b61311 /OpenSim/Region/CoreModules/World/Terrain/FileLoaders/RAW32.cs | |
parent | Stopgap measure: To use gridlaunch, or GUI, start opensim with (diff) | |
download | opensim-SC_OLD-180be7de07014aa33bc6066f12a0819b731c1c9d.zip opensim-SC_OLD-180be7de07014aa33bc6066f12a0819b731c1c9d.tar.gz opensim-SC_OLD-180be7de07014aa33bc6066f12a0819b731c1c9d.tar.bz2 opensim-SC_OLD-180be7de07014aa33bc6066f12a0819b731c1c9d.tar.xz |
this is step 2 of 2 of the OpenSim.Region.Environment refactor.
NOTHING has been deleted or moved off to forge at this point. what
has happened is that OpenSim.Region.Environment.Modules has been split
in two:
- OpenSim.Region.CoreModules: all those modules that are either
directly or indirectly referenced from other OpenSim packages, or
that provide functionality that the OpenSim developer community
considers core functionality:
CoreModules/Agent/AssetTransaction
CoreModules/Agent/Capabilities
CoreModules/Agent/TextureDownload
CoreModules/Agent/TextureSender
CoreModules/Agent/TextureSender/Tests
CoreModules/Agent/Xfer
CoreModules/Avatar/AvatarFactory
CoreModules/Avatar/Chat/ChatModule
CoreModules/Avatar/Combat
CoreModules/Avatar/Currency/SampleMoney
CoreModules/Avatar/Dialog
CoreModules/Avatar/Friends
CoreModules/Avatar/Gestures
CoreModules/Avatar/Groups
CoreModules/Avatar/InstantMessage
CoreModules/Avatar/Inventory
CoreModules/Avatar/Inventory/Archiver
CoreModules/Avatar/Inventory/Transfer
CoreModules/Avatar/Lure
CoreModules/Avatar/ObjectCaps
CoreModules/Avatar/Profiles
CoreModules/Communications/Local
CoreModules/Communications/REST
CoreModules/Framework/EventQueue
CoreModules/Framework/InterfaceCommander
CoreModules/Hypergrid
CoreModules/InterGrid
CoreModules/Scripting/DynamicTexture
CoreModules/Scripting/EMailModules
CoreModules/Scripting/HttpRequest
CoreModules/Scripting/LoadImageURL
CoreModules/Scripting/VectorRender
CoreModules/Scripting/WorldComm
CoreModules/Scripting/XMLRPC
CoreModules/World/Archiver
CoreModules/World/Archiver/Tests
CoreModules/World/Estate
CoreModules/World/Land
CoreModules/World/Permissions
CoreModules/World/Serialiser
CoreModules/World/Sound
CoreModules/World/Sun
CoreModules/World/Terrain
CoreModules/World/Terrain/DefaultEffects
CoreModules/World/Terrain/DefaultEffects/bin
CoreModules/World/Terrain/DefaultEffects/bin/Debug
CoreModules/World/Terrain/Effects
CoreModules/World/Terrain/FileLoaders
CoreModules/World/Terrain/FloodBrushes
CoreModules/World/Terrain/PaintBrushes
CoreModules/World/Terrain/Tests
CoreModules/World/Vegetation
CoreModules/World/Wind
CoreModules/World/WorldMap
- OpenSim.Region.OptionalModules: all those modules that are not core
modules:
OptionalModules/Avatar/Chat/IRC-stuff
OptionalModules/Avatar/Concierge
OptionalModules/Avatar/Voice/AsterixVoice
OptionalModules/Avatar/Voice/SIPVoice
OptionalModules/ContentManagementSystem
OptionalModules/Grid/Interregion
OptionalModules/Python
OptionalModules/SvnSerialiser
OptionalModules/World/NPC
OptionalModules/World/TreePopulator
Diffstat (limited to 'OpenSim/Region/CoreModules/World/Terrain/FileLoaders/RAW32.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Terrain/FileLoaders/RAW32.cs | 170 |
1 files changed, 170 insertions, 0 deletions
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/RAW32.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/RAW32.cs new file mode 100644 index 0000000..178104f --- /dev/null +++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/RAW32.cs | |||
@@ -0,0 +1,170 @@ | |||
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.IO; | ||
29 | using OpenSim.Region.Framework.Interfaces; | ||
30 | using OpenSim.Region.Framework.Scenes; | ||
31 | |||
32 | namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders | ||
33 | { | ||
34 | public class RAW32 : ITerrainLoader | ||
35 | { | ||
36 | #region ITerrainLoader Members | ||
37 | |||
38 | public string FileExtension | ||
39 | { | ||
40 | get { return ".r32"; } | ||
41 | } | ||
42 | |||
43 | public ITerrainChannel LoadFile(string filename) | ||
44 | { | ||
45 | FileInfo file = new FileInfo(filename); | ||
46 | FileStream s = file.Open(FileMode.Open, FileAccess.Read); | ||
47 | ITerrainChannel retval = LoadStream(s); | ||
48 | |||
49 | s.Close(); | ||
50 | |||
51 | return retval; | ||
52 | } | ||
53 | |||
54 | public ITerrainChannel LoadFile(string filename, int offsetX, int offsetY, int fileWidth, int fileHeight, int sectionWidth, int sectionHeight) | ||
55 | { | ||
56 | TerrainChannel retval = new TerrainChannel(sectionWidth, sectionHeight); | ||
57 | |||
58 | FileInfo file = new FileInfo(filename); | ||
59 | FileStream s = file.Open(FileMode.Open, FileAccess.Read); | ||
60 | BinaryReader bs = new BinaryReader(s); | ||
61 | |||
62 | int currFileYOffset = 0; | ||
63 | |||
64 | // if our region isn't on the first Y section of the areas to be landscaped, then | ||
65 | // advance to our section of the file | ||
66 | while (currFileYOffset < offsetY) | ||
67 | { | ||
68 | // read a whole strip of regions | ||
69 | int heightsToRead = sectionHeight * (fileWidth * sectionWidth); | ||
70 | bs.ReadBytes(heightsToRead * 4); // because the floats are 4 bytes in the file | ||
71 | currFileYOffset++; | ||
72 | } | ||
73 | |||
74 | // got to the Y start offset within the file of our region | ||
75 | // so read the file bits associated with our region | ||
76 | int y; | ||
77 | // for each Y within our Y offset | ||
78 | for (y = 0; y < sectionHeight; y++) | ||
79 | { | ||
80 | int currFileXOffset = 0; | ||
81 | |||
82 | // if our region isn't the first X section of the areas to be landscaped, then | ||
83 | // advance the stream to the X start pos of our section in the file | ||
84 | // i.e. eat X upto where we start | ||
85 | while (currFileXOffset < offsetX) | ||
86 | { | ||
87 | bs.ReadBytes(sectionWidth * 4); // 4 bytes = single | ||
88 | currFileXOffset++; | ||
89 | } | ||
90 | |||
91 | // got to our X offset, so write our regions X line | ||
92 | int x; | ||
93 | for (x = 0; x < sectionWidth; x++) | ||
94 | { | ||
95 | // Read a strip and continue | ||
96 | retval[x, y] = bs.ReadSingle(); | ||
97 | } | ||
98 | // record that we wrote it | ||
99 | currFileXOffset++; | ||
100 | |||
101 | // if our region isn't the last X section of the areas to be landscaped, then | ||
102 | // advance the stream to the end of this Y column | ||
103 | while (currFileXOffset < fileWidth) | ||
104 | { | ||
105 | // eat the next regions x line | ||
106 | bs.ReadBytes(sectionWidth * 4); // 4 bytes = single | ||
107 | currFileXOffset++; | ||
108 | } | ||
109 | } | ||
110 | |||
111 | bs.Close(); | ||
112 | s.Close(); | ||
113 | |||
114 | return retval; | ||
115 | } | ||
116 | |||
117 | public ITerrainChannel LoadStream(Stream s) | ||
118 | { | ||
119 | TerrainChannel retval = new TerrainChannel(); | ||
120 | |||
121 | BinaryReader bs = new BinaryReader(s); | ||
122 | int y; | ||
123 | for (y = 0; y < retval.Height; y++) | ||
124 | { | ||
125 | int x; | ||
126 | for (x = 0; x < retval.Width; x++) | ||
127 | { | ||
128 | retval[x, y] = bs.ReadSingle(); | ||
129 | } | ||
130 | } | ||
131 | |||
132 | bs.Close(); | ||
133 | |||
134 | return retval; | ||
135 | } | ||
136 | |||
137 | public void SaveFile(string filename, ITerrainChannel map) | ||
138 | { | ||
139 | FileInfo file = new FileInfo(filename); | ||
140 | FileStream s = file.Open(FileMode.Create, FileAccess.Write); | ||
141 | SaveStream(s, map); | ||
142 | |||
143 | s.Close(); | ||
144 | } | ||
145 | |||
146 | public void SaveStream(Stream s, ITerrainChannel map) | ||
147 | { | ||
148 | BinaryWriter bs = new BinaryWriter(s); | ||
149 | |||
150 | int y; | ||
151 | for (y = 0; y < map.Height; y++) | ||
152 | { | ||
153 | int x; | ||
154 | for (x = 0; x < map.Width; x++) | ||
155 | { | ||
156 | bs.Write((float) map[x, y]); | ||
157 | } | ||
158 | } | ||
159 | |||
160 | bs.Close(); | ||
161 | } | ||
162 | |||
163 | #endregion | ||
164 | |||
165 | public override string ToString() | ||
166 | { | ||
167 | return "RAW32"; | ||
168 | } | ||
169 | } | ||
170 | } | ||