diff options
author | Adam Frisby | 2008-04-06 13:48:28 +0000 |
---|---|---|
committer | Adam Frisby | 2008-04-06 13:48:28 +0000 |
commit | 996309a6e1ee47d96d81c0bdfdd5bfc27db66efd (patch) | |
tree | 9b9208a28969785a459e30de3ce9f260beb26201 /OpenSim/Region/Environment/Modules/Terrain/FileLoaders | |
parent | * Fixed up some documentation (diff) | |
download | opensim-SC-996309a6e1ee47d96d81c0bdfdd5bfc27db66efd.zip opensim-SC-996309a6e1ee47d96d81c0bdfdd5bfc27db66efd.tar.gz opensim-SC-996309a6e1ee47d96d81c0bdfdd5bfc27db66efd.tar.bz2 opensim-SC-996309a6e1ee47d96d81c0bdfdd5bfc27db66efd.tar.xz |
* Various terrain engine fixes
* Includes patch #894 fixes for terrain load-tile
* Large number of other terrain fixes and new commands included.
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Terrain/FileLoaders')
-rw-r--r-- | OpenSim/Region/Environment/Modules/Terrain/FileLoaders/RAW32.cs | 51 |
1 files changed, 42 insertions, 9 deletions
diff --git a/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/RAW32.cs b/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/RAW32.cs index fc81376..83ee341 100644 --- a/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/RAW32.cs +++ b/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/RAW32.cs | |||
@@ -62,30 +62,63 @@ namespace OpenSim.Region.Environment.Modules.Terrain.FileLoaders | |||
62 | return "RAW32"; | 62 | return "RAW32"; |
63 | } | 63 | } |
64 | 64 | ||
65 | public ITerrainChannel LoadFile(string filename, int fileStartX, int fileStartY, int fileWidth, int fileHeight, int sectionWidth, int sectionHeight) | 65 | public ITerrainChannel LoadFile(string filename, int offsetX, int offsetY, int fileWidth, int fileHeight, int sectionWidth, int sectionHeight) |
66 | { | 66 | { |
67 | TerrainChannel retval = new TerrainChannel(sectionWidth, sectionHeight); | 67 | TerrainChannel retval = new TerrainChannel(sectionWidth, sectionHeight); |
68 | 68 | ||
69 | FileInfo file = new FileInfo(filename); | 69 | FileInfo file = new FileInfo(filename); |
70 | FileStream s = file.Open(FileMode.Open, FileAccess.Read); | 70 | FileStream s = file.Open(FileMode.Open, FileAccess.Read); |
71 | BinaryReader bs = new BinaryReader(s); | 71 | BinaryReader bs = new BinaryReader(s); |
72 | |||
73 | int currFileXOffset = 0; | ||
74 | int currFileYOffset = 0; | ||
72 | 75 | ||
73 | // Advance to our section of the file | 76 | // if our region isn't on the first Y section of the areas to be landscaped, then |
74 | if (fileStartY * sectionHeight > 0) | 77 | // advance to our section of the file |
75 | bs.ReadBytes(fileStartY * sectionHeight); | 78 | while (currFileYOffset < offsetY) |
79 | { | ||
80 | // read a whole strip of regions | ||
81 | int heightsToRead = sectionHeight * (fileWidth * sectionWidth); | ||
82 | bs.ReadBytes( heightsToRead * 4); // because the floats are 4 bytes in the file | ||
83 | currFileYOffset++; | ||
84 | } | ||
76 | 85 | ||
86 | // got to the Y start offset within the file of our region | ||
87 | // so read the file bits associated with our region | ||
77 | int x, y; | 88 | int x, y; |
78 | for (y = 0; y < retval.Height; y++) | 89 | // for each Y within our Y offset |
90 | for (y = 0; y < sectionHeight; y++) | ||
79 | { | 91 | { |
80 | // Advance the stream if we aren't at the start of the section in the file | 92 | currFileXOffset = 0; |
81 | if (fileStartX * sectionWidth > 0) | 93 | |
82 | bs.ReadBytes(fileStartX * sectionHeight); | 94 | // if our region isn't the first X section of the areas to be landscaped, then |
95 | // advance the stream to the X start pos of our section in the file | ||
96 | // i.e. eat X upto where we start | ||
97 | while (currFileXOffset < offsetX) | ||
98 | { | ||
99 | bs.ReadBytes( sectionWidth * 4); // 4 bytes = single | ||
100 | currFileXOffset++; | ||
101 | } | ||
83 | 102 | ||
84 | for (x = 0; x < retval.Width; x++) | 103 | // got to our X offset, so write our regions X line |
104 | for (x = 0; x < sectionWidth; x++) | ||
85 | { | 105 | { |
86 | // Read a strip and continue | 106 | // Read a strip and continue |
87 | retval[x, y] = bs.ReadSingle(); | 107 | retval[x, y] = bs.ReadSingle(); |
88 | } | 108 | } |
109 | // record that we wrote it | ||
110 | currFileXOffset++; | ||
111 | |||
112 | // if our region isn't the last X section of the areas to be landscaped, then | ||
113 | // advance the stream to the end of this Y column | ||
114 | while (currFileXOffset < fileWidth ) | ||
115 | { | ||
116 | // eat the next regions x line | ||
117 | bs.ReadBytes(sectionWidth * 4); // 4 bytes = single | ||
118 | currFileXOffset++; | ||
119 | } | ||
120 | |||
121 | |||
89 | } | 122 | } |
90 | 123 | ||
91 | bs.Close(); | 124 | bs.Close(); |