Merged in Mazes and Nether Branches #123

Merged
SenseiKiwi merged 10 commits from master into master 2014-01-04 07:42:05 +00:00
4 changed files with 80 additions and 39 deletions
Showing only changes of commit 2f8292faab - Show all commits

View File

@@ -0,0 +1,69 @@
package StevenDimDoors.experimental;
import StevenDimDoors.mod_pocketDim.Point3D;
public class BoundingBox
{
protected Point3D minCorner;
protected Point3D maxCorner;
public BoundingBox(int x, int y, int z, int width, int height, int length)
{
this.minCorner = new Point3D(x, y, z);
this.maxCorner = new Point3D(x + width - 1, y + height - 1, z + length - 1);
}
public BoundingBox(Point3D minCorner, Point3D maxCorner)
{
this.minCorner = minCorner;
this.maxCorner = maxCorner;
}
public int width()
{
return (maxCorner.getX() - minCorner.getX() + 1);
}
public int height()
{
return (maxCorner.getY() - minCorner.getY() + 1);
}
public int length()
{
return (maxCorner.getZ() - minCorner.getZ() + 1);
}
public Point3D minCorner()
{
return minCorner;
}
public Point3D maxCorner()
{
return maxCorner;
}
public boolean contains(int x, int y, int z)
{
return ((minCorner.getX() <= x && x <= maxCorner.getX()) &&
(minCorner.getY() <= y && y <= maxCorner.getY()) &&
(minCorner.getZ() <= z && z <= maxCorner.getZ()));
}
public boolean intersects(BoundingBox other)
{
// To be clear, having one box inside another counts as intersecting
boolean xi = (this.minCorner.getX() <= other.minCorner.getX() && other.minCorner.getX() <= this.maxCorner.getX()) ||
(other.minCorner.getX() <= this.minCorner.getX() && this.minCorner.getX() <= other.maxCorner.getX());
boolean yi = (this.minCorner.getY() <= other.minCorner.getY() && other.minCorner.getY() <= this.maxCorner.getY()) ||
(other.minCorner.getY() <= this.minCorner.getY() && this.minCorner.getY() <= other.maxCorner.getY());
boolean zi = (this.minCorner.getZ() <= other.minCorner.getZ() && other.minCorner.getZ() <= this.maxCorner.getZ()) ||
(other.minCorner.getZ() <= this.minCorner.getZ() && this.minCorner.getZ() <= other.maxCorner.getZ());
return xi && yi && zi;
}
}

View File

@@ -21,6 +21,8 @@ public class MazeBuilder
buildRooms(design.getRoomGraph(), world, offset);
carveDoorways(design.getRoomGraph(), world, offset, decay, random);
//placeDoors(design, world, offset);
applyRandomDestruction(design, world, offset, decay, random);
}

View File

@@ -7,6 +7,7 @@ public class MazeDesign
private PartitionNode root;
private DirectedGraph<PartitionNode, DoorwayData> rooms;
private ArrayList<IGraphNode<PartitionNode, DoorwayData>> cores;
private ArrayList<BoundingBox> protectedAreas;
public MazeDesign(PartitionNode root, DirectedGraph<PartitionNode, DoorwayData> rooms,
ArrayList<IGraphNode<PartitionNode, DoorwayData>> cores)
@@ -31,6 +32,11 @@ public class MazeDesign
return cores;
}
public ArrayList<BoundingBox> getProtectedAreas()
{
return protectedAreas;
}
public int width()
{
return root.width();

View File

@@ -2,41 +2,22 @@ package StevenDimDoors.experimental;
import StevenDimDoors.mod_pocketDim.Point3D;
public class PartitionNode
public class PartitionNode extends BoundingBox
{
private Point3D minCorner;
private Point3D maxCorner;
private PartitionNode parent;
private PartitionNode leftChild = null;
private PartitionNode rightChild = null;
public PartitionNode(int width, int height, int length)
{
super(new Point3D(0, 0, 0), new Point3D(width - 1, height - 1, length - 1));
parent = null;
minCorner = new Point3D(0, 0, 0);
maxCorner = new Point3D(width - 1, height - 1, length - 1);
}
private PartitionNode(PartitionNode parent, Point3D minCorner, Point3D maxCorner)
{
super(minCorner, maxCorner);
this.parent = parent;
this.minCorner = minCorner;
this.maxCorner = maxCorner;
}
public int width()
{
return (maxCorner.getX() - minCorner.getX() + 1);
}
public int height()
{
return (maxCorner.getY() - minCorner.getY() + 1);
}
public int length()
{
return (maxCorner.getZ() - minCorner.getZ() + 1);
}
public boolean isLeaf()
@@ -54,16 +35,6 @@ public class PartitionNode
return rightChild;
}
public Point3D minCorner()
{
return minCorner;
}
public Point3D maxCorner()
{
return maxCorner;
}
public PartitionNode parent()
{
return parent;
@@ -123,13 +94,6 @@ public class PartitionNode
}
}
public boolean contains(int x, int y, int z)
{
return ((minCorner.getX() <= x && x <= maxCorner.getX()) &&
(minCorner.getY() <= y && y <= maxCorner.getY()) &&
(minCorner.getZ() <= z && z <= maxCorner.getZ()));
}
public PartitionNode findPoint(int x, int y, int z)
{
// Find the lowest node that contains the specified point or return null