public String toString() { return "{"+getCenter()+":"+getRadius()+"}"; }
/** * Expands this box to include the specified bounding sphere. * @param bs the bounding sphere. */ public void expandBy(BoundingSphere bs) { if (!bs.isInfinite()) { if (!bs.isEmpty()) { double r = bs.getRadius(); Point3 c = bs.getCenter(); double x = c.x; double y = c.y; double z = c.z; if (_xmin>x-r) _xmin = x-r; if (_ymin>y-r) _ymin = y-r; if (_zmin>z-r) _zmin = z-r; if (_xmax<x+r) _xmax = x+r; if (_ymax<y+r) _ymax = y+r; if (_zmax<z+r) _zmax = z+r; } } else { setInfinite(); } }
/** * Determines whether the view frustrum intersects the bounding sphere * of the specified node. * @param node the node with a bounding sphere. * @return true, if the view frustum intersects the bounding sphere; * false, otherwise. */ public boolean frustumIntersectsSphereOf(Node node) { if (_active!=0) { // if at least one frustum plane is active, ... BoundingSphere bs = node.getBoundingSphere(false); if (bs.isEmpty()) return false; if (bs.isInfinite()) return true; Point3 c = bs.getCenter(); double r = bs.getRadius(); double s = -r; for (int i=0,plane=1; i<6; ++i,plane<<=1) { // for all six planes if ((_active&plane)!=0) { // if plane is active double d = _planes[i].distanceTo(c); // distance from center if (d<s) { // if sphere is entirely outside (below plane) return false; // no intersection } else if (d>r) { // else if sphere is entirely above plane _active ^= plane; // need not test this plane again } } } } return true; }
Point3 a = _farPoint; Point3 b = _nearPoint; Point3 c = bs.getCenter(); double r = bs.getRadius(); double rr = r*r;
_worldSphere = world.getBoundingSphere(true); BoundingSphere ws = _worldSphere; Point3 c = (!ws.isEmpty())?ws.getCenter():new Point3(); double tx = -c.x; double ty = -c.y;
if (!bs.isEmpty() && !bs.isInfinite()) { double r = bs.getRadius(); Point3 c = bs.getCenter(); Point3 x = new Point3(c.x+r,c.y,c.z); Point3 y = new Point3(c.x,c.y+r,c.z);