예제 #1
0
 public LakeEdge(ErosionNode a, ErosionNode b)
 {
     nodes = new HashSet <ErosionNode>()
     {
         a, b
     };
     receiver = null;
     height   = Math.Max(a.Height, b.Height);
 }
 public void Draw()
 {
     Gizmos.color = new Color(1, 1, 1, 1F);
     foreach (ErosionNode node in nodes)
     {
         /*
          * if (node.Outflow == null)
          * {
          *  Gizmos.color = new Color(1f, 0f, 0f, 1f);
          * }
          * else if (node.Lake.oceanic)
          * {
          *  Gizmos.color = new Color(0f, 1f, 0f, 1f);
          * }
          * else
          * {
          *  Gizmos.color = new Color(0.5f, 0.5f, 0.5f, 1f);
          * }
          * Gizmos.DrawCube(new Vector3(node.X, node.Height, node.Y), Vector3.one);
          */
         foreach (GraphEdge edge in node.GetEdges())
         {
             ErosionNode other = (ErosionNode)edge.GetOtherNode(node);
             if (node.Outflow == other || other.Outflow == node)
             {
                 Gizmos.color = new Color(0f, 0f, 1f, 1f);
             }
             else
             {
                 Gizmos.color = new Color(0.5f, 0.5f, 0.5f, 1f);
             }
             Gizmos.DrawLine(new Vector3(node.X, node.Height, node.Y), new Vector3(other.X, other.Height, other.Y));
         }
         if (node.Outflow != null && !node.GetEdges().Any(t => t.GetOtherNode(node) == node.Outflow))
         {
             ErosionNode other = node.Outflow;
             Gizmos.color = new Color(1f, 0f, 1f, 1f);
             Gizmos.DrawLine(new Vector3(node.X, node.Height, node.Y), new Vector3(other.X, other.Height, other.Y));
         }
     }
 }
    public void AdjustHeights(List <ErosionNode> origins, float delta_t)
    {
        float max_slope = (float)Math.Tan(0.75);  // max angle in radians

        Queue <ErosionNode> node_queue = new Queue <ErosionNode>();

        foreach (ErosionNode origin in origins)
        {
            node_queue.Enqueue(origin);
        }

        while (node_queue.Count > 0)
        {
            ErosionNode node = node_queue.Dequeue();
            foreach (ErosionNode inflow in node.Inflows())
            {
                node_queue.Enqueue(inflow);
            }
            if (node.Outflow != null)
            {
                float fluvial = (float)(node.K * Math.Pow(node.Drainage, node.M) / node.Distance);
                float uplift  = node.Height + delta_t * (node.Uplift + fluvial * node.Outflow.Height);
                uplift      = uplift / (1f + delta_t * fluvial);
                node.Height = uplift;

                if (node.Slope > max_slope)
                {
                    node.Height = node.Outflow.Height + node.Distance * max_slope;
                }
                else if (node.Slope < (-1 * max_slope))
                {
                    node.Height = node.Outflow.Height - node.Distance * max_slope;
                }
            }
        }
    }
 public ErosionEdge(ErosionNode a, ErosionNode b) : base(a, b)
 {
 }
 public void AddInflow(ErosionNode a)
 {
     inflow.Add(a);
 }
예제 #6
0
 public LakeNode(ErosionNode origin)
 {
     this.origin = origin;
     oceanic     = origin.IsExterior();
     nodes       = new List <ErosionNode>();
 }