com.brackeen.javagamebook.bsp2D
Class BSPTree

java.lang.Object
  extended bycom.brackeen.javagamebook.bsp2D.BSPTree

public class BSPTree
extends java.lang.Object

The BSPTree class represents a 2D Binary Space Partitioned tree of polygons. The BSPTree is built using a BSPTreeBuilder class, and can be travered using BSPTreeTraverser class.


Nested Class Summary
static class BSPTree.Leaf
          A Leaf of the tree.
static class BSPTree.Node
          A Node of the tree.
 
Constructor Summary
BSPTree(BSPTree.Node root)
          Creates a new BSPTree with the specified root node.
 
Method Summary
 java.awt.Rectangle calcBounds()
          Calculates the 2D boundary of all the polygons in this BSP tree.
 void createSurfaces(java.util.List lights)
          Creates surface textures for every polygon in this tree.
 BSPTree.Leaf getBackLeaf(BSPLine partition)
          Gets the Leaf in back of the specified partition.
 BSPTree.Node getCollinearNode(BSPLine partition)
          Gets the Node that is collinear with the specified partition, or null if no such node exists.
 BSPTree.Leaf getFrontLeaf(BSPLine partition)
          Gets the Leaf in front of the specified partition.
 BSPTree.Leaf getLeaf(float x, float z)
          Gets the leaf the x,z coordinates are in.
 BSPTree.Node getRoot()
          Gets the root node of this tree.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BSPTree

public BSPTree(BSPTree.Node root)
Creates a new BSPTree with the specified root node.

Method Detail

getRoot

public BSPTree.Node getRoot()
Gets the root node of this tree.


calcBounds

public java.awt.Rectangle calcBounds()
Calculates the 2D boundary of all the polygons in this BSP tree. Returns a rectangle of the bounds.


getLeaf

public BSPTree.Leaf getLeaf(float x,
                            float z)
Gets the leaf the x,z coordinates are in.


getCollinearNode

public BSPTree.Node getCollinearNode(BSPLine partition)
Gets the Node that is collinear with the specified partition, or null if no such node exists.


getFrontLeaf

public BSPTree.Leaf getFrontLeaf(BSPLine partition)
Gets the Leaf in front of the specified partition.


getBackLeaf

public BSPTree.Leaf getBackLeaf(BSPLine partition)
Gets the Leaf in back of the specified partition.


createSurfaces

public void createSurfaces(java.util.List lights)
Creates surface textures for every polygon in this tree.