Class BSPNode

java.lang.Object
net.mtrop.doom.bsp.data.BSPNode
All Implemented Interfaces:
BinaryObject

public class BSPNode extends Object implements BinaryObject
This contains the BSP tree information for a single 28-byte node in the tree.
Author:
Matthew Tropiano
  • Field Details

    • LENGTH

      public static final int LENGTH
      Byte length of this object.
      See Also:
    • LEAF_NODE_INDEX

      public static final int LEAF_NODE_INDEX
      Leaf node value.
      See Also:
    • partitionLineX

      protected int partitionLineX
      This node's partition line's X-coordinate.
    • partitionLineY

      protected int partitionLineY
      This node's partition line's Y-coordinate.
    • partitionDeltaX

      protected int partitionDeltaX
      This node's partition line's change in X to the end of the line.
    • partitionDeltaY

      protected int partitionDeltaY
      This node's partition line's change in Y to the end of the line.
    • rightRect

      protected int[] rightRect
      This node's right bounding box coordinates.
    • leftRect

      protected int[] leftRect
      This node's left bounding box coordinates.
    • rightSubsectorIndex

      protected int rightSubsectorIndex
      This node's right child index or subsector index.
    • leftSubsectorIndex

      protected int leftSubsectorIndex
      This node's left child index or subsector index.
  • Constructor Details

    • BSPNode

      public BSPNode()
      Creates a new BSP Node.
  • Method Details

    • getPartitionLineX

      public int getPartitionLineX()
      Returns:
      this node's partition line's X-coordinate.
    • setPartitionLineX

      public void setPartitionLineX(int val)
      Sets this node's partition line's X-coordinate.
      Parameters:
      val - the new partition line x-coordinate.
      Throws:
      IllegalArgumentException - if the value is outside the range -32768 to 32767.
    • getPartitionLineY

      public int getPartitionLineY()
      Returns:
      this node's partition line's Y-coordinate.
    • setPartitionLineY

      public void setPartitionLineY(int val)
      Sets this node's partition line's Y-coordinate.
      Parameters:
      val - the new partition line y-coordinate.
      Throws:
      IllegalArgumentException - if the value is outside the range -32768 to 32767.
    • getPartitionDeltaX

      public int getPartitionDeltaX()
      Returns:
      this node's partition line's change in X to the end of the line.
    • setPartitionDeltaX

      public void setPartitionDeltaX(int val)
      Sets this node's partition line's change in X to the end of the line.
      Parameters:
      val - the new partition line delta X.
      Throws:
      IllegalArgumentException - if the value is outside the range -32768 to 32767.
    • getPartitionDeltaY

      public int getPartitionDeltaY()
      Returns:
      this node's partition line's change in Y to the end of the line.
    • setPartitionDeltaY

      public void setPartitionDeltaY(int val)
      Sets this node's partition line's change in Y to the end of the line.
      Parameters:
      val - the new partition line delta Y.
      Throws:
      IllegalArgumentException - if the value is outside the range -32768 to 32767.
    • getRightRect

      public int[] getRightRect()
      Returns:
      this node's right bounding box coordinates (top, bottom, left, right).
    • setRightRect

      public void setRightRect(int top, int bottom, int left, int right)
      Sets this node's right bounding box coordinates (top, bottom, left, right).
      Parameters:
      top - the top of the box.
      bottom - the bottom of the box.
      left - the left side of the box.
      right - the right side of the box.
      Throws:
      IllegalArgumentException - if any of the values are outside the range -32768 to 32767.
    • getLeftRect

      public int[] getLeftRect()
      Returns:
      this node's left bounding box coordinates (top, bottom, left, right).
    • setLeftRect

      public void setLeftRect(int top, int bottom, int left, int right)
      Sets this node's left bounding box coordinates (top, bottom, left, right).
      Parameters:
      top - the top of the box.
      bottom - the bottom of the box.
      left - the left side of the box.
      right - the right side of the box.
      Throws:
      IllegalArgumentException - if any of the values are outside the range -32768 to 32767.
    • getRightChildIsLeaf

      public boolean getRightChildIsLeaf()
      Returns:
      true, if this node's right node is a leaf, false if not.
    • getRightSubsectorIndex

      public int getRightSubsectorIndex()
      Returns:
      this node's right subsector index.
    • setRightSubsectorIndex

      public void setRightSubsectorIndex(int val)
      Sets this node's right subsector index.
      Parameters:
      val - the new right subsector index.
      Throws:
      IllegalArgumentException - if the value is outside the range 0 to 32767, or isn't LEAF_NODE_INDEX.
    • getLeftSubsectorIndex

      public int getLeftSubsectorIndex()
      Returns:
      this node's left subsector index.
    • getLeftChildIsLeaf

      public boolean getLeftChildIsLeaf()
      Returns:
      true, if this node's left node is a leaf, false if not.
    • setLeftSubsectorIndex

      public void setLeftSubsectorIndex(int val)
      Sets this node's left subsector index.
      Parameters:
      val - the new left subsector index.
      Throws:
      IllegalArgumentException - if the value is outside the range 0 to 32767, or isn't LEAF_NODE_INDEX.
    • readBytes

      public void readBytes(InputStream in) throws IOException
      Description copied from interface: BinaryObject
      Reads from an InputStream and sets this object's fields. Only reads the amount of bytes that it takes to read a single instance of the object. Note that not every object may have a consistent length!
      Specified by:
      readBytes in interface BinaryObject
      Parameters:
      in - the InputStream to read from.
      Throws:
      IOException - if a read error occurs.
    • writeBytes

      public void writeBytes(OutputStream out) throws IOException
      Description copied from interface: BinaryObject
      Writes this object to an OutputStream.
      Specified by:
      writeBytes in interface BinaryObject
      Parameters:
      out - the OutputStream to write to.
      Throws:
      IOException - if a write error occurs.