Пример #1
0
        internal TreeBranch(float c_length, float angleClamp, float dropOff, int number,
            Vector3 normal, Vector3 position, int depthCounter, Billboard b, TreeBranch parent, Tree root)
        {
            List<Vector3> points = new List<Vector3>();
            Position = position;
            Parent = parent;
            Root = root;
            for (int i = 0; i < number; ++i)
            {
                if (depthCounter > 0)
                    points.Add(getNext(c_length, angleClamp, normal) + position);
                else
                    points.Add(getNext(c_length, angleClamp, normal) * 0.5f + position);
            }

            if (depthCounter > 0)
            {
                foreach(Vector3 point in points)
                {
                    Children.Add(new TreeBranch(c_length * dropOff, angleClamp, dropOff, number,
                        (point - position).normalize(), point, depthCounter-1, b, this, root));
                }
            }
            else
            {
                foreach(Vector3 leaf in points)
                {
                    Children.Add(new TreeLeaf(leaf, b, this, root));
                }
            }
        }
Пример #2
0
 public Tree(Vector3 position, float treeHeight, float angleClamp, float dropOff, int number, 
     int depth, Billboard b)
 {
     args = new DrawArgs(null, new Color4(0, .5f, 0, 1f));
     Root = new TreeBranch();
     Root.Position = position;
     var subr = new TreeBranch(treeHeight * dropOff, angleClamp, dropOff, number, new Vector3(0,1,0),
         position + new Vector3(0, treeHeight, 0), depth, b, Root, this);
     Root.Children.Add(subr);
     Position = position;
 }
Пример #3
0
 internal TreeLeaf(Vector3 position, Billboard b, TreeBranch parent, Tree root)
 {
     Position = position;
     leaf = b;
     Parent = parent;
     Root = root;
 }