Пример #1
0
 /** Update the size of a leaf */
 public void UpdateLeafSize(bLeaf l, float hours)
 {
     l.Size += LeafGrowPerHour;
       if (l.Size > l.MaxSize)
     l.Size = l.MaxSize;
 }
Пример #2
0
        /** Maybe add a leaf if this is a tip segment */
        public void MaybeAddLeaf(bTreeBranch b, float hours)
        {
            if (b.Trunk) return; // Never trunk
              //if (b.Length < (MaxBranchSize / 2.0f)) return; // Only on older branches

              if (b.Tree.Leaves < TotalMaxLeaves) {
            if ((b.Length > 0.5f) && (b.Leaves.Count < 5)) {
              if (b.Age < MaxSegmentGrowAge) {
            var chance = LeafChancePerHour * hours;
            if (b.NextSegment == null)
              chance = chance * 2.0f;
            if (RValue(chance)) {
              var texture = GetTextureForTreeType(TreeType);
              var new_leaf = new bLeaf() {
                Tree = b.Tree,
                Parent = b,
                Angle = RValue(0f, 180f),
                Offset = RValue(0f, b.Length, 0f),
                Size = 0.001f,
                MaxSize = RValue(MaxLeafSize, MaxLeafSizeVariation),
                Texture = texture
              };
              b.Leaves.Add(new_leaf);
              ++b.Tree.Leaves;
              nLog.Debug("Added a leaf at offset {2}! New is {0} < {1}", b.Tree.Leaves, TotalMaxLeaves, new_leaf.Offset);
            }
              }
            }
              }
        }