com.brackeen.javagamebook.bsp2D
Class Portal

java.lang.Object
  extended bycom.brackeen.javagamebook.path.AStarNode
      extended bycom.brackeen.javagamebook.bsp2D.Portal
All Implemented Interfaces:
java.lang.Comparable

public class Portal
extends AStarNode

A Portal represents a passable divider between two leaves in a BSP tree (think: entryway between rooms). The Portal class is also an AStarNode, so AI creatures can use the A* algorithm to find paths throughout the BSP tree.


Constructor Summary
Portal(BSPLine divider, BSPTree.Leaf front, BSPTree.Leaf back)
          Create a new Portal with the specified divider and front/ back leaves.
 
Method Summary
 void addNeighbor(AStarNode node)
          Adds a neighbor node to the list of neighbors.
 void buildNeighborList()
          Builds the list of neighbors for the AStarNode representation.
 float getCost(AStarNode node)
          Gets the cost between this node and the specified adjacent (aka "neighbor" or "child") node.
 float getEstimatedCost(AStarNode node)
          Gets the estimated cost between this node and the specified node.
 Vector3D getMidPoint()
          Gets the mid-point along this Portal's divider.
 java.util.List getNeighbors()
          Gets the children (aka "neighbors" or "adjacent nodes") of this node.
 void removeNeighbor(AStarNode node)
          Removes a neighbor node to the list of neighbors.
 
Methods inherited from class com.brackeen.javagamebook.path.AStarNode
compareTo, getCost
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Portal

public Portal(BSPLine divider,
              BSPTree.Leaf front,
              BSPTree.Leaf back)
Create a new Portal with the specified divider and front/ back leaves.

Method Detail

getMidPoint

public Vector3D getMidPoint()
Gets the mid-point along this Portal's divider.


buildNeighborList

public void buildNeighborList()
Builds the list of neighbors for the AStarNode representation. The neighbors are the portals of the front and back leaves, not including this portal.


addNeighbor

public void addNeighbor(AStarNode node)
Adds a neighbor node to the list of neighbors.


removeNeighbor

public void removeNeighbor(AStarNode node)
Removes a neighbor node to the list of neighbors.


getCost

public float getCost(AStarNode node)
Description copied from class: AStarNode
Gets the cost between this node and the specified adjacent (aka "neighbor" or "child") node.

Specified by:
getCost in class AStarNode

getEstimatedCost

public float getEstimatedCost(AStarNode node)
Description copied from class: AStarNode
Gets the estimated cost between this node and the specified node. The estimated cost should never exceed the true cost. The better the estimate, the more effecient the search.

Specified by:
getEstimatedCost in class AStarNode

getNeighbors

public java.util.List getNeighbors()
Description copied from class: AStarNode
Gets the children (aka "neighbors" or "adjacent nodes") of this node.

Specified by:
getNeighbors in class AStarNode