Exemple #1
0
        public List <BasinVertex> basinVertices;                // the basin points

        public WaterSeed(Terrain_holistic _T, Vector3 _position, float _flow)
        {
            T    = _T;
            flow = _flow;

            Vector2 uv = T.worldToTerrainUV(_position);
            Vector3 n  = T.thisTerrain.terrainData.GetInterpolatedNormal(uv.x, uv.y);

            source = new BasinVertex(_position, uv, n);

            updateBasin();
        }
Exemple #2
0
 /******************************
 * DEBUG GIZMO DISPLAY
 ******************************/
 void OnDrawGizmos()
 {
     if (riverGizmos)
     {
         Gizmos.color = Color.blue;
         for (int i = 0; i < waterSpots.Count; i++)
         {
             WaterSeed ws = waterSpots[i];
             for (int j = 0; j < ws.basinVertices.Count; j++)
             {
                 BasinVertex bv = ws.basinVertices[j];
                 Gizmos.DrawLine(bv.position, bv.position + 10 * bv.normal);
             }
         }
     }
 }
Exemple #3
0
        private void updateBasin()
        {
            // Reset collection
            basinVertices = new List <BasinVertex>();

            // Start eroding again
            erosionStrength = 1.0f;

            // Add source
            basinVertices.Add(source);

            int safe = 300;
            int step = 0;

            BasinVertex prev = source;

            // Gradient descent (gross sort of...)
            while (step < safe)
            {
                Vector3 p   = prev.position + 10 * prev.normal;
                Vector2 puv = T.worldToTerrainUV(p);
                Vector3 pn  = T.thisTerrain.terrainData.GetInterpolatedNormal(puv.x, puv.y);
                Vector3 pp  = T.terrainUVToWorld(puv);

                // Reached a local minimum?
                if (pn.y > minimaLimit)
                {
                    break;
                }

                BasinVertex v = new BasinVertex(pp, puv, pn);
                basinVertices.Add(v);

                prev = v;
                step++;
            }
        }
        private void updateBasin()
        {
            // Reset collection
            basinVertices = new List<BasinVertex>();

            // Start eroding again
            erosionStrength = 1.0f;

            // Add source
            basinVertices.Add(source);

            int safe = 300;
            int step = 0;

            BasinVertex prev = source;

            // Gradient descent (gross sort of...)
            while (step < safe) {
                Vector3 p = prev.position + 10 * prev.normal;
                Vector2 puv = T.worldToTerrainUV(p);
                Vector3 pn = T.thisTerrain.terrainData.GetInterpolatedNormal(puv.x, puv.y);
                Vector3 pp = T.terrainUVToWorld(puv);

                // Reached a local minimum?
                if (pn.y > minimaLimit) break;

                BasinVertex v = new BasinVertex(pp, puv, pn);
                basinVertices.Add(v);

                prev = v;
                step++;
            }
        }
        public WaterSeed(Terrain_holistic _T, Vector3 _position, float _flow)
        {
            T = _T;
            flow = _flow;

            Vector2 uv = T.worldToTerrainUV(_position);
            Vector3 n = T.thisTerrain.terrainData.GetInterpolatedNormal(uv.x, uv.y);
            source = new BasinVertex(_position, uv, n);

            updateBasin();
        }