Package net.mtrop.doom.bsp.data
Class BSPNode
java.lang.Object
net.mtrop.doom.bsp.data.BSPNode
- All Implemented Interfaces:
BinaryObject
This contains the BSP tree information for a single 28-byte node in the tree.
- Author:
- Matthew Tropiano
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.mtrop.doom.object.BinaryObject
BinaryObject.InlineScanner<BO extends BinaryObject>, BinaryObject.Reflect, BinaryObject.Scanner<BO extends BinaryObject>, BinaryObject.Shared, BinaryObject.Transformer<BO extends BinaryObject>
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Leaf node value.protected int[]
This node's left bounding box coordinates.protected int
This node's left child index or subsector index.static final int
Byte length of this object.protected int
This node's partition line's change in X to the end of the line.protected int
This node's partition line's change in Y to the end of the line.protected int
This node's partition line's X-coordinate.protected int
This node's partition line's Y-coordinate.protected int[]
This node's right bounding box coordinates.protected int
This node's right child index or subsector index. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
int[]
int
int
int
int
int
boolean
int[]
int
void
readBytes
(InputStream in) Reads from anInputStream
and sets this object's fields.void
setLeftRect
(int top, int bottom, int left, int right) Sets this node's left bounding box coordinates (top, bottom, left, right).void
setLeftSubsectorIndex
(int val) Sets this node's left subsector index.void
setPartitionDeltaX
(int val) Sets this node's partition line's change in X to the end of the line.void
setPartitionDeltaY
(int val) Sets this node's partition line's change in Y to the end of the line.void
setPartitionLineX
(int val) Sets this node's partition line's X-coordinate.void
setPartitionLineY
(int val) Sets this node's partition line's Y-coordinate.void
setRightRect
(int top, int bottom, int left, int right) Sets this node's right bounding box coordinates (top, bottom, left, right).void
setRightSubsectorIndex
(int val) Sets this node's right subsector index.void
writeBytes
(OutputStream out) Writes this object to anOutputStream
.
-
Field Details
-
LENGTH
public static final int LENGTHByte length of this object.- See Also:
-
LEAF_NODE_INDEX
public static final int LEAF_NODE_INDEXLeaf node value.- See Also:
-
partitionLineX
protected int partitionLineXThis node's partition line's X-coordinate. -
partitionLineY
protected int partitionLineYThis node's partition line's Y-coordinate. -
partitionDeltaX
protected int partitionDeltaXThis node's partition line's change in X to the end of the line. -
partitionDeltaY
protected int partitionDeltaYThis node's partition line's change in Y to the end of the line. -
rightRect
protected int[] rightRectThis node's right bounding box coordinates. -
leftRect
protected int[] leftRectThis node's left bounding box coordinates. -
rightSubsectorIndex
protected int rightSubsectorIndexThis node's right child index or subsector index. -
leftSubsectorIndex
protected int leftSubsectorIndexThis 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'tLEAF_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'tLEAF_NODE_INDEX
.
-
readBytes
Description copied from interface:BinaryObject
Reads from anInputStream
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 interfaceBinaryObject
- Parameters:
in
- theInputStream
to read from.- Throws:
IOException
- if a read error occurs.
-
writeBytes
Description copied from interface:BinaryObject
Writes this object to anOutputStream
.- Specified by:
writeBytes
in interfaceBinaryObject
- Parameters:
out
- theOutputStream
to write to.- Throws:
IOException
- if a write error occurs.
-