diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs | 65 |
1 files changed, 36 insertions, 29 deletions
diff --git a/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs b/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs index 6d68c61..850ffc3 100644 --- a/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs +++ b/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs | |||
@@ -166,8 +166,8 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap | |||
166 | } | 166 | } |
167 | 167 | ||
168 | Vector3 camPos = new Vector3( | 168 | Vector3 camPos = new Vector3( |
169 | m_scene.RegionInfo.RegionSizeX / 2 - 0.5f, | 169 | (m_scene.RegionInfo.RegionSizeX - 1) * 0.5f, |
170 | m_scene.RegionInfo.RegionSizeY / 2 - 0.5f, | 170 | (m_scene.RegionInfo.RegionSizeY - 1) * 0.5f, |
171 | 221.7025033688163f); | 171 | 221.7025033688163f); |
172 | // Viewport viewing down onto the region | 172 | // Viewport viewing down onto the region |
173 | Viewport viewport = new Viewport(camPos, -Vector3.UnitZ, 1024f, 0.1f, | 173 | Viewport viewport = new Viewport(camPos, -Vector3.UnitZ, 1024f, 0.1f, |
@@ -284,7 +284,7 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap | |||
284 | } | 284 | } |
285 | 285 | ||
286 | // Add a terrain to the renderer. | 286 | // Add a terrain to the renderer. |
287 | // Note that we create a 'low resolution' 256x256 vertex terrain rather than trying for | 287 | // Note that we create a 'low resolution' 257x257 vertex terrain rather than trying for |
288 | // full resolution. This saves a lot of memory especially for very large regions. | 288 | // full resolution. This saves a lot of memory especially for very large regions. |
289 | private void CreateTerrain(WarpRenderer renderer, bool textureTerrain) | 289 | private void CreateTerrain(WarpRenderer renderer, bool textureTerrain) |
290 | { | 290 | { |
@@ -296,49 +296,56 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap | |||
296 | // 'diff' is the difference in scale between the real region size and the size of terrain we're buiding | 296 | // 'diff' is the difference in scale between the real region size and the size of terrain we're buiding |
297 | float diff = regionsx / 256f; | 297 | float diff = regionsx / 256f; |
298 | 298 | ||
299 | int npointsx =(int)(regionsx / diff); | 299 | int npointsx = (int)(regionsx / diff) + 1; |
300 | int npointsy =(int)(regionsy / diff); | 300 | int npointsy = (int)(regionsy / diff) + 1; |
301 | 301 | ||
302 | float invsx = 1.0f / regionsx; | 302 | float invsx = 1.0f / regionsx; |
303 | float invsy = 1.0f / (float)m_scene.RegionInfo.RegionSizeY; | 303 | float invsy = 1.0f / regionsy; |
304 | 304 | ||
305 | // Create all the vertices for the terrain | 305 | // Create all the vertices for the terrain |
306 | warp_Object obj = new warp_Object(); | 306 | warp_Object obj = new warp_Object(); |
307 | for (float y = 0; y < regionsy; y += diff) | 307 | warp_Vector pos; |
308 | float x, y; | ||
309 | for (y = 0; y < regionsy; y += diff) | ||
308 | { | 310 | { |
309 | for (float x = 0; x < regionsx; x += diff) | 311 | for (x = 0; x < regionsx; x += diff) |
310 | { | 312 | { |
311 | warp_Vector pos = ConvertVector(x , y , (float)terrain[(int)x, (int)y]); | 313 | pos = ConvertVector(x , y , (float)terrain[(int)x, (int)y]); |
312 | obj.addVertex(new warp_Vertex(pos, x * invsx, 1.0f - y * invsy)); | 314 | obj.addVertex(new warp_Vertex(pos, x * invsx, 1.0f - y * invsy)); |
313 | } | 315 | } |
316 | pos = ConvertVector(x , y , (float)terrain[(int)(x - diff), (int)y]); | ||
317 | obj.addVertex(new warp_Vertex(pos, 1.0f, 1.0f - y * invsy)); | ||
314 | } | 318 | } |
315 | 319 | ||
320 | int lastY = (int)(y - diff); | ||
321 | for (x = 0; x < regionsx; x += diff) | ||
322 | { | ||
323 | pos = ConvertVector(x , y , (float)terrain[(int)x, lastY]); | ||
324 | obj.addVertex(new warp_Vertex(pos, x * invsx, 1.0f - y * invsy)); | ||
325 | } | ||
326 | pos = ConvertVector(x , y , (float)terrain[(int)(x - diff), lastY]); | ||
327 | obj.addVertex(new warp_Vertex(pos, 1.0f, 1.0f)); | ||
328 | |||
316 | // Now that we have all the vertices, make another pass and | 329 | // Now that we have all the vertices, make another pass and |
317 | // create the list of triangle indices. | 330 | // create the list of triangle indices. |
318 | float invdiff = 1.0f / diff; | ||
319 | int limx = npointsx - 1; | 331 | int limx = npointsx - 1; |
320 | int limy = npointsy - 1; | 332 | int limy = npointsy - 1; |
321 | for (float y = 0; y < regionsy; y += diff) | 333 | for (int j = 0; j < limy; j++) |
322 | { | 334 | { |
323 | for (float x = 0; x < regionsx; x += diff) | 335 | for (int i = 0; i < limx; i++) |
324 | { | 336 | { |
325 | float newX = x * invdiff; | 337 | int v = j * npointsx + i; |
326 | float newY = y * invdiff; | 338 | |
327 | if (newX < limx && newY < limy) | 339 | // Make two triangles for each of the squares in the grid of vertices |
328 | { | 340 | obj.addTriangle( |
329 | int v = (int)newY * npointsx + (int)newX; | 341 | v, |
330 | 342 | v + 1, | |
331 | // Make two triangles for each of the squares in the grid of vertices | 343 | v + npointsx); |
332 | obj.addTriangle( | 344 | |
333 | v, | 345 | obj.addTriangle( |
334 | v + 1, | 346 | v + npointsx + 1, |
335 | v + npointsx); | 347 | v + npointsx, |
336 | 348 | v + 1); | |
337 | obj.addTriangle( | ||
338 | v + npointsx + 1, | ||
339 | v + npointsx, | ||
340 | v + 1); | ||
341 | } | ||
342 | } | 349 | } |
343 | } | 350 | } |
344 | 351 | ||