/// <summary> /// Converts the land bitmap to a packet friendly byte array /// </summary> /// <returns></returns> private byte[] ConvertLandBitmapToBytes() { byte[] tempConvertArr = new byte[LandBitmap.GetLength(0) * LandBitmap.GetLength(1) / 8]; byte tempByte = 0; int byteNum = 0; int i = 0; for (int y = 0; y < LandBitmap.GetLength(1); y++) { for (int x = 0; x < LandBitmap.GetLength(0); x++) { tempByte = Convert.ToByte(tempByte | Convert.ToByte(LandBitmap[x, y]) << (i++ % 8)); if (i % 8 == 0) { tempConvertArr[byteNum] = tempByte; tempByte = (byte)0; i = 0; byteNum++; } } } // m_log.DebugFormat("{0} ConvertLandBitmapToBytes. BitmapSize=<{1},{2}>", // LogHeader, LandBitmap.GetLength(0), LandBitmap.GetLength(1)); return(tempConvertArr); }
/// <summary> /// Updates the AABBMin and AABBMax values after area/shape modification of the land object /// </summary> private void UpdateAABBAndAreaValues() { int min_x = 10000; int min_y = 10000; int max_x = 0; int max_y = 0; int tempArea = 0; int x, y; for (x = 0; x < LandBitmap.GetLength(0); x++) { for (y = 0; y < LandBitmap.GetLength(1); y++) { if (LandBitmap[x, y] == true) { if (min_x > x) { min_x = x; } if (min_y > y) { min_y = y; } if (max_x < x) { max_x = x; } if (max_y < y) { max_y = y; } tempArea += landUnit * landUnit; //16sqm peice of land } } } int tx = min_x * landUnit; if (tx > ((int)m_scene.RegionInfo.RegionSizeX - 1)) { tx = ((int)m_scene.RegionInfo.RegionSizeX - 1); } int ty = min_y * landUnit; if (ty > ((int)m_scene.RegionInfo.RegionSizeY - 1)) { ty = ((int)m_scene.RegionInfo.RegionSizeY - 1); } LandData.AABBMin = new Vector3( (float)(min_x * landUnit), (float)(min_y * landUnit), m_scene != null ? (float)m_scene.Heightmap[tx, ty] : 0); tx = max_x * landUnit; if (tx > ((int)m_scene.RegionInfo.RegionSizeX - 1)) { tx = ((int)m_scene.RegionInfo.RegionSizeX - 1); } ty = max_y * landUnit; if (ty > ((int)m_scene.RegionInfo.RegionSizeY - 1)) { ty = ((int)m_scene.RegionInfo.RegionSizeY - 1); } LandData.AABBMax = new Vector3( (float)(max_x * landUnit), (float)(max_y * landUnit), m_scene != null ? (float)m_scene.Heightmap[tx, ty] : 0); LandData.Area = tempArea; }