aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/LLRAW.cs
diff options
context:
space:
mode:
authormingchen2008-07-03 22:16:09 +0000
committermingchen2008-07-03 22:16:09 +0000
commita5e3439cf0307a283fe547033dcaccb04ef14ff2 (patch)
tree29259b5880c12ed46ed694530eb7004e16f7e783 /OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/LLRAW.cs
parentMantis#1658. Thank you, Melanie for a patch that: (diff)
downloadopensim-SC_OLD-a5e3439cf0307a283fe547033dcaccb04ef14ff2.zip
opensim-SC_OLD-a5e3439cf0307a283fe547033dcaccb04ef14ff2.tar.gz
opensim-SC_OLD-a5e3439cf0307a283fe547033dcaccb04ef14ff2.tar.bz2
opensim-SC_OLD-a5e3439cf0307a283fe547033dcaccb04ef14ff2.tar.xz
*.Raw files should now be loadable using "terrain load-tile" functionality
Diffstat (limited to 'OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/LLRAW.cs')
-rw-r--r--OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/LLRAW.cs63
1 files changed, 61 insertions, 2 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/LLRAW.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/LLRAW.cs
index d8d0648..21fba2b 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/LLRAW.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/LLRAW.cs
@@ -80,9 +80,68 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders
80 return retval; 80 return retval;
81 } 81 }
82 82
83 public ITerrainChannel LoadFile(string filename, int x, int y, int fileWidth, int fileHeight, int w, int h) 83 public ITerrainChannel LoadFile(string filename, int offsetX, int offsetY, int fileWidth, int fileHeight, int sectionWidth, int sectionHeight)
84 { 84 {
85 throw new NotImplementedException(); 85 TerrainChannel retval = new TerrainChannel(sectionWidth, sectionHeight);
86
87 FileInfo file = new FileInfo(filename);
88 FileStream s = file.Open(FileMode.Open, FileAccess.Read);
89 BinaryReader bs = new BinaryReader(s);
90
91 int currFileYOffset = 0;
92
93 // if our region isn't on the first Y section of the areas to be landscaped, then
94 // advance to our section of the file
95 while (currFileYOffset < offsetY)
96 {
97 // read a whole strip of regions
98 int heightsToRead = sectionHeight * (fileWidth * sectionWidth);
99 bs.ReadBytes(heightsToRead * 13); // because there are 13 fun channels
100 currFileYOffset++;
101 }
102
103 // got to the Y start offset within the file of our region
104 // so read the file bits associated with our region
105 int y;
106 // for each Y within our Y offset
107 for (y = 0; y < sectionHeight; y++)
108 {
109 int currFileXOffset = 0;
110
111 // if our region isn't the first X section of the areas to be landscaped, then
112 // advance the stream to the X start pos of our section in the file
113 // i.e. eat X upto where we start
114 while (currFileXOffset < offsetX)
115 {
116 bs.ReadBytes(sectionWidth * 13);
117 currFileXOffset++;
118 }
119
120 // got to our X offset, so write our regions X line
121 int x;
122 for (x = 0; x < sectionWidth; x++)
123 {
124 // Read a strip and continue
125 retval[x, y] = bs.ReadByte() * (bs.ReadByte() / 128.0);
126 bs.ReadBytes(11);
127 }
128 // record that we wrote it
129 currFileXOffset++;
130
131 // if our region isn't the last X section of the areas to be landscaped, then
132 // advance the stream to the end of this Y column
133 while (currFileXOffset < fileWidth)
134 {
135 // eat the next regions x line
136 bs.ReadBytes(sectionWidth * 13); //The 13 channels again
137 currFileXOffset++;
138 }
139 }
140
141 bs.Close();
142 s.Close();
143
144 return retval;
86 } 145 }
87 146
88 public ITerrainChannel LoadStream(Stream s) 147 public ITerrainChannel LoadStream(Stream s)