|
@@ -102,6 +102,14 @@ public class BoundingBox extends BoundingVolume {
|
|
|
this.zExtent = source.zExtent;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Instantiate a BoundingBox with the specified extremes.
|
|
|
+ *
|
|
|
+ * @param min the desired minimum coordinate value for each axis (not null,
|
|
|
+ * not altered)
|
|
|
+ * @param max the desired maximum coordinate value for each axis (not null,
|
|
|
+ * not altered)
|
|
|
+ */
|
|
|
public BoundingBox(Vector3f min, Vector3f max) {
|
|
|
setMinMax(min, max);
|
|
|
}
|
|
@@ -1009,18 +1017,38 @@ public class BoundingBox extends BoundingVolume {
|
|
|
return store;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Determine the X-axis distance between the center and the boundary.
|
|
|
+ *
|
|
|
+ * @return the distance
|
|
|
+ */
|
|
|
public float getXExtent() {
|
|
|
return xExtent;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Determine the Y-axis distance between the center and the boundary.
|
|
|
+ *
|
|
|
+ * @return the distance
|
|
|
+ */
|
|
|
public float getYExtent() {
|
|
|
return yExtent;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Determine the Z-axis distance between the center and the boundary.
|
|
|
+ *
|
|
|
+ * @return the distance
|
|
|
+ */
|
|
|
public float getZExtent() {
|
|
|
return zExtent;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Alter the X-axis distance between the center and the boundary.
|
|
|
+ *
|
|
|
+ * @param xExtent the desired distance (≥0)
|
|
|
+ */
|
|
|
public void setXExtent(float xExtent) {
|
|
|
if (xExtent < 0) {
|
|
|
throw new IllegalArgumentException();
|
|
@@ -1029,6 +1057,11 @@ public class BoundingBox extends BoundingVolume {
|
|
|
this.xExtent = xExtent;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Alter the Y-axis distance between the center and the boundary.
|
|
|
+ *
|
|
|
+ * @param yExtent the desired distance (≥0)
|
|
|
+ */
|
|
|
public void setYExtent(float yExtent) {
|
|
|
if (yExtent < 0) {
|
|
|
throw new IllegalArgumentException();
|
|
@@ -1037,6 +1070,11 @@ public class BoundingBox extends BoundingVolume {
|
|
|
this.yExtent = yExtent;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Alter the Z-axis distance between the center and the boundary.
|
|
|
+ *
|
|
|
+ * @param zExtent the desired distance (≥0)
|
|
|
+ */
|
|
|
public void setZExtent(float zExtent) {
|
|
|
if (zExtent < 0) {
|
|
|
throw new IllegalArgumentException();
|
|
@@ -1045,6 +1083,12 @@ public class BoundingBox extends BoundingVolume {
|
|
|
this.zExtent = zExtent;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Determine the minimum coordinate value for each axis.
|
|
|
+ *
|
|
|
+ * @param store storage for the result (modified if not null)
|
|
|
+ * @return either storeResult or a new vector
|
|
|
+ */
|
|
|
public Vector3f getMin(Vector3f store) {
|
|
|
if (store == null) {
|
|
|
store = new Vector3f();
|
|
@@ -1053,6 +1097,12 @@ public class BoundingBox extends BoundingVolume {
|
|
|
return store;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Determine the maximum coordinate value for each axis.
|
|
|
+ *
|
|
|
+ * @param store storage for the result (modified if not null)
|
|
|
+ * @return either storeResult or a new vector
|
|
|
+ */
|
|
|
public Vector3f getMax(Vector3f store) {
|
|
|
if (store == null) {
|
|
|
store = new Vector3f();
|
|
@@ -1061,6 +1111,14 @@ public class BoundingBox extends BoundingVolume {
|
|
|
return store;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Reconfigure with the specified extremes.
|
|
|
+ *
|
|
|
+ * @param min the desired minimum coordinate value for each axis (not null,
|
|
|
+ * not altered)
|
|
|
+ * @param max the desired maximum coordinate value for each axis (not null,
|
|
|
+ * not altered)
|
|
|
+ */
|
|
|
public void setMinMax(Vector3f min, Vector3f max) {
|
|
|
this.center.set(max).addLocal(min).multLocal(0.5f);
|
|
|
xExtent = FastMath.abs(max.x - center.x);
|
|
@@ -1090,4 +1148,4 @@ public class BoundingBox extends BoundingVolume {
|
|
|
public float getVolume() {
|
|
|
return (8 * xExtent * yExtent * zExtent);
|
|
|
}
|
|
|
-}
|
|
|
+}
|