/** * Returns the size in y-direction * * @return The size in y-direction */ float getSizeY() { return getMaxY() - getMinY(); }
/** * Combine this bounding box with the given one * * @param other The other bounding box */ void combine(BoundingBox other) { Objects.requireNonNull(other, "The other bounding box may not be null"); minX = Math.min(minX, other.getMinX()); minY = Math.min(minY, other.getMinY()); minZ = Math.min(minZ, other.getMinZ()); maxX = Math.max(maxX, other.getMaxX()); maxY = Math.max(maxY, other.getMaxY()); maxZ = Math.max(maxZ, other.getMaxZ()); }
@Override public String toString() { return "[(" + getMinX() + "," + getMinY() + "," + getMinZ() + ")-(" + getMaxX() + "," + getMaxY() + "," + getMaxZ() + ")]"; } }
/** * Compute the bounding box of the given {@link GltfModel}. The result * will be an array <code>[minX, minY, minZ, maxX, maxY, maxZ]</code>. * * @param gltfModel The {@link GltfModel} * @return The bounding box */ public static float[] computeBoundingBoxMinMax(GltfModel gltfModel) { Objects.requireNonNull(gltfModel, "The gltfModel may not be null"); BoundingBoxComputer boundingBoxComputer = new BoundingBoxComputer(gltfModel); BoundingBox boundingBox = boundingBoxComputer.compute(); float result[] = { boundingBox.getMinX(), boundingBox.getMinY(), boundingBox.getMinZ(), boundingBox.getMaxX(), boundingBox.getMaxY(), boundingBox.getMaxZ() }; return result; }