aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/World/WorldMap/MapImageModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Modules/World/WorldMap/MapImageModule.cs')
-rw-r--r--OpenSim/Region/Environment/Modules/World/WorldMap/MapImageModule.cs64
1 files changed, 18 insertions, 46 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/WorldMap/MapImageModule.cs b/OpenSim/Region/Environment/Modules/World/WorldMap/MapImageModule.cs
index 7a1c516..38c52f0 100644
--- a/OpenSim/Region/Environment/Modules/World/WorldMap/MapImageModule.cs
+++ b/OpenSim/Region/Environment/Modules/World/WorldMap/MapImageModule.cs
@@ -97,7 +97,6 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
97 DrawObjectVolume(m_scene, mapbmp); 97 DrawObjectVolume(m_scene, mapbmp);
98 } 98 }
99 99
100
101 try 100 try
102 { 101 {
103 imageData = OpenJPEG.EncodeFromImage(mapbmp, true); 102 imageData = OpenJPEG.EncodeFromImage(mapbmp, true);
@@ -153,14 +152,14 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
153// if (entity is SceneObjectGroup) 152// if (entity is SceneObjectGroup)
154// { 153// {
155// SceneObjectGroup sog = (SceneObjectGroup) entity; 154// SceneObjectGroup sog = (SceneObjectGroup) entity;
156// 155//
157// foreach (SceneObjectPart primitive in sog.Children.Values) 156// foreach (SceneObjectPart primitive in sog.Children.Values)
158// { 157// {
159// int x = (int) (primitive.AbsolutePosition.X - (primitive.Scale.X / 2)); 158// int x = (int) (primitive.AbsolutePosition.X - (primitive.Scale.X / 2));
160// int y = (int) (primitive.AbsolutePosition.Y - (primitive.Scale.Y / 2)); 159// int y = (int) (primitive.AbsolutePosition.Y - (primitive.Scale.Y / 2));
161// int w = (int) primitive.Scale.X; 160// int w = (int) primitive.Scale.X;
162// int h = (int) primitive.Scale.Y; 161// int h = (int) primitive.Scale.Y;
163// 162//
164// int dx; 163// int dx;
165// for (dx = x; dx < x + w; dx++) 164// for (dx = x; dx < x + w; dx++)
166// { 165// {
@@ -171,7 +170,7 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
171// continue; 170// continue;
172// if (x >= map.Width || y >= map.Height) 171// if (x >= map.Width || y >= map.Height)
173// continue; 172// continue;
174// 173//
175// map.SetPixel(dx, dy, Color.DarkGray); 174// map.SetPixel(dx, dy, Color.DarkGray);
176// } 175// }
177// } 176// }
@@ -189,7 +188,7 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
189 188
190 double[,] hm = whichScene.Heightmap.GetDoubles(); 189 double[,] hm = whichScene.Heightmap.GetDoubles();
191 bool ShadowDebugContinue = true; 190 bool ShadowDebugContinue = true;
192 191
193 bool terraincorruptedwarningsaid = false; 192 bool terraincorruptedwarningsaid = false;
194 193
195 float low = 255; 194 float low = 255;
@@ -220,13 +219,10 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
220 //int tc = System.Environment.TickCount; 219 //int tc = System.Environment.TickCount;
221 for (int y = 0; y < 256; y++) 220 for (int y = 0; y < 256; y++)
222 { 221 {
223
224 float heightvalue = (float)hm[x, y]; 222 float heightvalue = (float)hm[x, y];
225 223
226
227 if (heightvalue > (float)whichScene.RegionInfo.RegionSettings.WaterHeight) 224 if (heightvalue > (float)whichScene.RegionInfo.RegionSettings.WaterHeight)
228 { 225 {
229
230 // scale height value 226 // scale height value
231 heightvalue = low + mid * (heightvalue - low) / mid; 227 heightvalue = low + mid * (heightvalue - low) / mid;
232 228
@@ -238,6 +234,7 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
238 234
239 if (Single.IsInfinity(heightvalue) || Single.IsNaN(heightvalue)) 235 if (Single.IsInfinity(heightvalue) || Single.IsNaN(heightvalue))
240 heightvalue = 0; 236 heightvalue = 0;
237
241 try 238 try
242 { 239 {
243 Color green = Color.FromArgb((int)heightvalue, 100, (int)heightvalue); 240 Color green = Color.FromArgb((int)heightvalue, 100, (int)heightvalue);
@@ -264,7 +261,6 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
264 261
265 if (hfdiff > 0.3f) 262 if (hfdiff > 0.3f)
266 { 263 {
267
268 } 264 }
269 else if (hfdiff < -0.3f) 265 else if (hfdiff < -0.3f)
270 { 266 {
@@ -301,15 +297,8 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
301 mapbmp.SetPixel(x - 1, (256 - y) - 1, Shade); 297 mapbmp.SetPixel(x - 1, (256 - y) - 1, Shade);
302 } 298 }
303 } 299 }
304
305
306 } 300 }
307
308 } 301 }
309
310
311
312
313 } 302 }
314 catch (System.ArgumentException) 303 catch (System.ArgumentException)
315 { 304 {
@@ -367,7 +356,6 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
367 return mapbmp; 356 return mapbmp;
368 } 357 }
369 358
370
371 private Bitmap DrawObjectVolume(Scene whichScene, Bitmap mapbmp) 359 private Bitmap DrawObjectVolume(Scene whichScene, Bitmap mapbmp)
372 { 360 {
373 int tc = 0; 361 int tc = 0;
@@ -395,7 +383,6 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
395 if (part == null) 383 if (part == null)
396 continue; 384 continue;
397 385
398
399 // Draw if the object is at least 1 meter wide in any direction 386 // Draw if the object is at least 1 meter wide in any direction
400 if (part.Scale.X > 1f || part.Scale.Y > 1f || part.Scale.Z > 1f) 387 if (part.Scale.X > 1f || part.Scale.Y > 1f || part.Scale.Z > 1f)
401 { 388 {
@@ -459,8 +446,8 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
459 continue; 446 continue;
460 447
461 // skip prim in non-finite position 448 // skip prim in non-finite position
462 if (Single.IsNaN(pos.X) || Single.IsNaN(pos.Y) || Single.IsInfinity(pos.X) 449 if (Single.IsNaN(pos.X) || Single.IsNaN(pos.Y) ||
463 || Single.IsInfinity(pos.Y)) 450 Single.IsInfinity(pos.X) || Single.IsInfinity(pos.Y))
464 continue; 451 continue;
465 452
466 // Figure out if object is under 256m above the height of the terrain 453 // Figure out if object is under 256m above the height of the terrain
@@ -481,7 +468,6 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
481 Vector3 scale = new Vector3(); 468 Vector3 scale = new Vector3();
482 Vector3 tScale = new Vector3(); 469 Vector3 tScale = new Vector3();
483 Vector3 axPos = new Vector3(pos.X,pos.Y,pos.Z); 470 Vector3 axPos = new Vector3(pos.X,pos.Y,pos.Z);
484
485 471
486 LLQuaternion llrot = part.GetWorldRotation(); 472 LLQuaternion llrot = part.GetWorldRotation();
487 Quaternion rot = new Quaternion(llrot.W, llrot.X, llrot.Y, llrot.Z); 473 Quaternion rot = new Quaternion(llrot.W, llrot.X, llrot.Y, llrot.Z);
@@ -609,7 +595,7 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
609 FaceC[3] = vertexes[7]; 595 FaceC[3] = vertexes[7];
610 FaceD[5] = vertexes[7]; 596 FaceD[5] = vertexes[7];
611#endregion 597#endregion
612 598
613 //int wy = 0; 599 //int wy = 0;
614 600
615 //bool breakYN = false; // If we run into an error drawing, break out of the 601 //bool breakYN = false; // If we run into an error drawing, break out of the
@@ -618,14 +604,10 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
618 ds.brush = new SolidBrush(mapdotspot); 604 ds.brush = new SolidBrush(mapdotspot);
619 //ds.rect = new Rectangle(mapdrawstartX, (255 - mapdrawstartY), mapdrawendX - mapdrawstartX, mapdrawendY - mapdrawstartY); 605 //ds.rect = new Rectangle(mapdrawstartX, (255 - mapdrawstartY), mapdrawendX - mapdrawstartX, mapdrawendY - mapdrawstartY);
620 606
621
622 ds.trns = new face[FaceA.Length]; 607 ds.trns = new face[FaceA.Length];
623 608
624
625
626 for (int i = 0; i < FaceA.Length; i++) 609 for (int i = 0; i < FaceA.Length; i++)
627 { 610 {
628
629 Point[] working = new Point[5]; 611 Point[] working = new Point[5];
630 working[0] = project(FaceA[i], axPos); 612 working[0] = project(FaceA[i], axPos);
631 working[1] = project(FaceB[i], axPos); 613 working[1] = project(FaceB[i], axPos);
@@ -635,20 +617,14 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
635 617
636 face workingface = new face(); 618 face workingface = new face();
637 workingface.pts = working; 619 workingface.pts = working;
638 620
639 ds.trns[i] = workingface; 621 ds.trns[i] = workingface;
640
641 } 622 }
642 623
643
644
645
646 z_sort.Add(part.LocalId, ds); 624 z_sort.Add(part.LocalId, ds);
647 z_localIDs.Add(part.LocalId); 625 z_localIDs.Add(part.LocalId);
648 z_sortheights.Add(pos.Z); 626 z_sortheights.Add(pos.Z);
649 627
650
651
652 //for (int wx = mapdrawstartX; wx < mapdrawendX; wx++) 628 //for (int wx = mapdrawstartX; wx < mapdrawendX; wx++)
653 //{ 629 //{
654 //for (wy = mapdrawstartY; wy < mapdrawendY; wy++) 630 //for (wy = mapdrawstartY; wy < mapdrawendY; wy++)
@@ -676,20 +652,17 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
676 } // loop over group children 652 } // loop over group children
677 } // entitybase is sceneobject group 653 } // entitybase is sceneobject group
678 } // foreach loop over entities 654 } // foreach loop over entities
679 655
680 float[] sortedZHeights = z_sortheights.ToArray(); 656 float[] sortedZHeights = z_sortheights.ToArray();
681 uint[] sortedlocalIds = z_localIDs.ToArray(); 657 uint[] sortedlocalIds = z_localIDs.ToArray();
682 658
683 // Sort prim by Z position 659 // Sort prim by Z position
684 Array.Sort(sortedZHeights, sortedlocalIds); 660 Array.Sort(sortedZHeights, sortedlocalIds);
685 661
686
687
688 Graphics g = Graphics.FromImage(mapbmp); 662 Graphics g = Graphics.FromImage(mapbmp);
689 663
690 for (int s = 0; s < sortedZHeights.Length; s++) 664 for (int s = 0; s < sortedZHeights.Length; s++)
691 { 665 {
692
693 if (z_sort.ContainsKey(sortedlocalIds[s])) 666 if (z_sort.ContainsKey(sortedlocalIds[s]))
694 { 667 {
695 DrawStruct rectDrawStruct = z_sort[sortedlocalIds[s]]; 668 DrawStruct rectDrawStruct = z_sort[sortedlocalIds[s]];
@@ -701,13 +674,13 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
701 } 674 }
702 } 675 }
703 676
704
705 g.Dispose(); 677 g.Dispose();
706 } // lock entities objs 678 } // lock entities objs
707 679
708 m_log.Info("[MAPTILE]: Generating Maptile Step 2: Done in " + (System.Environment.TickCount - tc) + " ms"); 680 m_log.Info("[MAPTILE]: Generating Maptile Step 2: Done in " + (System.Environment.TickCount - tc) + " ms");
709 return mapbmp; 681 return mapbmp;
710 } 682 }
683
711 private Point project(Vector3 point3d, Vector3 originpos) 684 private Point project(Vector3 point3d, Vector3 originpos)
712 { 685 {
713 Point returnpt = new Point(); 686 Point returnpt = new Point();
@@ -716,12 +689,11 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
716 689
717 //Vector3 topos = new Vector3(0, 0, 0); 690 //Vector3 topos = new Vector3(0, 0, 0);
718 // float z = -point3d.z - topos.z; 691 // float z = -point3d.z - topos.z;
719 692
720 returnpt.X = (int)point3d.x;//(int)((topos.x - point3d.x) / z * d); 693 returnpt.X = (int)point3d.x;//(int)((topos.x - point3d.x) / z * d);
721 returnpt.Y = (int)(255 - point3d.y);//(int)(255 - (((topos.y - point3d.y) / z * d))); 694 returnpt.Y = (int)(255 - point3d.y);//(int)(255 - (((topos.y - point3d.y) / z * d)));
722 695
723 return returnpt; 696 return returnpt;
724
725 } 697 }
726 698
727// TODO: unused: 699// TODO: unused:
@@ -729,17 +701,17 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
729// private Bitmap TerrainToBitmap(string gradientmap) 701// private Bitmap TerrainToBitmap(string gradientmap)
730// { 702// {
731// Bitmap gradientmapLd = new Bitmap(gradientmap); 703// Bitmap gradientmapLd = new Bitmap(gradientmap);
732// 704//
733// int pallete = gradientmapLd.Height; 705// int pallete = gradientmapLd.Height;
734// 706//
735// Bitmap bmp = new Bitmap(m_scene.Heightmap.Width, m_scene.Heightmap.Height); 707// Bitmap bmp = new Bitmap(m_scene.Heightmap.Width, m_scene.Heightmap.Height);
736// Color[] colours = new Color[pallete]; 708// Color[] colours = new Color[pallete];
737// 709//
738// for (int i = 0; i < pallete; i++) 710// for (int i = 0; i < pallete; i++)
739// { 711// {
740// colours[i] = gradientmapLd.GetPixel(0, i); 712// colours[i] = gradientmapLd.GetPixel(0, i);
741// } 713// }
742// 714//
743// lock (m_scene.Heightmap) 715// lock (m_scene.Heightmap)
744// { 716// {
745// ITerrainChannel copy = m_scene.Heightmap; 717// ITerrainChannel copy = m_scene.Heightmap;
@@ -749,7 +721,7 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
749// { 721// {
750// // 512 is the largest possible height before colours clamp 722// // 512 is the largest possible height before colours clamp
751// int colorindex = (int) (Math.Max(Math.Min(1.0, copy[x, y] / 512.0), 0.0) * (pallete - 1)); 723// int colorindex = (int) (Math.Max(Math.Min(1.0, copy[x, y] / 512.0), 0.0) * (pallete - 1));
752// 724//
753// // Handle error conditions 725// // Handle error conditions
754// if (colorindex > pallete - 1 || colorindex < 0) 726// if (colorindex > pallete - 1 || colorindex < 0)
755// bmp.SetPixel(x, copy.Height - y - 1, Color.Red); 727// bmp.SetPixel(x, copy.Height - y - 1, Color.Red);