BoundingBox rVal = new BoundingBox(new Vector3f(0,0,0), 0, 0, 0); rVal.center.add(this.center).add(vBox.center).multLocal(.5f);   rVal.xExtent = Math.max(Math.abs(center.x - xExtent - rVal.center.x), rVal.xExtent); rVal.xExtent = Math.max(Math.abs(center.x + xExtent - rVal.center.x), rVal.xExtent); rVal.yExtent = Math.max(Math.abs(center.y - yExtent - rVal.center.y), rVal.yExtent); rVal.yExtent = Math.max(Math.abs(center.y + yExtent - rVal.center.y), rVal.yExtent); rVal.zExtent = Math.max(Math.abs(center.z - zExtent - rVal.center.z), rVal.zExtent); rVal.zExtent = Math.max(Math.abs(center.z + zExtent - rVal.center.z), rVal.zExtent);   rVal.xExtent = Math.max(Math.abs(vBox.center.x - vBox.xExtent - rVal.center.x), rVal.xExtent); rVal.xExtent = Math.max(Math.abs(vBox.center.x + vBox.xExtent - rVal.center.x), rVal.xExtent); rVal.yExtent = Math.max(Math.abs(vBox.center.y - vBox.yExtent - rVal.center.y), rVal.yExtent); rVal.yExtent = Math.max(Math.abs(vBox.center.y + vBox.yExtent - rVal.center.y), rVal.yExtent); rVal.zExtent = Math.max(Math.abs(vBox.center.z - vBox.zExtent - rVal.center.z), rVal.zExtent); rVal.zExtent = Math.max(Math.abs(vBox.center.z + vBox.zExtent - rVal.center.z), rVal.zExtent);  return rVal;
return merge(vBox, new BoundingBox(new Vector3f(0,0,0), 0, 0, 0));
    public BoundingVolume merge(BoundingVolume volume) {        if(volume == null) {            return this;        }        if (!(volume instanceof BoundingBox)) {            return this;        } else {            BoundingBox vBox = (BoundingBox)volume;            BoundingBox rVal = new BoundingBox(new Vector3f(0,0,0), 0, 0, 0);            rVal.center.add(this.center).add(vBox.center).multLocal(.5f);        // check first box for extents            rVal.xExtent = Math.max(Math.abs(center.x - xExtent - rVal.center.x), rVal.xExtent);            rVal.xExtent = Math.max(Math.abs(center.x + xExtent - rVal.center.x), rVal.xExtent);            rVal.yExtent = Math.max(Math.abs(center.y - yExtent - rVal.center.y), rVal.yExtent);            rVal.yExtent = Math.max(Math.abs(center.y + yExtent - rVal.center.y), rVal.yExtent);            rVal.zExtent = Math.max(Math.abs(center.z - zExtent - rVal.center.z), rVal.zExtent);            rVal.zExtent = Math.max(Math.abs(center.z + zExtent - rVal.center.z), rVal.zExtent);        // check second box for extents            rVal.xExtent = Math.max(Math.abs(vBox.center.x - vBox.xExtent - rVal.center.x), rVal.xExtent);            rVal.xExtent = Math.max(Math.abs(vBox.center.x + vBox.xExtent - rVal.center.x), rVal.xExtent);            rVal.yExtent = Math.max(Math.abs(vBox.center.y - vBox.yExtent - rVal.center.y), rVal.yExtent);            rVal.yExtent = Math.max(Math.abs(vBox.center.y + vBox.yExtent - rVal.center.y), rVal.yExtent);            rVal.zExtent = Math.max(Math.abs(vBox.center.z - vBox.zExtent - rVal.center.z), rVal.zExtent);            rVal.zExtent = Math.max(Math.abs(vBox.center.z + vBox.zExtent - rVal.center.z), rVal.zExtent);            return rVal;        }    }