// New terrain serialization format that includes the width and length. private void FromXml2(XmlReader xmlReader) { XmlSerializer serializer = new XmlSerializer(typeof(TerrainChannelXMLPackage)); TerrainChannelXMLPackage package = (TerrainChannelXMLPackage)serializer.Deserialize(xmlReader); m_terrainData = new HeightMapTerrainData(package.Map, package.CompressionFactor, package.SizeX, package.SizeY, package.SizeZ); }
// Create terrain of specified size and initialize with specified terrain. // TODO: join this with the terrain initializers. public TerrainChannel(String type, int pX, int pY, int pZ) { m_terrainData = new HeightMapTerrainData(pX, pY, pZ); if (type.Equals("flat")) { FlatLand(); } else { PinHeadIsland(); } }
// Read legacy terrain map. Presumed to be 256x256 of data encoded as floats in a byte array. private void FromXml(XmlReader xmlReader) { XmlSerializer serializer = new XmlSerializer(typeof(byte[])); byte[] dataArray = (byte[])serializer.Deserialize(xmlReader); int index = 0; m_terrainData = new HeightMapTerrainData(Height, Width, (int)Constants.RegionHeight); for (int y = 0; y < Height; y++) { for (int x = 0; x < Width; x++) { float value; value = BitConverter.ToSingle(dataArray, index); index += 4; this[x, y] = (double)value; } } }
// Create channel passed a heightmap and expected dimensions of the region. // The heightmap might not fit the passed size so accomodations must be made. public TerrainChannel(double[,] pM, int pSizeX, int pSizeY, int pAltitude) { int hmSizeX = pM.GetLength(0); int hmSizeY = pM.GetLength(1); m_terrainData = new HeightMapTerrainData(pSizeX, pSizeY, pAltitude); for (int xx = 0; xx < pSizeX; xx++) { for (int yy = 0; yy < pSizeY; yy++) { if (xx > hmSizeX || yy > hmSizeY) { m_terrainData[xx, yy] = HeightMapTerrainData.DefaultTerrainHeight; } else { m_terrainData[xx, yy] = (float)pM[xx, yy]; } } } }
public void StoreTerrain(HeightMapTerrainData terrain, UUID regionID) { m_database.StoreTerrain(terrain, regionID); }
// Legacy. Just don't do this. public void StoreTerrain(double[,] ter, UUID regionID) { HeightMapTerrainData terrData = new HeightMapTerrainData(ter); StoreTerrain(terrData, regionID); }
public void StoreTerrain(HeightMapTerrainData ter, UUID regionID) { m_terrains[regionID] = ter; }
// Create terrain of given size public TerrainChannel(int pX, int pY) { m_terrainData = new HeightMapTerrainData(pX, pY, (int)Constants.RegionHeight); }
} // Y dimension // Default, not-often-used builder public TerrainChannel() { m_terrainData = new HeightMapTerrainData((int)Constants.RegionSize, (int)Constants.RegionSize, (int)Constants.RegionHeight); FlatLand(); // PinHeadIsland(); }
public TerrainChannel(HeightMapTerrainData pTerrData) { m_terrainData = pTerrData; }