diff options
author | Melanie | 2014-01-28 21:02:20 +0000 |
---|---|---|
committer | Melanie | 2014-01-28 21:02:20 +0000 |
commit | c6e9db58669d773c85041db99b19b942f70324f7 (patch) | |
tree | 99f69fb669332cff69a45ce6f7473aed6d965a0d /OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs | |
parent | Merge branch 'master' into careminster (diff) | |
parent | Merge branch 'justincc-master' (diff) | |
download | opensim-SC_OLD-c6e9db58669d773c85041db99b19b942f70324f7.zip opensim-SC_OLD-c6e9db58669d773c85041db99b19b942f70324f7.tar.gz opensim-SC_OLD-c6e9db58669d773c85041db99b19b942f70324f7.tar.bz2 opensim-SC_OLD-c6e9db58669d773c85041db99b19b942f70324f7.tar.xz |
Merge branch 'master' into careminster
Conflicts:
OpenSim/Framework/RegionSettings.cs
OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
OpenSim/Region/Framework/Interfaces/IInterregionComms.cs
OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
Diffstat (limited to 'OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs | 538 |
1 files changed, 276 insertions, 262 deletions
diff --git a/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs b/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs index 40638f8..bc52a43 100644 --- a/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs +++ b/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs | |||
@@ -55,7 +55,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | |||
55 | public struct DrawStruct | 55 | public struct DrawStruct |
56 | { | 56 | { |
57 | public DrawRoutine dr; | 57 | public DrawRoutine dr; |
58 | public Rectangle rect; | 58 | // public Rectangle rect; |
59 | public SolidBrush brush; | 59 | public SolidBrush brush; |
60 | public face[] trns; | 60 | public face[] trns; |
61 | } | 61 | } |
@@ -119,6 +119,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | |||
119 | { | 119 | { |
120 | mapbmp = FetchTexture(m_scene.RegionInfo.RegionSettings.TerrainImageID); | 120 | mapbmp = FetchTexture(m_scene.RegionInfo.RegionSettings.TerrainImageID); |
121 | } | 121 | } |
122 | |||
122 | return mapbmp; | 123 | return mapbmp; |
123 | } | 124 | } |
124 | 125 | ||
@@ -127,7 +128,10 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | |||
127 | try | 128 | try |
128 | { | 129 | { |
129 | using (Bitmap mapbmp = CreateMapTile()) | 130 | using (Bitmap mapbmp = CreateMapTile()) |
130 | return OpenJPEG.EncodeFromImage(mapbmp, true); | 131 | { |
132 | if (mapbmp != null) | ||
133 | return OpenJPEG.EncodeFromImage(mapbmp, true); | ||
134 | } | ||
131 | } | 135 | } |
132 | catch (Exception e) // LEGIT: Catching problems caused by OpenJPEG p/invoke | 136 | catch (Exception e) // LEGIT: Catching problems caused by OpenJPEG p/invoke |
133 | { | 137 | { |
@@ -277,321 +281,331 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | |||
277 | tc = Environment.TickCount; | 281 | tc = Environment.TickCount; |
278 | m_log.Debug("[MAPTILE]: Generating Maptile Step 2: Object Volume Profile"); | 282 | m_log.Debug("[MAPTILE]: Generating Maptile Step 2: Object Volume Profile"); |
279 | EntityBase[] objs = whichScene.GetEntities(); | 283 | EntityBase[] objs = whichScene.GetEntities(); |
280 | Dictionary<uint, DrawStruct> z_sort = new Dictionary<uint, DrawStruct>(); | ||
281 | //SortedList<float, RectangleDrawStruct> z_sort = new SortedList<float, RectangleDrawStruct>(); | ||
282 | List<float> z_sortheights = new List<float>(); | 284 | List<float> z_sortheights = new List<float>(); |
283 | List<uint> z_localIDs = new List<uint>(); | 285 | List<uint> z_localIDs = new List<uint>(); |
286 | Dictionary<uint, DrawStruct> z_sort = new Dictionary<uint, DrawStruct>(); | ||
284 | 287 | ||
285 | lock (objs) | 288 | try |
286 | { | 289 | { |
287 | foreach (EntityBase obj in objs) | 290 | //SortedList<float, RectangleDrawStruct> z_sort = new SortedList<float, RectangleDrawStruct>(); |
291 | |||
292 | lock (objs) | ||
288 | { | 293 | { |
289 | // Only draw the contents of SceneObjectGroup | 294 | foreach (EntityBase obj in objs) |
290 | if (obj is SceneObjectGroup) | ||
291 | { | 295 | { |
292 | SceneObjectGroup mapdot = (SceneObjectGroup)obj; | 296 | // Only draw the contents of SceneObjectGroup |
293 | Color mapdotspot = Color.Gray; // Default color when prim color is white | 297 | if (obj is SceneObjectGroup) |
294 | |||
295 | // Loop over prim in group | ||
296 | foreach (SceneObjectPart part in mapdot.Parts) | ||
297 | { | 298 | { |
298 | if (part == null) | 299 | SceneObjectGroup mapdot = (SceneObjectGroup)obj; |
299 | continue; | 300 | Color mapdotspot = Color.Gray; // Default color when prim color is white |
300 | 301 | ||
301 | // Draw if the object is at least 1 meter wide in any direction | 302 | // Loop over prim in group |
302 | if (part.Scale.X > 1f || part.Scale.Y > 1f || part.Scale.Z > 1f) | 303 | foreach (SceneObjectPart part in mapdot.Parts) |
303 | { | 304 | { |
304 | // Try to get the RGBA of the default texture entry.. | 305 | if (part == null) |
305 | // | 306 | continue; |
306 | try | 307 | |
308 | // Draw if the object is at least 1 meter wide in any direction | ||
309 | if (part.Scale.X > 1f || part.Scale.Y > 1f || part.Scale.Z > 1f) | ||
307 | { | 310 | { |
308 | // get the null checks out of the way | 311 | // Try to get the RGBA of the default texture entry.. |
309 | // skip the ones that break | 312 | // |
310 | if (part == null) | 313 | try |
311 | continue; | 314 | { |
315 | // get the null checks out of the way | ||
316 | // skip the ones that break | ||
317 | if (part == null) | ||
318 | continue; | ||
312 | 319 | ||
313 | if (part.Shape == null) | 320 | if (part.Shape == null) |
314 | continue; | 321 | continue; |
315 | 322 | ||
316 | if (part.Shape.PCode == (byte)PCode.Tree || part.Shape.PCode == (byte)PCode.NewTree || part.Shape.PCode == (byte)PCode.Grass) | 323 | if (part.Shape.PCode == (byte)PCode.Tree || part.Shape.PCode == (byte)PCode.NewTree || part.Shape.PCode == (byte)PCode.Grass) |
317 | continue; // eliminates trees from this since we don't really have a good tree representation | 324 | continue; // eliminates trees from this since we don't really have a good tree representation |
318 | // if you want tree blocks on the map comment the above line and uncomment the below line | 325 | // if you want tree blocks on the map comment the above line and uncomment the below line |
319 | //mapdotspot = Color.PaleGreen; | 326 | //mapdotspot = Color.PaleGreen; |
320 | 327 | ||
321 | Primitive.TextureEntry textureEntry = part.Shape.Textures; | 328 | Primitive.TextureEntry textureEntry = part.Shape.Textures; |
322 | 329 | ||
323 | if (textureEntry == null || textureEntry.DefaultTexture == null) | 330 | if (textureEntry == null || textureEntry.DefaultTexture == null) |
324 | continue; | 331 | continue; |
325 | 332 | ||
326 | Color4 texcolor = textureEntry.DefaultTexture.RGBA; | 333 | Color4 texcolor = textureEntry.DefaultTexture.RGBA; |
327 | 334 | ||
328 | // Not sure why some of these are null, oh well. | 335 | // Not sure why some of these are null, oh well. |
329 | 336 | ||
330 | int colorr = 255 - (int)(texcolor.R * 255f); | 337 | int colorr = 255 - (int)(texcolor.R * 255f); |
331 | int colorg = 255 - (int)(texcolor.G * 255f); | 338 | int colorg = 255 - (int)(texcolor.G * 255f); |
332 | int colorb = 255 - (int)(texcolor.B * 255f); | 339 | int colorb = 255 - (int)(texcolor.B * 255f); |
333 | 340 | ||
334 | if (!(colorr == 255 && colorg == 255 && colorb == 255)) | 341 | if (!(colorr == 255 && colorg == 255 && colorb == 255)) |
335 | { | ||
336 | //Try to set the map spot color | ||
337 | try | ||
338 | { | ||
339 | // If the color gets goofy somehow, skip it *shakes fist at Color4 | ||
340 | mapdotspot = Color.FromArgb(colorr, colorg, colorb); | ||
341 | } | ||
342 | catch (ArgumentException) | ||
343 | { | 342 | { |
343 | //Try to set the map spot color | ||
344 | try | ||
345 | { | ||
346 | // If the color gets goofy somehow, skip it *shakes fist at Color4 | ||
347 | mapdotspot = Color.FromArgb(colorr, colorg, colorb); | ||
348 | } | ||
349 | catch (ArgumentException) | ||
350 | { | ||
351 | } | ||
344 | } | 352 | } |
345 | } | 353 | } |
346 | } | 354 | catch (IndexOutOfRangeException) |
347 | catch (IndexOutOfRangeException) | 355 | { |
348 | { | 356 | // Windows Array |
349 | // Windows Array | 357 | } |
350 | } | 358 | catch (ArgumentOutOfRangeException) |
351 | catch (ArgumentOutOfRangeException) | 359 | { |
352 | { | 360 | // Mono Array |
353 | // Mono Array | 361 | } |
354 | } | ||
355 | |||
356 | Vector3 pos = part.GetWorldPosition(); | ||
357 | |||
358 | // skip prim outside of retion | ||
359 | if (pos.X < 0f || pos.X > 256f || pos.Y < 0f || pos.Y > 256f) | ||
360 | continue; | ||
361 | |||
362 | // skip prim in non-finite position | ||
363 | if (Single.IsNaN(pos.X) || Single.IsNaN(pos.Y) || | ||
364 | Single.IsInfinity(pos.X) || Single.IsInfinity(pos.Y)) | ||
365 | continue; | ||
366 | |||
367 | // Figure out if object is under 256m above the height of the terrain | ||
368 | bool isBelow256AboveTerrain = false; | ||
369 | 362 | ||
370 | try | 363 | Vector3 pos = part.GetWorldPosition(); |
371 | { | ||
372 | isBelow256AboveTerrain = (pos.Z < ((float)hm[(int)pos.X, (int)pos.Y] + 256f)); | ||
373 | } | ||
374 | catch (Exception) | ||
375 | { | ||
376 | } | ||
377 | 364 | ||
378 | if (isBelow256AboveTerrain) | 365 | // skip prim outside of retion |
379 | { | 366 | if (pos.X < 0f || pos.X > 256f || pos.Y < 0f || pos.Y > 256f) |
380 | // Translate scale by rotation so scale is represented properly when object is rotated | ||
381 | Vector3 lscale = new Vector3(part.Shape.Scale.X, part.Shape.Scale.Y, part.Shape.Scale.Z); | ||
382 | Vector3 scale = new Vector3(); | ||
383 | Vector3 tScale = new Vector3(); | ||
384 | Vector3 axPos = new Vector3(pos.X,pos.Y,pos.Z); | ||
385 | |||
386 | Quaternion llrot = part.GetWorldRotation(); | ||
387 | Quaternion rot = new Quaternion(llrot.W, llrot.X, llrot.Y, llrot.Z); | ||
388 | scale = lscale * rot; | ||
389 | |||
390 | // negative scales don't work in this situation | ||
391 | scale.X = Math.Abs(scale.X); | ||
392 | scale.Y = Math.Abs(scale.Y); | ||
393 | scale.Z = Math.Abs(scale.Z); | ||
394 | |||
395 | // This scaling isn't very accurate and doesn't take into account the face rotation :P | ||
396 | int mapdrawstartX = (int)(pos.X - scale.X); | ||
397 | int mapdrawstartY = (int)(pos.Y - scale.Y); | ||
398 | int mapdrawendX = (int)(pos.X + scale.X); | ||
399 | int mapdrawendY = (int)(pos.Y + scale.Y); | ||
400 | |||
401 | // If object is beyond the edge of the map, don't draw it to avoid errors | ||
402 | if (mapdrawstartX < 0 || mapdrawstartX > ((int)Constants.RegionSize - 1) || mapdrawendX < 0 || mapdrawendX > ((int)Constants.RegionSize - 1) | ||
403 | || mapdrawstartY < 0 || mapdrawstartY > ((int)Constants.RegionSize - 1) || mapdrawendY < 0 | ||
404 | || mapdrawendY > ((int)Constants.RegionSize - 1)) | ||
405 | continue; | 367 | continue; |
406 | 368 | ||
407 | #region obb face reconstruction part duex | 369 | // skip prim in non-finite position |
408 | Vector3[] vertexes = new Vector3[8]; | 370 | if (Single.IsNaN(pos.X) || Single.IsNaN(pos.Y) || |
409 | 371 | Single.IsInfinity(pos.X) || Single.IsInfinity(pos.Y)) | |
410 | // float[] distance = new float[6]; | 372 | continue; |
411 | Vector3[] FaceA = new Vector3[6]; // vertex A for Facei | ||
412 | Vector3[] FaceB = new Vector3[6]; // vertex B for Facei | ||
413 | Vector3[] FaceC = new Vector3[6]; // vertex C for Facei | ||
414 | Vector3[] FaceD = new Vector3[6]; // vertex D for Facei | ||
415 | |||
416 | tScale = new Vector3(lscale.X, -lscale.Y, lscale.Z); | ||
417 | scale = ((tScale * rot)); | ||
418 | vertexes[0] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); | ||
419 | // vertexes[0].x = pos.X + vertexes[0].x; | ||
420 | //vertexes[0].y = pos.Y + vertexes[0].y; | ||
421 | //vertexes[0].z = pos.Z + vertexes[0].z; | ||
422 | |||
423 | FaceA[0] = vertexes[0]; | ||
424 | FaceB[3] = vertexes[0]; | ||
425 | FaceA[4] = vertexes[0]; | ||
426 | |||
427 | tScale = lscale; | ||
428 | scale = ((tScale * rot)); | ||
429 | vertexes[1] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); | ||
430 | |||
431 | // vertexes[1].x = pos.X + vertexes[1].x; | ||
432 | // vertexes[1].y = pos.Y + vertexes[1].y; | ||
433 | //vertexes[1].z = pos.Z + vertexes[1].z; | ||
434 | |||
435 | FaceB[0] = vertexes[1]; | ||
436 | FaceA[1] = vertexes[1]; | ||
437 | FaceC[4] = vertexes[1]; | ||
438 | |||
439 | tScale = new Vector3(lscale.X, -lscale.Y, -lscale.Z); | ||
440 | scale = ((tScale * rot)); | ||
441 | |||
442 | vertexes[2] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); | ||
443 | |||
444 | //vertexes[2].x = pos.X + vertexes[2].x; | ||
445 | //vertexes[2].y = pos.Y + vertexes[2].y; | ||
446 | //vertexes[2].z = pos.Z + vertexes[2].z; | ||
447 | |||
448 | FaceC[0] = vertexes[2]; | ||
449 | FaceD[3] = vertexes[2]; | ||
450 | FaceC[5] = vertexes[2]; | ||
451 | |||
452 | tScale = new Vector3(lscale.X, lscale.Y, -lscale.Z); | ||
453 | scale = ((tScale * rot)); | ||
454 | vertexes[3] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); | ||
455 | |||
456 | //vertexes[3].x = pos.X + vertexes[3].x; | ||
457 | // vertexes[3].y = pos.Y + vertexes[3].y; | ||
458 | // vertexes[3].z = pos.Z + vertexes[3].z; | ||
459 | |||
460 | FaceD[0] = vertexes[3]; | ||
461 | FaceC[1] = vertexes[3]; | ||
462 | FaceA[5] = vertexes[3]; | ||
463 | |||
464 | tScale = new Vector3(-lscale.X, lscale.Y, lscale.Z); | ||
465 | scale = ((tScale * rot)); | ||
466 | vertexes[4] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); | ||
467 | |||
468 | // vertexes[4].x = pos.X + vertexes[4].x; | ||
469 | // vertexes[4].y = pos.Y + vertexes[4].y; | ||
470 | // vertexes[4].z = pos.Z + vertexes[4].z; | ||
471 | |||
472 | FaceB[1] = vertexes[4]; | ||
473 | FaceA[2] = vertexes[4]; | ||
474 | FaceD[4] = vertexes[4]; | ||
475 | |||
476 | tScale = new Vector3(-lscale.X, lscale.Y, -lscale.Z); | ||
477 | scale = ((tScale * rot)); | ||
478 | vertexes[5] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); | ||
479 | |||
480 | // vertexes[5].x = pos.X + vertexes[5].x; | ||
481 | // vertexes[5].y = pos.Y + vertexes[5].y; | ||
482 | // vertexes[5].z = pos.Z + vertexes[5].z; | ||
483 | |||
484 | FaceD[1] = vertexes[5]; | ||
485 | FaceC[2] = vertexes[5]; | ||
486 | FaceB[5] = vertexes[5]; | ||
487 | 373 | ||
488 | tScale = new Vector3(-lscale.X, -lscale.Y, lscale.Z); | 374 | // Figure out if object is under 256m above the height of the terrain |
489 | scale = ((tScale * rot)); | 375 | bool isBelow256AboveTerrain = false; |
490 | vertexes[6] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); | ||
491 | 376 | ||
492 | // vertexes[6].x = pos.X + vertexes[6].x; | 377 | try |
493 | // vertexes[6].y = pos.Y + vertexes[6].y; | 378 | { |
494 | // vertexes[6].z = pos.Z + vertexes[6].z; | 379 | isBelow256AboveTerrain = (pos.Z < ((float)hm[(int)pos.X, (int)pos.Y] + 256f)); |
380 | } | ||
381 | catch (Exception) | ||
382 | { | ||
383 | } | ||
495 | 384 | ||
496 | FaceB[2] = vertexes[6]; | 385 | if (isBelow256AboveTerrain) |
497 | FaceA[3] = vertexes[6]; | 386 | { |
498 | FaceB[4] = vertexes[6]; | 387 | // Translate scale by rotation so scale is represented properly when object is rotated |
388 | Vector3 lscale = new Vector3(part.Shape.Scale.X, part.Shape.Scale.Y, part.Shape.Scale.Z); | ||
389 | Vector3 scale = new Vector3(); | ||
390 | Vector3 tScale = new Vector3(); | ||
391 | Vector3 axPos = new Vector3(pos.X,pos.Y,pos.Z); | ||
392 | |||
393 | Quaternion llrot = part.GetWorldRotation(); | ||
394 | Quaternion rot = new Quaternion(llrot.W, llrot.X, llrot.Y, llrot.Z); | ||
395 | scale = lscale * rot; | ||
396 | |||
397 | // negative scales don't work in this situation | ||
398 | scale.X = Math.Abs(scale.X); | ||
399 | scale.Y = Math.Abs(scale.Y); | ||
400 | scale.Z = Math.Abs(scale.Z); | ||
401 | |||
402 | // This scaling isn't very accurate and doesn't take into account the face rotation :P | ||
403 | int mapdrawstartX = (int)(pos.X - scale.X); | ||
404 | int mapdrawstartY = (int)(pos.Y - scale.Y); | ||
405 | int mapdrawendX = (int)(pos.X + scale.X); | ||
406 | int mapdrawendY = (int)(pos.Y + scale.Y); | ||
407 | |||
408 | // If object is beyond the edge of the map, don't draw it to avoid errors | ||
409 | if (mapdrawstartX < 0 || mapdrawstartX > ((int)Constants.RegionSize - 1) || mapdrawendX < 0 || mapdrawendX > ((int)Constants.RegionSize - 1) | ||
410 | || mapdrawstartY < 0 || mapdrawstartY > ((int)Constants.RegionSize - 1) || mapdrawendY < 0 | ||
411 | || mapdrawendY > ((int)Constants.RegionSize - 1)) | ||
412 | continue; | ||
413 | |||
414 | #region obb face reconstruction part duex | ||
415 | Vector3[] vertexes = new Vector3[8]; | ||
416 | |||
417 | // float[] distance = new float[6]; | ||
418 | Vector3[] FaceA = new Vector3[6]; // vertex A for Facei | ||
419 | Vector3[] FaceB = new Vector3[6]; // vertex B for Facei | ||
420 | Vector3[] FaceC = new Vector3[6]; // vertex C for Facei | ||
421 | Vector3[] FaceD = new Vector3[6]; // vertex D for Facei | ||
422 | |||
423 | tScale = new Vector3(lscale.X, -lscale.Y, lscale.Z); | ||
424 | scale = ((tScale * rot)); | ||
425 | vertexes[0] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); | ||
426 | // vertexes[0].x = pos.X + vertexes[0].x; | ||
427 | //vertexes[0].y = pos.Y + vertexes[0].y; | ||
428 | //vertexes[0].z = pos.Z + vertexes[0].z; | ||
429 | |||
430 | FaceA[0] = vertexes[0]; | ||
431 | FaceB[3] = vertexes[0]; | ||
432 | FaceA[4] = vertexes[0]; | ||
433 | |||
434 | tScale = lscale; | ||
435 | scale = ((tScale * rot)); | ||
436 | vertexes[1] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); | ||
437 | |||
438 | // vertexes[1].x = pos.X + vertexes[1].x; | ||
439 | // vertexes[1].y = pos.Y + vertexes[1].y; | ||
440 | //vertexes[1].z = pos.Z + vertexes[1].z; | ||
441 | |||
442 | FaceB[0] = vertexes[1]; | ||
443 | FaceA[1] = vertexes[1]; | ||
444 | FaceC[4] = vertexes[1]; | ||
445 | |||
446 | tScale = new Vector3(lscale.X, -lscale.Y, -lscale.Z); | ||
447 | scale = ((tScale * rot)); | ||
448 | |||
449 | vertexes[2] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); | ||
450 | |||
451 | //vertexes[2].x = pos.X + vertexes[2].x; | ||
452 | //vertexes[2].y = pos.Y + vertexes[2].y; | ||
453 | //vertexes[2].z = pos.Z + vertexes[2].z; | ||
454 | |||
455 | FaceC[0] = vertexes[2]; | ||
456 | FaceD[3] = vertexes[2]; | ||
457 | FaceC[5] = vertexes[2]; | ||
458 | |||
459 | tScale = new Vector3(lscale.X, lscale.Y, -lscale.Z); | ||
460 | scale = ((tScale * rot)); | ||
461 | vertexes[3] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); | ||
462 | |||
463 | //vertexes[3].x = pos.X + vertexes[3].x; | ||
464 | // vertexes[3].y = pos.Y + vertexes[3].y; | ||
465 | // vertexes[3].z = pos.Z + vertexes[3].z; | ||
466 | |||
467 | FaceD[0] = vertexes[3]; | ||
468 | FaceC[1] = vertexes[3]; | ||
469 | FaceA[5] = vertexes[3]; | ||
470 | |||
471 | tScale = new Vector3(-lscale.X, lscale.Y, lscale.Z); | ||
472 | scale = ((tScale * rot)); | ||
473 | vertexes[4] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); | ||
474 | |||
475 | // vertexes[4].x = pos.X + vertexes[4].x; | ||
476 | // vertexes[4].y = pos.Y + vertexes[4].y; | ||
477 | // vertexes[4].z = pos.Z + vertexes[4].z; | ||
478 | |||
479 | FaceB[1] = vertexes[4]; | ||
480 | FaceA[2] = vertexes[4]; | ||
481 | FaceD[4] = vertexes[4]; | ||
482 | |||
483 | tScale = new Vector3(-lscale.X, lscale.Y, -lscale.Z); | ||
484 | scale = ((tScale * rot)); | ||
485 | vertexes[5] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); | ||
486 | |||
487 | // vertexes[5].x = pos.X + vertexes[5].x; | ||
488 | // vertexes[5].y = pos.Y + vertexes[5].y; | ||
489 | // vertexes[5].z = pos.Z + vertexes[5].z; | ||
490 | |||
491 | FaceD[1] = vertexes[5]; | ||
492 | FaceC[2] = vertexes[5]; | ||
493 | FaceB[5] = vertexes[5]; | ||
494 | |||
495 | tScale = new Vector3(-lscale.X, -lscale.Y, lscale.Z); | ||
496 | scale = ((tScale * rot)); | ||
497 | vertexes[6] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); | ||
498 | |||
499 | // vertexes[6].x = pos.X + vertexes[6].x; | ||
500 | // vertexes[6].y = pos.Y + vertexes[6].y; | ||
501 | // vertexes[6].z = pos.Z + vertexes[6].z; | ||
502 | |||
503 | FaceB[2] = vertexes[6]; | ||
504 | FaceA[3] = vertexes[6]; | ||
505 | FaceB[4] = vertexes[6]; | ||
499 | 506 | ||
500 | tScale = new Vector3(-lscale.X, -lscale.Y, -lscale.Z); | 507 | tScale = new Vector3(-lscale.X, -lscale.Y, -lscale.Z); |
501 | scale = ((tScale * rot)); | 508 | scale = ((tScale * rot)); |
502 | vertexes[7] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); | 509 | vertexes[7] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); |
503 | 510 | ||
504 | // vertexes[7].x = pos.X + vertexes[7].x; | 511 | // vertexes[7].x = pos.X + vertexes[7].x; |
505 | // vertexes[7].y = pos.Y + vertexes[7].y; | 512 | // vertexes[7].y = pos.Y + vertexes[7].y; |
506 | // vertexes[7].z = pos.Z + vertexes[7].z; | 513 | // vertexes[7].z = pos.Z + vertexes[7].z; |
507 | 514 | ||
508 | FaceD[2] = vertexes[7]; | 515 | FaceD[2] = vertexes[7]; |
509 | FaceC[3] = vertexes[7]; | 516 | FaceC[3] = vertexes[7]; |
510 | FaceD[5] = vertexes[7]; | 517 | FaceD[5] = vertexes[7]; |
511 | #endregion | 518 | #endregion |
512 | 519 | ||
513 | //int wy = 0; | 520 | //int wy = 0; |
514 | 521 | ||
515 | //bool breakYN = false; // If we run into an error drawing, break out of the | 522 | //bool breakYN = false; // If we run into an error drawing, break out of the |
516 | // loop so we don't lag to death on error handling | 523 | // loop so we don't lag to death on error handling |
517 | DrawStruct ds = new DrawStruct(); | 524 | DrawStruct ds = new DrawStruct(); |
518 | ds.brush = new SolidBrush(mapdotspot); | 525 | ds.brush = new SolidBrush(mapdotspot); |
519 | //ds.rect = new Rectangle(mapdrawstartX, (255 - mapdrawstartY), mapdrawendX - mapdrawstartX, mapdrawendY - mapdrawstartY); | 526 | //ds.rect = new Rectangle(mapdrawstartX, (255 - mapdrawstartY), mapdrawendX - mapdrawstartX, mapdrawendY - mapdrawstartY); |
520 | 527 | ||
521 | ds.trns = new face[FaceA.Length]; | 528 | ds.trns = new face[FaceA.Length]; |
522 | 529 | ||
523 | for (int i = 0; i < FaceA.Length; i++) | 530 | for (int i = 0; i < FaceA.Length; i++) |
524 | { | 531 | { |
525 | Point[] working = new Point[5]; | 532 | Point[] working = new Point[5]; |
526 | working[0] = project(FaceA[i], axPos); | 533 | working[0] = project(FaceA[i], axPos); |
527 | working[1] = project(FaceB[i], axPos); | 534 | working[1] = project(FaceB[i], axPos); |
528 | working[2] = project(FaceD[i], axPos); | 535 | working[2] = project(FaceD[i], axPos); |
529 | working[3] = project(FaceC[i], axPos); | 536 | working[3] = project(FaceC[i], axPos); |
530 | working[4] = project(FaceA[i], axPos); | 537 | working[4] = project(FaceA[i], axPos); |
531 | 538 | ||
532 | face workingface = new face(); | 539 | face workingface = new face(); |
533 | workingface.pts = working; | 540 | workingface.pts = working; |
534 | 541 | ||
535 | ds.trns[i] = workingface; | 542 | ds.trns[i] = workingface; |
536 | } | 543 | } |
537 | 544 | ||
538 | z_sort.Add(part.LocalId, ds); | 545 | z_sort.Add(part.LocalId, ds); |
539 | z_localIDs.Add(part.LocalId); | 546 | z_localIDs.Add(part.LocalId); |
540 | z_sortheights.Add(pos.Z); | 547 | z_sortheights.Add(pos.Z); |
541 | 548 | ||
542 | //for (int wx = mapdrawstartX; wx < mapdrawendX; wx++) | 549 | //for (int wx = mapdrawstartX; wx < mapdrawendX; wx++) |
543 | //{ | ||
544 | //for (wy = mapdrawstartY; wy < mapdrawendY; wy++) | ||
545 | //{ | 550 | //{ |
546 | //m_log.InfoFormat("[MAPDEBUG]: {0},{1}({2})", wx, (255 - wy),wy); | 551 | //for (wy = mapdrawstartY; wy < mapdrawendY; wy++) |
547 | //try | ||
548 | //{ | ||
549 | // Remember, flip the y! | ||
550 | // mapbmp.SetPixel(wx, (255 - wy), mapdotspot); | ||
551 | //} | ||
552 | //catch (ArgumentException) | ||
553 | //{ | 552 | //{ |
554 | // breakYN = true; | 553 | //m_log.InfoFormat("[MAPDEBUG]: {0},{1}({2})", wx, (255 - wy),wy); |
554 | //try | ||
555 | //{ | ||
556 | // Remember, flip the y! | ||
557 | // mapbmp.SetPixel(wx, (255 - wy), mapdotspot); | ||
558 | //} | ||
559 | //catch (ArgumentException) | ||
560 | //{ | ||
561 | // breakYN = true; | ||
562 | //} | ||
563 | |||
564 | //if (breakYN) | ||
565 | // break; | ||
555 | //} | 566 | //} |
556 | 567 | ||
557 | //if (breakYN) | 568 | //if (breakYN) |
558 | // break; | 569 | // break; |
559 | //} | 570 | //} |
571 | } // Object is within 256m Z of terrain | ||
572 | } // object is at least a meter wide | ||
573 | } // loop over group children | ||
574 | } // entitybase is sceneobject group | ||
575 | } // foreach loop over entities | ||
560 | 576 | ||
561 | //if (breakYN) | 577 | float[] sortedZHeights = z_sortheights.ToArray(); |
562 | // break; | 578 | uint[] sortedlocalIds = z_localIDs.ToArray(); |
563 | //} | ||
564 | } // Object is within 256m Z of terrain | ||
565 | } // object is at least a meter wide | ||
566 | } // loop over group children | ||
567 | } // entitybase is sceneobject group | ||
568 | } // foreach loop over entities | ||
569 | |||
570 | float[] sortedZHeights = z_sortheights.ToArray(); | ||
571 | uint[] sortedlocalIds = z_localIDs.ToArray(); | ||
572 | |||
573 | // Sort prim by Z position | ||
574 | Array.Sort(sortedZHeights, sortedlocalIds); | ||
575 | 579 | ||
576 | Graphics g = Graphics.FromImage(mapbmp); | 580 | // Sort prim by Z position |
581 | Array.Sort(sortedZHeights, sortedlocalIds); | ||
577 | 582 | ||
578 | for (int s = 0; s < sortedZHeights.Length; s++) | 583 | using (Graphics g = Graphics.FromImage(mapbmp)) |
579 | { | ||
580 | if (z_sort.ContainsKey(sortedlocalIds[s])) | ||
581 | { | 584 | { |
582 | DrawStruct rectDrawStruct = z_sort[sortedlocalIds[s]]; | 585 | for (int s = 0; s < sortedZHeights.Length; s++) |
583 | for (int r = 0; r < rectDrawStruct.trns.Length; r++) | ||
584 | { | 586 | { |
585 | g.FillPolygon(rectDrawStruct.brush,rectDrawStruct.trns[r].pts); | 587 | if (z_sort.ContainsKey(sortedlocalIds[s])) |
588 | { | ||
589 | DrawStruct rectDrawStruct = z_sort[sortedlocalIds[s]]; | ||
590 | for (int r = 0; r < rectDrawStruct.trns.Length; r++) | ||
591 | { | ||
592 | g.FillPolygon(rectDrawStruct.brush,rectDrawStruct.trns[r].pts); | ||
593 | } | ||
594 | //g.FillRectangle(rectDrawStruct.brush , rectDrawStruct.rect); | ||
595 | } | ||
586 | } | 596 | } |
587 | //g.FillRectangle(rectDrawStruct.brush , rectDrawStruct.rect); | ||
588 | } | 597 | } |
589 | } | 598 | } // lock entities objs |
590 | 599 | ||
591 | g.Dispose(); | 600 | } |
592 | } // lock entities objs | 601 | finally |
602 | { | ||
603 | foreach (DrawStruct ds in z_sort.Values) | ||
604 | ds.brush.Dispose(); | ||
605 | } | ||
593 | 606 | ||
594 | m_log.Debug("[MAPTILE]: Generating Maptile Step 2: Done in " + (Environment.TickCount - tc) + " ms"); | 607 | m_log.Debug("[MAPTILE]: Generating Maptile Step 2: Done in " + (Environment.TickCount - tc) + " ms"); |
608 | |||
595 | return mapbmp; | 609 | return mapbmp; |
596 | } | 610 | } |
597 | 611 | ||