Esempio n. 1
0
        /// <summary>
        /// Create a waterflow map from the terrain
        /// </summary>
        /// <param name="terrain">Terrain to create the waterflow map from</param>
        public void CreateWaterFlowMap(Terrain terrain)
        {
            m_heightMap = new UnityHeightMap(terrain);
            int width = m_heightMap.Width();
            int depth = m_heightMap.Depth();

            m_waterFlowMap = new HeightMap(width, depth);

            //Avoid edges for now
            for (int x = 1; x < (width - 1); x++)
            {
                for (int z = 1; z < (depth - 1); z++)
                {
                    TraceWaterFlow(x, z, width, depth);
                }
            }

            //Flip it so it matches the terrain
            m_waterFlowMap.Flip();

            //Smooth the water map
            m_waterFlowMap.Smooth(m_waterflowSmoothIterations);
        }