Class BSPSegment

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

public class BSPSegment extends Object implements BinaryObject
12-byte BSP Segment information for a BSP tree in Doom.
Author:
Matthew Tropiano
  • Field Details

    • LENGTH

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

      public static final int DIRECTION_SAME_AS_LINEDEF
      Direction along linedef (same).
      See Also:
    • DIRECTION_OPPOSITE_LINEDEF

      public static final int DIRECTION_OPPOSITE_LINEDEF
      Direction along linedef (opposite).
      See Also:
    • ANGLE_EAST

      public static final int ANGLE_EAST
      Binary angle.
      See Also:
    • ANGLE_NORTH

      public static final int ANGLE_NORTH
      Binary angle.
      See Also:
    • ANGLE_SOUTH

      public static final int ANGLE_SOUTH
      Binary angle.
      See Also:
    • ANGLE_WEST

      public static final int ANGLE_WEST
      Binary angle.
      See Also:
    • vertexStartIndex

      protected int vertexStartIndex
      This Seg's start vertex index reference.
    • vertexEndIndex

      protected int vertexEndIndex
      This Seg's end vertex index reference.
    • angle

      protected int angle
      This Seg's angle.
    • linedefIndex

      protected int linedefIndex
      This Seg's linedef index.
    • direction

      protected int direction
      This Seg's direction.
    • offset

      protected int offset
      This Seg's offset along linedef.
  • Constructor Details

    • BSPSegment

      public BSPSegment()
      Creates a new BSP Segment.
  • Method Details

    • getVertexStartIndex

      public int getVertexStartIndex()
      Returns:
      this Seg's start vertex index reference.
    • setVertexStartIndex

      public void setVertexStartIndex(int val)
      Sets this Seg's start vertex index reference.
      Parameters:
      val - the new starting vertex reference.
      Throws:
      IllegalArgumentException - if the provided value is outside the range 0 to 65535.
    • getVertexEndIndex

      public int getVertexEndIndex()
      Returns:
      this Seg's end vertex index reference.
    • setVertexEndIndex

      public void setVertexEndIndex(int val)
      Sets this Seg's end vertex index reference.
      Parameters:
      val - the new ending vertex reference.
      Throws:
      IllegalArgumentException - if the provided value is outside the range 0 to 65535.
    • getAngle

      public int getAngle()
      Returns:
      this Seg's angle in degrees.
    • setAngle

      public void setAngle(int val)
      Sets this Seg's binary angle.
      Parameters:
      val - the new binary angle.
      Throws:
      IllegalArgumentException - if the provided value is outside the range -32768 to 32767.
    • getLinedefIndex

      public int getLinedefIndex()
      Returns:
      this Seg's linedef index.
    • setLinedefIndex

      public void setLinedefIndex(int val)
      Sets this Seg's linedef index.
      Parameters:
      val - the new linedef index.
      Throws:
      IllegalArgumentException - if the provided value is outside the range -32768 to 32767.
    • getDirection

      public int getDirection()
      Returns:
      this Seg's direction.
    • setDirection

      public void setDirection(int val)
      Sets this Seg's directionality.
      Parameters:
      val - the new directionality.
      Throws:
      IllegalArgumentException - if the provided value is neither DIRECTION_OPPOSITE_LINEDEF to DIRECTION_SAME_AS_LINEDEF.
    • getOffset

      public int getOffset()
      Returns:
      this Seg's linedef offset.
    • setOffset

      public void setOffset(int val)
      Sets this Seg's linedef offset (distance along line until start of seg).
      Parameters:
      val - the linedef offset.
      Throws:
      IllegalArgumentException - if the provided value is outside the range 0 to 65535.
    • 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.