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