diff options
Diffstat (limited to 'OpenSim/Region/Environment/Scenes/Scene.cs')
-rw-r--r-- | OpenSim/Region/Environment/Scenes/Scene.cs | 93 |
1 files changed, 47 insertions, 46 deletions
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index b93367c..ba8a356 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs | |||
@@ -984,19 +984,21 @@ namespace OpenSim.Region.Environment.Scenes | |||
984 | /// </summary> | 984 | /// </summary> |
985 | public void CreateTerrainTexture(bool temporary) | 985 | public void CreateTerrainTexture(bool temporary) |
986 | { | 986 | { |
987 | //TODOADAM: Move this to TerrainModule | ||
988 | |||
989 | //create a texture asset of the terrain | 987 | //create a texture asset of the terrain |
990 | ITerrainTemp terrain = RequestModuleInterface<ITerrainTemp>(); | 988 | IMapImageGenerator terrain = RequestModuleInterface<IMapImageGenerator>(); |
991 | 989 | ||
992 | if (Heightmap != null) | 990 | // Cannot create a map for a nonexistant heightmap yet. |
991 | if (Heightmap == null) | ||
992 | return; | ||
993 | |||
994 | if (terrain == null) | ||
993 | { | 995 | { |
994 | Bitmap mapbmp = new Bitmap(256, 256); | 996 | Bitmap mapbmp = new Bitmap(256, 256); |
995 | double[,] hm = Heightmap.GetDoubles(); | 997 | double[,] hm = Heightmap.GetDoubles(); |
996 | 998 | ||
997 | float heightvalue = 0; | 999 | float heightvalue = 0; |
998 | 1000 | ||
999 | 1001 | ||
1000 | Color prim = Color.FromArgb(120, 120, 120); | 1002 | Color prim = Color.FromArgb(120, 120, 120); |
1001 | LLVector3 RayEnd = new LLVector3(0, 0, 0); | 1003 | LLVector3 RayEnd = new LLVector3(0, 0, 0); |
1002 | LLVector3 RayStart = new LLVector3(0, 0, 0); | 1004 | LLVector3 RayStart = new LLVector3(0, 0, 0); |
@@ -1038,50 +1040,50 @@ namespace OpenSim.Region.Environment.Scenes | |||
1038 | 1040 | ||
1039 | //if (rt.HitTF) | 1041 | //if (rt.HitTF) |
1040 | //{ | 1042 | //{ |
1041 | //mapbmp.SetPixel(x, y, prim); | 1043 | //mapbmp.SetPixel(x, y, prim); |
1042 | //} | 1044 | //} |
1043 | //else | 1045 | //else |
1044 | //{ | 1046 | //{ |
1045 | float tmpval = (float)hm[x, y]; | 1047 | float tmpval = (float)hm[x, y]; |
1046 | heightvalue = (float)hm[x, y]; | 1048 | heightvalue = (float)hm[x, y]; |
1047 | 1049 | ||
1048 | if ((float)heightvalue > m_regInfo.EstateSettings.waterHeight) | 1050 | if ((float)heightvalue > m_regInfo.EstateSettings.waterHeight) |
1049 | { | 1051 | { |
1050 | // scale height value | 1052 | // scale height value |
1051 | heightvalue = low + mid * (heightvalue - low) / mid; | 1053 | 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 | heightvalue = m_regInfo.EstateSettings.waterHeight - heightvalue; | ||
1069 | if (heightvalue > 19) | ||
1070 | heightvalue = 19; | ||
1071 | if (heightvalue < 0) | ||
1072 | heightvalue = 0; | ||
1073 | 1054 | ||
1074 | heightvalue = 100 - (heightvalue * 100) / 19; | 1055 | if (heightvalue > 255) |
1056 | heightvalue = 255; | ||
1075 | 1057 | ||
1076 | if (heightvalue > 255) | 1058 | if (heightvalue < 0) |
1077 | heightvalue = 255; | 1059 | heightvalue = 0; |
1078 | 1060 | ||
1079 | if (heightvalue < 0) | ||
1080 | heightvalue = 0; | ||
1081 | 1061 | ||
1082 | Color water = Color.FromArgb((int)heightvalue, (int)heightvalue, 255); | 1062 | Color green = Color.FromArgb((int)heightvalue, 100, (int)heightvalue); |
1083 | mapbmp.SetPixel(x, (256 - y) - 1, water); | 1063 | |
1084 | } | 1064 | // Y flip the cordinates |
1065 | mapbmp.SetPixel(x, (256 - y) - 1, green); | ||
1066 | } | ||
1067 | else | ||
1068 | { | ||
1069 | // Y flip the cordinates | ||
1070 | heightvalue = m_regInfo.EstateSettings.waterHeight - heightvalue; | ||
1071 | if (heightvalue > 19) | ||
1072 | heightvalue = 19; | ||
1073 | if (heightvalue < 0) | ||
1074 | heightvalue = 0; | ||
1075 | |||
1076 | heightvalue = 100 - (heightvalue * 100) / 19; | ||
1077 | |||
1078 | if (heightvalue > 255) | ||
1079 | heightvalue = 255; | ||
1080 | |||
1081 | if (heightvalue < 0) | ||
1082 | heightvalue = 0; | ||
1083 | |||
1084 | Color water = Color.FromArgb((int)heightvalue, (int)heightvalue, 255); | ||
1085 | mapbmp.SetPixel(x, (256 - y) - 1, water); | ||
1086 | } | ||
1085 | //} | 1087 | //} |
1086 | 1088 | ||
1087 | 1089 | ||
@@ -1098,7 +1100,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
1098 | { | 1100 | { |
1099 | return; | 1101 | return; |
1100 | } | 1102 | } |
1101 | 1103 | ||
1102 | m_regInfo.EstateSettings.terrainImageID = LLUUID.Random(); | 1104 | m_regInfo.EstateSettings.terrainImageID = LLUUID.Random(); |
1103 | AssetBase asset = new AssetBase(); | 1105 | AssetBase asset = new AssetBase(); |
1104 | asset.FullID = m_regInfo.EstateSettings.terrainImageID; | 1106 | asset.FullID = m_regInfo.EstateSettings.terrainImageID; |
@@ -1108,12 +1110,11 @@ namespace OpenSim.Region.Environment.Scenes | |||
1108 | asset.Type = 0; | 1110 | asset.Type = 0; |
1109 | asset.Temporary = temporary; | 1111 | asset.Temporary = temporary; |
1110 | AssetCache.AddAsset(asset); | 1112 | AssetCache.AddAsset(asset); |
1111 | |||
1112 | } | ||
1113 | 1113 | ||
1114 | if (terrain != null) | 1114 | } |
1115 | else | ||
1115 | { | 1116 | { |
1116 | byte[] data = terrain.WriteJpegImage("defaultstripe.png"); | 1117 | byte[] data = terrain.WriteJpeg2000Image("defaultstripe.png"); |
1117 | if (data != null) | 1118 | if (data != null) |
1118 | { | 1119 | { |
1119 | m_regInfo.EstateSettings.terrainImageID = LLUUID.Random(); | 1120 | m_regInfo.EstateSettings.terrainImageID = LLUUID.Random(); |