diff options
author | UbitUmarov | 2015-09-02 19:54:53 +0100 |
---|---|---|
committer | UbitUmarov | 2015-09-02 19:54:53 +0100 |
commit | a11edceb00b5b86f825bd957bdac9edb91f893dd (patch) | |
tree | c192eae26f3aadf365a66f32fc6d9ade2f0a0c61 /OpenSim/Region/CoreModules/World/Warp3DMap | |
parent | bad merge? (diff) | |
download | opensim-SC_OLD-a11edceb00b5b86f825bd957bdac9edb91f893dd.zip opensim-SC_OLD-a11edceb00b5b86f825bd957bdac9edb91f893dd.tar.gz opensim-SC_OLD-a11edceb00b5b86f825bd957bdac9edb91f893dd.tar.bz2 opensim-SC_OLD-a11edceb00b5b86f825bd957bdac9edb91f893dd.tar.xz |
seems to compile ( tests comented out)
Diffstat (limited to 'OpenSim/Region/CoreModules/World/Warp3DMap')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Warp3DMap/TerrainSplat.cs | 130 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs | 34 |
2 files changed, 4 insertions, 160 deletions
diff --git a/OpenSim/Region/CoreModules/World/Warp3DMap/TerrainSplat.cs b/OpenSim/Region/CoreModules/World/Warp3DMap/TerrainSplat.cs index 77c10b8..4719ba3 100644 --- a/OpenSim/Region/CoreModules/World/Warp3DMap/TerrainSplat.cs +++ b/OpenSim/Region/CoreModules/World/Warp3DMap/TerrainSplat.cs | |||
@@ -79,13 +79,10 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap | |||
79 | /// <remarks>Based on the algorithm described at http://opensimulator.org/wiki/Terrain_Splatting | 79 | /// <remarks>Based on the algorithm described at http://opensimulator.org/wiki/Terrain_Splatting |
80 | /// Note we create a 256x256 dimension texture even if the actual terrain is larger. | 80 | /// Note we create a 256x256 dimension texture even if the actual terrain is larger. |
81 | /// </remarks> | 81 | /// </remarks> |
82 | <<<<<<< HEAD | 82 | |
83 | public static Bitmap Splat(ITerrainChannel terrain, | 83 | public static Bitmap Splat(ITerrainChannel terrain, |
84 | UUID[] textureIDs, float[] startHeights, float[] heightRanges, | 84 | UUID[] textureIDs, float[] startHeights, float[] heightRanges, |
85 | Vector3d regionPosition, IAssetService assetService, bool textureTerrain) | 85 | Vector3d regionPosition, IAssetService assetService, bool textureTerrain) |
86 | ======= | ||
87 | public static Bitmap Splat(ITerrainChannel terrain, UUID[] textureIDs, float[] startHeights, float[] heightRanges, Vector3d regionPosition, IAssetService assetService, bool textureTerrain) | ||
88 | >>>>>>> avn/ubitvar | ||
89 | { | 86 | { |
90 | Debug.Assert(textureIDs.Length == 4); | 87 | Debug.Assert(textureIDs.Length == 4); |
91 | Debug.Assert(startHeights.Length == 4); | 88 | Debug.Assert(startHeights.Length == 4); |
@@ -133,8 +130,8 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap | |||
133 | asset = assetService.Get(textureIDs[i].ToString()); | 130 | asset = assetService.Get(textureIDs[i].ToString()); |
134 | if (asset != null) | 131 | if (asset != null) |
135 | { | 132 | { |
136 | // m_log.DebugFormat( | 133 | // m_log.DebugFormat( |
137 | // "[TERRAIN SPLAT]: Got cached original JPEG2000 terrain texture {0} {1}", i, asset.ID); | 134 | // "[TERRAIN SPLAT]: Got cached original JPEG2000 terrain texture {0} {1}", i, asset.ID); |
138 | 135 | ||
139 | try { detailTexture[i] = (Bitmap)CSJ2K.J2kImage.FromBytes(asset.Data); } | 136 | try { detailTexture[i] = (Bitmap)CSJ2K.J2kImage.FromBytes(asset.Data); } |
140 | catch (Exception ex) | 137 | catch (Exception ex) |
@@ -144,7 +141,7 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap | |||
144 | } | 141 | } |
145 | 142 | ||
146 | if (detailTexture[i] != null) | 143 | if (detailTexture[i] != null) |
147 | { | 144 | { |
148 | // Make sure this texture is the correct size, otherwise resize | 145 | // Make sure this texture is the correct size, otherwise resize |
149 | if (detailTexture[i].Width != 256 || detailTexture[i].Height != 256) | 146 | if (detailTexture[i].Width != 256 || detailTexture[i].Height != 256) |
150 | { | 147 | { |
@@ -199,74 +196,12 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap | |||
199 | using (SolidBrush brush = new SolidBrush(DEFAULT_TERRAIN_COLOR[i])) | 196 | using (SolidBrush brush = new SolidBrush(DEFAULT_TERRAIN_COLOR[i])) |
200 | gfx.FillRectangle(brush, 0, 0, 256, 256); | 197 | gfx.FillRectangle(brush, 0, 0, 256, 256); |
201 | } | 198 | } |
202 | else | ||
203 | { | ||
204 | if (detailTexture[i].Width != 256 || detailTexture[i].Height != 256) | ||
205 | { | ||
206 | detailTexture[i] = ResizeBitmap(detailTexture[i], 256, 256); | ||
207 | } | ||
208 | } | ||
209 | } | 199 | } |
210 | <<<<<<< HEAD | ||
211 | else | 200 | else |
212 | ======= | ||
213 | |||
214 | #region Layer Map | ||
215 | |||
216 | float[,] layermap = new float[256 , 256]; | ||
217 | |||
218 | int xFactor = terrain.Width / 256; | ||
219 | int yFactor = terrain.Height / 256; | ||
220 | |||
221 | for (int y = 0; y < 256; y++) | ||
222 | >>>>>>> avn/ubitvar | ||
223 | { | 201 | { |
224 | if (detailTexture[i].Width != 256 || detailTexture[i].Height != 256) | 202 | if (detailTexture[i].Width != 256 || detailTexture[i].Height != 256) |
225 | { | 203 | { |
226 | <<<<<<< HEAD | ||
227 | detailTexture[i] = ResizeBitmap(detailTexture[i], 256, 256); | 204 | detailTexture[i] = ResizeBitmap(detailTexture[i], 256, 256); |
228 | ======= | ||
229 | float height = (float)terrain[x * xFactor, y * yFactor]; | ||
230 | |||
231 | float pctX = (float)x / 255f; | ||
232 | float pctY = (float)y / 255f; | ||
233 | |||
234 | // Use bilinear interpolation between the four corners of start height and | ||
235 | // height range to select the current values at this position | ||
236 | float startHeight = ImageUtils.Bilinear( | ||
237 | startHeights[0], | ||
238 | startHeights[2], | ||
239 | startHeights[1], | ||
240 | startHeights[3], | ||
241 | pctX, pctY); | ||
242 | startHeight = Utils.Clamp(startHeight, 0f, 255f); | ||
243 | |||
244 | float heightRange = ImageUtils.Bilinear( | ||
245 | heightRanges[0], | ||
246 | heightRanges[2], | ||
247 | heightRanges[1], | ||
248 | heightRanges[3], | ||
249 | pctX, pctY); | ||
250 | heightRange = Utils.Clamp(heightRange, 0f, 255f); | ||
251 | |||
252 | // Generate two frequencies of perlin noise based on our global position | ||
253 | // The magic values were taken from http://opensimulator.org/wiki/Terrain_Splatting | ||
254 | Vector3 vec = new Vector3 | ||
255 | ( | ||
256 | ((float)regionPosition.X + (x * xFactor)) * 0.20319f, | ||
257 | ((float)regionPosition.Y + (y * yFactor)) * 0.20319f, | ||
258 | height * 0.25f | ||
259 | ); | ||
260 | |||
261 | float lowFreq = Perlin.noise2(vec.X * 0.222222f, vec.Y * 0.222222f) * 6.5f; | ||
262 | float highFreq = Perlin.turbulence2(vec.X, vec.Y, 2f) * 2.25f; | ||
263 | float noise = (lowFreq + highFreq) * 2f; | ||
264 | |||
265 | // Combine the current height, generated noise, start height, and height range parameters, then scale all of it | ||
266 | float layer = ((height + noise - startHeight) / heightRange) * 4f; | ||
267 | if (Single.IsNaN(layer)) layer = 0f; | ||
268 | layermap[x,y] = Utils.Clamp(layer, 0f, 3f); | ||
269 | >>>>>>> avn/ubitvar | ||
270 | } | 205 | } |
271 | } | 206 | } |
272 | } | 207 | } |
@@ -286,7 +221,6 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap | |||
286 | { | 221 | { |
287 | for (int x = 0; x < 256; x++) | 222 | for (int x = 0; x < 256; x++) |
288 | { | 223 | { |
289 | <<<<<<< HEAD | ||
290 | float height = (float)terrain[x * xFactor, y * yFactor]; | 224 | float height = (float)terrain[x * xFactor, y * yFactor]; |
291 | 225 | ||
292 | float pctX = (float)x / 255f; | 226 | float pctX = (float)x / 255f; |
@@ -328,58 +262,6 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap | |||
328 | if (Single.IsNaN(layer)) | 262 | if (Single.IsNaN(layer)) |
329 | layer = 0f; | 263 | layer = 0f; |
330 | layermap[x, y] = Utils.Clamp(layer, 0f, 3f); | 264 | layermap[x, y] = Utils.Clamp(layer, 0f, 3f); |
331 | ======= | ||
332 | // Get handles to all of the texture data arrays | ||
333 | BitmapData[] datas = new BitmapData[] | ||
334 | { | ||
335 | detailTexture[0].LockBits(new Rectangle(0, 0, 256, 256), ImageLockMode.ReadOnly, detailTexture[0].PixelFormat), | ||
336 | detailTexture[1].LockBits(new Rectangle(0, 0, 256, 256), ImageLockMode.ReadOnly, detailTexture[1].PixelFormat), | ||
337 | detailTexture[2].LockBits(new Rectangle(0, 0, 256, 256), ImageLockMode.ReadOnly, detailTexture[2].PixelFormat), | ||
338 | detailTexture[3].LockBits(new Rectangle(0, 0, 256, 256), ImageLockMode.ReadOnly, detailTexture[3].PixelFormat) | ||
339 | }; | ||
340 | |||
341 | int[] comps = new int[] | ||
342 | { | ||
343 | (datas[0].PixelFormat == PixelFormat.Format32bppArgb) ? 4 : 3, | ||
344 | (datas[1].PixelFormat == PixelFormat.Format32bppArgb) ? 4 : 3, | ||
345 | (datas[2].PixelFormat == PixelFormat.Format32bppArgb) ? 4 : 3, | ||
346 | (datas[3].PixelFormat == PixelFormat.Format32bppArgb) ? 4 : 3 | ||
347 | }; | ||
348 | |||
349 | for (int y = 0; y < 256; y++) | ||
350 | { | ||
351 | for (int x = 0; x < 256; x++) | ||
352 | { | ||
353 | float layer = layermap[x, y]; | ||
354 | |||
355 | // Select two textures | ||
356 | int l0 = (int)Math.Floor(layer); | ||
357 | int l1 = Math.Min(l0 + 1, 3); | ||
358 | |||
359 | byte* ptrA = (byte*)datas[l0].Scan0 + y * datas[l0].Stride + x * comps[l0]; | ||
360 | byte* ptrB = (byte*)datas[l1].Scan0 + y * datas[l1].Stride + x * comps[l1]; | ||
361 | byte* ptrO = (byte*)outputData.Scan0 + y * outputData.Stride + x * 3; | ||
362 | |||
363 | float aB = *(ptrA + 0); | ||
364 | float aG = *(ptrA + 1); | ||
365 | float aR = *(ptrA + 2); | ||
366 | |||
367 | float bB = *(ptrB + 0); | ||
368 | float bG = *(ptrB + 1); | ||
369 | float bR = *(ptrB + 2); | ||
370 | |||
371 | float layerDiff = layer - l0; | ||
372 | |||
373 | // Interpolate between the two selected textures | ||
374 | *(ptrO + 0) = (byte)Math.Floor(aB + layerDiff * (bB - aB)); | ||
375 | *(ptrO + 1) = (byte)Math.Floor(aG + layerDiff * (bG - aG)); | ||
376 | *(ptrO + 2) = (byte)Math.Floor(aR + layerDiff * (bR - aR)); | ||
377 | } | ||
378 | } | ||
379 | |||
380 | for (int i = 0; i < 4; i++) | ||
381 | detailTexture[i].UnlockBits(datas[i]); | ||
382 | >>>>>>> avn/ubitvar | ||
383 | } | 265 | } |
384 | } | 266 | } |
385 | 267 | ||
@@ -471,10 +353,6 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap | |||
471 | b.Dispose(); | 353 | b.Dispose(); |
472 | return result; | 354 | return result; |
473 | } | 355 | } |
474 | <<<<<<< HEAD | ||
475 | |||
476 | ======= | ||
477 | >>>>>>> avn/ubitvar | ||
478 | public static Bitmap SplatSimple(float[] heightmap) | 356 | public static Bitmap SplatSimple(float[] heightmap) |
479 | { | 357 | { |
480 | const float BASE_HSV_H = 93f / 360f; | 358 | const float BASE_HSV_H = 93f / 360f; |
diff --git a/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs b/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs index d8420d9..8e843ee 100644 --- a/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs +++ b/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs | |||
@@ -156,13 +156,6 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap | |||
156 | 156 | ||
157 | public Bitmap CreateMapTile() | 157 | public Bitmap CreateMapTile() |
158 | { | 158 | { |
159 | <<<<<<< HEAD | ||
160 | // Vector3 camPos = new Vector3(127.5f, 127.5f, 221.7025033688163f); | ||
161 | // Camera above the middle of the region | ||
162 | Vector3 camPos = new Vector3( | ||
163 | m_scene.RegionInfo.RegionSizeX/2 - 0.5f, | ||
164 | m_scene.RegionInfo.RegionSizeY/2 - 0.5f, | ||
165 | ======= | ||
166 | /* this must be on all map, not just its image | 159 | /* this must be on all map, not just its image |
167 | if ((DateTime.Now - lastImageTime).TotalSeconds < 3600) | 160 | if ((DateTime.Now - lastImageTime).TotalSeconds < 3600) |
168 | { | 161 | { |
@@ -179,16 +172,10 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap | |||
179 | Vector3 camPos = new Vector3( | 172 | Vector3 camPos = new Vector3( |
180 | m_scene.RegionInfo.RegionSizeX / 2 - 0.5f, | 173 | m_scene.RegionInfo.RegionSizeX / 2 - 0.5f, |
181 | m_scene.RegionInfo.RegionSizeY / 2 - 0.5f, | 174 | m_scene.RegionInfo.RegionSizeY / 2 - 0.5f, |
182 | >>>>>>> avn/ubitvar | ||
183 | 221.7025033688163f); | 175 | 221.7025033688163f); |
184 | // Viewport viewing down onto the region | 176 | // Viewport viewing down onto the region |
185 | Viewport viewport = new Viewport(camPos, -Vector3.UnitZ, 1024f, 0.1f, | 177 | Viewport viewport = new Viewport(camPos, -Vector3.UnitZ, 1024f, 0.1f, |
186 | (int)m_scene.RegionInfo.RegionSizeX, (int)m_scene.RegionInfo.RegionSizeY, | 178 | (int)m_scene.RegionInfo.RegionSizeX, (int)m_scene.RegionInfo.RegionSizeY, |
187 | <<<<<<< HEAD | ||
188 | (float)m_scene.RegionInfo.RegionSizeX, (float)m_scene.RegionInfo.RegionSizeY ); | ||
189 | // Fill the viewport and return the image | ||
190 | return CreateMapTile(viewport, false); | ||
191 | ======= | ||
192 | (float)m_scene.RegionInfo.RegionSizeX, (float)m_scene.RegionInfo.RegionSizeY); | 179 | (float)m_scene.RegionInfo.RegionSizeX, (float)m_scene.RegionInfo.RegionSizeY); |
193 | 180 | ||
194 | Bitmap tile = CreateMapTile(viewport, false); | 181 | Bitmap tile = CreateMapTile(viewport, false); |
@@ -199,7 +186,6 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap | |||
199 | lastImageTime = DateTime.Now; | 186 | lastImageTime = DateTime.Now; |
200 | return (Bitmap)lastImage.Clone(); | 187 | return (Bitmap)lastImage.Clone(); |
201 | */ | 188 | */ |
202 | >>>>>>> avn/ubitvar | ||
203 | } | 189 | } |
204 | 190 | ||
205 | public Bitmap CreateViewImage(Vector3 camPos, Vector3 camDir, float fov, int width, int height, bool useTextures) | 191 | public Bitmap CreateViewImage(Vector3 camPos, Vector3 camDir, float fov, int width, int height, bool useTextures) |
@@ -315,15 +301,9 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap | |||
315 | float waterHeight = (float)m_scene.RegionInfo.RegionSettings.WaterHeight; | 301 | float waterHeight = (float)m_scene.RegionInfo.RegionSettings.WaterHeight; |
316 | 302 | ||
317 | renderer.AddPlane("Water", m_scene.RegionInfo.RegionSizeX * 0.5f); | 303 | renderer.AddPlane("Water", m_scene.RegionInfo.RegionSizeX * 0.5f); |
318 | <<<<<<< HEAD | ||
319 | renderer.Scene.sceneobject("Water").setPos(m_scene.RegionInfo.RegionSizeX/2 - 0.5f, | ||
320 | waterHeight, | ||
321 | m_scene.RegionInfo.RegionSizeY/2 - 0.5f ); | ||
322 | ======= | ||
323 | renderer.Scene.sceneobject("Water").setPos(m_scene.RegionInfo.RegionSizeX / 2 - 0.5f, | 304 | renderer.Scene.sceneobject("Water").setPos(m_scene.RegionInfo.RegionSizeX / 2 - 0.5f, |
324 | waterHeight, | 305 | waterHeight, |
325 | m_scene.RegionInfo.RegionSizeY / 2 - 0.5f); | 306 | m_scene.RegionInfo.RegionSizeY / 2 - 0.5f); |
326 | >>>>>>> avn/ubitvar | ||
327 | 307 | ||
328 | warp_Material waterColorMaterial = new warp_Material(ConvertColor(WATER_COLOR)); | 308 | warp_Material waterColorMaterial = new warp_Material(ConvertColor(WATER_COLOR)); |
329 | waterColorMaterial.setReflectivity(0); // match water color with standard map module thanks lkalif | 309 | waterColorMaterial.setReflectivity(0); // match water color with standard map module thanks lkalif |
@@ -352,11 +332,7 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap | |||
352 | warp_Vector pos = ConvertVector(x, y, (float)terrain[(int)x, (int)y]); | 332 | warp_Vector pos = ConvertVector(x, y, (float)terrain[(int)x, (int)y]); |
353 | obj.addVertex(new warp_Vertex(pos, | 333 | obj.addVertex(new warp_Vertex(pos, |
354 | x / (float)m_scene.RegionInfo.RegionSizeX, | 334 | x / (float)m_scene.RegionInfo.RegionSizeX, |
355 | <<<<<<< HEAD | ||
356 | (((float)m_scene.RegionInfo.RegionSizeY) - y) / m_scene.RegionInfo.RegionSizeY) ); | ||
357 | ======= | ||
358 | (((float)m_scene.RegionInfo.RegionSizeY) - y) / m_scene.RegionInfo.RegionSizeY)); | 335 | (((float)m_scene.RegionInfo.RegionSizeY) - y) / m_scene.RegionInfo.RegionSizeY)); |
359 | >>>>>>> avn/ubitvar | ||
360 | } | 336 | } |
361 | } | 337 | } |
362 | 338 | ||
@@ -424,12 +400,8 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap | |||
424 | warp_Texture texture; | 400 | warp_Texture texture; |
425 | using ( | 401 | using ( |
426 | Bitmap image | 402 | Bitmap image |
427 | <<<<<<< HEAD | ||
428 | = TerrainSplat.Splat(terrain, textureIDs, startHeights, heightRanges, | ||
429 | ======= | ||
430 | = TerrainSplat.Splat( | 403 | = TerrainSplat.Splat( |
431 | terrain, textureIDs, startHeights, heightRanges, | 404 | terrain, textureIDs, startHeights, heightRanges, |
432 | >>>>>>> avn/ubitvar | ||
433 | new Vector3d(globalX, globalY, 0.0), m_scene.AssetService, textureTerrain)) | 405 | new Vector3d(globalX, globalY, 0.0), m_scene.AssetService, textureTerrain)) |
434 | { | 406 | { |
435 | texture = new warp_Texture(image); | 407 | texture = new warp_Texture(image); |
@@ -711,12 +683,6 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap | |||
711 | return new warp_Vector(x, z, y); | 683 | return new warp_Vector(x, z, y); |
712 | } | 684 | } |
713 | 685 | ||
714 | // Note: axis change. | ||
715 | private static warp_Vector ConvertVector(float x, float y, float z) | ||
716 | { | ||
717 | return new warp_Vector(x, z, y); | ||
718 | } | ||
719 | |||
720 | private static warp_Vector ConvertVector(Vector3 vector) | 686 | private static warp_Vector ConvertVector(Vector3 vector) |
721 | { | 687 | { |
722 | return new warp_Vector(vector.X, vector.Z, vector.Y); | 688 | return new warp_Vector(vector.X, vector.Z, vector.Y); |