Beispiel #1
0
 /// <summary> Constructor to use if you are going to store the objects in x/y
 /// space, and there is a smallest node size because you don't want
 /// the nodes to be smaller than a group of pixels.</summary>
 /// <param name="Top">northern border of node coverage.</param>
 /// <param name="Left">western border of node coverage.</param>
 /// <param name="Bottom">southern border of node coverage.</param>
 /// <param name="Right">eastern border of node coverage.</param>
 /// <param name="maximumItems">number of items to hold in a node before
 /// splitting itself into four branch and redispensing the items into them.</param>
 /// <param name="minimumSize">the minimum difference between the boundaries of the node.</param>
 public OctreeNode(float xMax, float xMin, float yMax, float yMin, float zMax, float zMin, int maximumItems, float minimumSize)
 {
     bounds = new OctreeBox(xMax, xMin, yMax, yMin, zMax, zMin);
     maxItems = maximumItems;
     minSize = minimumSize;
     items = ArrayList.Synchronized(new ArrayList(10));
 }
Beispiel #2
0
 public bool within(OctreeBox Box)
 {
     return within(Box.Top, Box.Left, Box.Bottom, Box.Right, Box.Front, Box.Back);
 }
Beispiel #3
0
 /// <summary> Get all the objects within a bounding box.</summary>
 /// <param name="rect">boundary of area to fill.</param>
 /// <param name="vector">current vector of objects.</param>
 /// <returns> updated Vector of objects.</returns>
 public ArrayList GetNode(OctreeBox rect, ArrayList nodes)
 {
     if (branch == null)
     {
         IEnumerator things = this.items.GetEnumerator();
         while (things.MoveNext())
         {
             OctreeLeaf qtl = (OctreeLeaf)things.Current;
             if (rect.pointWithinBounds(qtl.X, qtl.Y, qtl.Z))
                 nodes.Add(qtl.LeafObject);
         }
     }
     else
     {
         for (int i = 0; i < branch.Length; i++)
         {
             if (branch[i].bounds.within(rect))
                 branch[i].GetNode(rect, nodes);
         }
     }
     return nodes;
 }