/// <summary> /// Create a height map that is a copy of another heightmap /// </summary> /// <param name="source">Source heightmap</param> public Heightmap(Heightmap source) { Reset(); m_widthX = source.m_widthX; m_depthZ = source.m_depthZ; m_widthInvX = 1f / (float)(m_widthX); m_depthInvZ = 1f / (float)(m_depthZ); m_heights = new float[m_widthX, m_depthZ]; m_isPowerOf2 = source.m_isPowerOf2; m_metaData = new byte[source.m_metaData.Length]; for (int idx = 0; idx < source.m_metaData.Length; idx++) { m_metaData[idx] = source.m_metaData[idx]; } for (int x = 0; x < m_widthX; x++) { for (int z = 0; z < m_depthZ; z++) { m_heights[x, z] = source.m_heights[x, z]; } } m_isDirty = false; }
/// <summary> /// Return a new heightmap where each point at contains the slopes of this heightmap at that point /// </summary> /// <returns></returns> public Heightmap GetSlopeMap() { Heightmap slopeMap = new Heightmap(this); for (int x = 0; x < m_widthX; x++) { for (int z = 0; z < m_depthZ; z++) { slopeMap[x, z] = GetSlope(x, z); } } return(slopeMap); }