diff options
author | Teravus Ovares | 2008-04-10 13:37:39 +0000 |
---|---|---|
committer | Teravus Ovares | 2008-04-10 13:37:39 +0000 |
commit | 1178eddffcfb5e34a82fb9dc8e2feb9f909e56f1 (patch) | |
tree | d20684236d7bafa16fc40b8519f197fc74bd3317 /OpenSim/Region | |
parent | comment out OpenSim.Model until first class is added, (diff) | |
download | opensim-SC_OLD-1178eddffcfb5e34a82fb9dc8e2feb9f909e56f1.zip opensim-SC_OLD-1178eddffcfb5e34a82fb9dc8e2feb9f909e56f1.tar.gz opensim-SC_OLD-1178eddffcfb5e34a82fb9dc8e2feb9f909e56f1.tar.bz2 opensim-SC_OLD-1178eddffcfb5e34a82fb9dc8e2feb9f909e56f1.tar.xz |
* Brings back map tile generation based on the terrain. The algorithm produces a graphic that is a bit Dazzle-ish. A Dazzle-ish map tile is better then a grey map tile IMHO.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Environment/Scenes/Scene.cs | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 4a57c5d..eb5fe56 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs | |||
@@ -988,6 +988,114 @@ namespace OpenSim.Region.Environment.Scenes | |||
988 | 988 | ||
989 | //create a texture asset of the terrain | 989 | //create a texture asset of the terrain |
990 | ITerrainTemp terrain = RequestModuleInterface<ITerrainTemp>(); | 990 | ITerrainTemp terrain = RequestModuleInterface<ITerrainTemp>(); |
991 | |||
992 | if (Heightmap != null) | ||
993 | { | ||
994 | Bitmap mapbmp = new Bitmap(256, 256); | ||
995 | double[,] hm = Heightmap.GetDoubles(); | ||
996 | |||
997 | float heightvalue = 0; | ||
998 | |||
999 | Color water = Color.FromArgb(0, 0, 255); | ||
1000 | Color prim = Color.FromArgb(120, 120, 120); | ||
1001 | LLVector3 RayEnd = new LLVector3(0, 0, 0); | ||
1002 | LLVector3 RayStart = new LLVector3(0, 0, 0); | ||
1003 | LLVector3 direction = new LLVector3(0, 0, -1); | ||
1004 | Vector3 AXOrigin = new Vector3(); | ||
1005 | Vector3 AXdirection = new Vector3(); | ||
1006 | Ray testRay = new Ray(); | ||
1007 | EntityIntersection rt = new EntityIntersection(); | ||
1008 | |||
1009 | float low = 255; | ||
1010 | float high = 0; | ||
1011 | for (int x = 0; x < 256; x++) | ||
1012 | { | ||
1013 | for (int y = 0; y < 256; y++) | ||
1014 | { | ||
1015 | float hmval = (float)hm[x, y]; | ||
1016 | if (hmval < low) | ||
1017 | low = hmval; | ||
1018 | if (hmval > high) | ||
1019 | high = hmval; | ||
1020 | } | ||
1021 | } | ||
1022 | |||
1023 | float mid = (high + low) * 0.5f; | ||
1024 | for (int x = 0; x < 256; x++) | ||
1025 | { | ||
1026 | //int tc = System.Environment.TickCount; | ||
1027 | for (int y = 0; y < 256; y++) | ||
1028 | { | ||
1029 | //RayEnd = new LLVector3(x, y, 0); | ||
1030 | //RayStart = new LLVector3(x, y, 255); | ||
1031 | |||
1032 | //direction = LLVector3.Norm(RayEnd - RayStart); | ||
1033 | //AXOrigin = new Vector3(RayStart.X, RayStart.Y, RayStart.Z); | ||
1034 | //AXdirection = new Vector3(direction.X, direction.Y, direction.Z); | ||
1035 | |||
1036 | //testRay = new Ray(AXOrigin, AXdirection); | ||
1037 | //rt = m_innerScene.GetClosestIntersectingPrim(testRay); | ||
1038 | |||
1039 | //if (rt.HitTF) | ||
1040 | //{ | ||
1041 | //mapbmp.SetPixel(x, y, prim); | ||
1042 | //} | ||
1043 | //else | ||
1044 | //{ | ||
1045 | //float tmpval = (float)hm[x, y]; | ||
1046 | heightvalue = (float)hm[x, y]; | ||
1047 | |||
1048 | if ((float)heightvalue > m_regInfo.EstateSettings.waterHeight) | ||
1049 | { | ||
1050 | // scale height value | ||
1051 | heightvalue = low + mid * (heightvalue - low) / mid; | ||
1052 | |||
1053 | if (heightvalue > 255) | ||
1054 | heightvalue = 255; | ||
1055 | |||
1056 | if (heightvalue < 0) | ||
1057 | heightvalue = 0; | ||
1058 | |||
1059 | |||
1060 | Color green = Color.FromArgb((int)heightvalue, 100, (int)heightvalue); | ||
1061 | |||
1062 | // Y flip the cordinates | ||
1063 | mapbmp.SetPixel(x, (256 - y) - 1, green); | ||
1064 | } | ||
1065 | else | ||
1066 | { | ||
1067 | // Y flip the cordinates | ||
1068 | mapbmp.SetPixel(x, (256 - y) - 1, water); | ||
1069 | } | ||
1070 | //} | ||
1071 | |||
1072 | |||
1073 | } | ||
1074 | //tc = System.Environment.TickCount - tc; | ||
1075 | //m_log.Info("[MAPTILE]: Completed One row in " + tc + " ms"); | ||
1076 | } | ||
1077 | byte[] data; | ||
1078 | try | ||
1079 | { | ||
1080 | data = OpenJPEGNet.OpenJPEG.EncodeFromImage(mapbmp, false); | ||
1081 | } | ||
1082 | catch (Exception) | ||
1083 | { | ||
1084 | return; | ||
1085 | } | ||
1086 | |||
1087 | m_regInfo.EstateSettings.terrainImageID = LLUUID.Random(); | ||
1088 | AssetBase asset = new AssetBase(); | ||
1089 | asset.FullID = m_regInfo.EstateSettings.terrainImageID; | ||
1090 | asset.Data = data; | ||
1091 | asset.Name = "terrainImage"; | ||
1092 | asset.Description = RegionInfo.RegionName; | ||
1093 | asset.Type = 0; | ||
1094 | asset.Temporary = temporary; | ||
1095 | AssetCache.AddAsset(asset); | ||
1096 | |||
1097 | } | ||
1098 | |||
991 | if (terrain != null) | 1099 | if (terrain != null) |
992 | { | 1100 | { |
993 | byte[] data = terrain.WriteJpegImage("defaultstripe.png"); | 1101 | byte[] data = terrain.WriteJpegImage("defaultstripe.png"); |