/** * <code>computeFromPoints</code> creates a new Bounding Box from a given * set of points. It uses the <code>containAABB</code> method as default. * * @param points * the points to contain. */ public void computeFromPoints(FloatBuffer points) { containAABB(points); }
/** * * <code>transform</code> alters the location of the bounding volume by a * rotation, translation and a scalar. * * @param trans * the transform to affect the bound. * @return the new bounding volume. */ public final BoundingVolume transform(Transform trans) { return transform(trans, null); }
private static float calcScreenArea(BoundingSphere bound, float distance, float screenWidth) { // Where is the center point and a radius point that lies in a plan parallel to the view plane? // // Calc radius based on these two points and plug into circle area formula. // Vector2f centerSP = null; // Vector2f outerSP = null; // float radiusSq = centerSP.subtract(outerSP).lengthSquared(); float radius = (bound.getRadius() * screenWidth) / (distance * 2); return radius * radius * FastMath.PI; }
private static float calcScreenArea(BoundingBox bound, float distance, float screenWidth) { // Calc as if we are a BoundingSphere for now... float radiusSquare = bound.getXExtent() * bound.getXExtent() + bound.getYExtent() * bound.getYExtent() + bound.getZExtent() * bound.getZExtent(); return ((radiusSquare * screenWidth * screenWidth) / (distance * distance * 4)) * FastMath.PI; } }
private int collideWithBoundingVolume(BoundingVolume boundingVolume, CollisionResults results) { if (boundingVolume instanceof BoundingBox) return collideWithBoundingBox((BoundingBox)boundingVolume, results); else if(boundingVolume instanceof BoundingSphere) { BoundingSphere sphere = (BoundingSphere) boundingVolume; BoundingBox bbox = new BoundingBox(boundingVolume.getCenter().clone(), sphere.getRadius(), sphere.getRadius(), sphere.getRadius()); return collideWithBoundingBox(bbox, results); } return 0; }
@Override public int collideWith(Collidable other) { if (other instanceof Ray) { Ray ray = (Ray) other; return collideWithRay(ray); } else if (other instanceof Triangle){ return super.collideWith(other); } else if (other instanceof BoundingVolume) { return intersects((BoundingVolume)other) ? 1 : 0; } else { throw new UnsupportedCollisionException(); } }
@Override public boolean intersectsBox(BoundingBox box, TempVars vars) { if (this.radius == 0) { return true; } else { // Sphere v. box collision return Intersection.intersect(box, position, radius); } }
/** * <code>merge</code> combines this bounding box locally with a second * bounding volume. The result contains both the original box and the second * volume. * * @param volume the bounding volume to combine with this box (or null) (not * altered) * @return this box (with its components modified) or null if the second * volume is of some type other than AABB or Sphere */ public BoundingVolume merge(BoundingVolume volume) { return mergeLocal(volume); }
public BoundingBox(Vector3f min, Vector3f max) { setMinMax(min, max); }
/** * <code>computeFromPoints</code> creates a new Bounding Sphere from a * given set of points. It uses the <code>calcWelzl</code> method as * default. * * @param points * the points to contain. */ public void computeFromPoints(FloatBuffer points) { calcWelzl(points); }
/** * intersects determines if this Bounding Box intersects with another given * bounding volume. If so, true is returned, otherwise, false is returned. * * @see BoundingVolume#intersects(com.jme3.bounding.BoundingVolume) */ public boolean intersects(BoundingVolume bv) { return bv.intersectsBoundingBox(this); }
public boolean intersects(BoundingVolume bv) { return bv.intersectsSphere(this); }
/** * determines if this bounding box intersects a given bounding sphere. * * @see BoundingVolume#intersectsSphere(com.jme3.bounding.BoundingSphere) */ public boolean intersectsSphere(BoundingSphere bs) { return bs.intersectsBoundingBox(this); }
@Override public boolean intersectsFrustum(Camera camera, TempVars vars) { if (this.radius == 0) { return true; } else { return Intersection.intersect(camera, position, radius); } }
@Override public boolean intersectsSphere(BoundingSphere sphere, TempVars vars) { if (this.radius == 0) { return true; } else { // Sphere v. sphere collision return Intersection.intersect(sphere, position, radius); } }
/** * C code ported from <a href="http://www.cs.lth.se/home/Tomas_Akenine_Moller/code/tribox3.txt"> * http://www.cs.lth.se/home/Tomas_Akenine_Moller/code/tribox3.txt</a> * * @param v1 The first point in the triangle * @param v2 The second point in the triangle * @param v3 The third point in the triangle * @return True if the bounding box intersects the triangle, false * otherwise. */ public boolean intersects(Vector3f v1, Vector3f v2, Vector3f v3) { return Intersection.intersect(this, v1, v2, v3); }
@Override public boolean intersectsBox(BoundingBox box, TempVars vars) { return Intersection.intersect(box, center, radius); }
@Override public boolean intersectsSphere(BoundingSphere sphere, TempVars vars) { return Intersection.intersect(sphere, center, radius); }
@Override public boolean intersectsFrustum(Camera camera, TempVars vars) { return Intersection.intersect(camera, center, radius); }
public boolean intersectsBoundingBox(BoundingBox bb) { return Intersection.intersect(bb, center, radius); }