Example #1
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);
 }
Example #2
0
 /// <summary> Get the node that covers a certain x/y pair.</summary>
 /// <param name="x">up-down location in Octree Grid (x, y)</param>
 /// <param name="y">left-right location in Octree Grid (y, x)</param>
 /// <returns> node if child covers the point, null if the point is
 /// out of range.</returns>
 protected internal OctreeNode getChild(float x, float y, float z)
 {
     if (bounds.pointWithinBounds(x, y, z))
     {
         if (branch != null)
         {
             for (int i = 0; i < branch.Length; i++)
             {
                 if (branch[i].bounds.pointWithinBounds(x, y, z))
                 {
                     return(branch[i].getChild(x, y, z));
                 }
             }
         }
         else
         {
             return(this);
         }
     }
     return(null);
 }
Example #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;
 }