public boolean contains(IBoundingVolume boundingVolume) { if(!(boundingVolume instanceof BoundingBox)) return false; BoundingBox boundingBox = (BoundingBox)boundingVolume; Vector3 otherMin = boundingBox.getTransformedMin(); Vector3 otherMax = boundingBox.getTransformedMax(); Vector3 min = mTransformedMin; Vector3 max = mTransformedMax; return (max.x >= otherMax.x) && (min.x <= otherMin.x) && (max.y >= otherMax.y) && (min.y <= otherMin.y) && (max.z >= otherMax.z) && (min.z <= otherMin.z); }
/** * Gets the bounding sphere for this geometry. If there is not current bounding * sphere it will be calculated. * * @return */ public BoundingSphere getBoundingSphere() { if (mBoundingSphere == null) { mBoundingSphere = new BoundingSphere(this); } return mBoundingSphere; }
public BoundingBox(Geometry3D geometry) { this(); mGeometry = geometry; calculateBounds(mGeometry); }
public boolean intersectsWith(IBoundingVolume boundingVolume) { if(!(boundingVolume instanceof BoundingSphere)) return false; BoundingSphere boundingSphere = (BoundingSphere)boundingVolume; mTmpPos.setAll(mPosition); mTmpPos.subtract(boundingSphere.getPosition()); mDist = mTmpPos.x * mTmpPos.x + mTmpPos.y * mTmpPos.y + mTmpPos.z * mTmpPos.z; mMinDist = mRadius * mScale + boundingSphere.getRadius() * boundingSphere.getScale(); return mDist < mMinDist * mMinDist; }
private boolean intersectsWith(BoundingSphere bsphere) { return Intersector.intersectRaySphere(mRayStart, mRayEnd, bsphere.getPosition(), bsphere.getRadius(), mHitPoint); }
public boolean boundsInFrustum(BoundingBox bounds) { for(int i=0; i<6; i++) { Plane p = mPlanes[i]; mPoint1.x = p.getNormal().x > 0 ? bounds.getMin().x : bounds.getMax().x; mPoint2.x = p.getNormal().x > 0 ? bounds.getMax().x : bounds.getMin().x; mPoint1.y = p.getNormal().y > 0 ? bounds.getMin().y : bounds.getMax().y; mPoint2.y = p.getNormal().y > 0 ? bounds.getMax().y : bounds.getMin().y; mPoint1.z = p.getNormal().z > 0 ? bounds.getMin().z : bounds.getMax().z; mPoint2.z = p.getNormal().z > 0 ? bounds.getMax().z : bounds.getMin().z; double distance1 = p.getDistanceTo(mPoint1); double distance2 = p.getDistanceTo(mPoint2); if ( distance1 < 0 && distance2 < 0 ) return false; } return true; }
/** * Gets the bounding box for this geometry. If there is no current bounding * box it will be calculated. * * @return */ public BoundingBox getBoundingBox() { if (mBoundingBox == null) { mBoundingBox = new BoundingBox(this); } return mBoundingBox; }
@Override public String toString() { return "BoundingSphere radius: " + Double.toString(getScaledRadius()); }
public void calculateBounds(Geometry3D geometry) { mMin.setAll(Double.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE); mMax.setAll(-Double.MAX_VALUE, -Double.MAX_VALUE, -Double.MAX_VALUE); FloatBuffer vertices = geometry.getVertices(); if (vertices != null) { calculateMinMaxVertices(vertices, mMin, mMax); calculatePoints(); } }
@Test public void testGetRadius() { double radius = bounds.getRadius(); assertEquals(0, radius, 1e-14); }
@Test public void testGetScale() { double scale = bounds.getScale(); assertEquals(0, scale, 1e-14); }
public BoundingSphere(Geometry3D geometry) { this(); mGeometry = geometry; calculateBounds(mGeometry); }
@Override public IBoundingVolume getTransformedBoundingVolume() { IBoundingVolume volume = null; volume = getBoundingBox(); calculateModelMatrix(null); volume.transform(mMMatrix); return volume; } }
public BoundingBox(Vector3 min, Vector3 max) { this(); mMin.setAll(min.x, min.y, min.z); mMax.setAll(max.x, max.y, max.z); calculatePoints(); }
public boolean isContainedBy(IBoundingVolume boundingVolume) { if(!(boundingVolume instanceof BoundingBox)) return false; BoundingBox boundingBox = (BoundingBox)boundingVolume; Vector3 otherMin = boundingBox.getTransformedMin(); Vector3 otherMax = boundingBox.getTransformedMax(); Vector3 min = mTransformedMin; Vector3 max = mTransformedMax; return (max.x <= otherMax.x) && (min.x >= otherMin.x) && (max.y <= otherMax.y) && (min.y >= otherMin.y) && (max.z <= otherMax.z) && (min.z >= otherMin.z); }
@Before public void setup() { bounds = new BoundingSphere(); }
public SkeletalAnimationFrame() { mBounds = new BoundingBox(); mSkeleton = new Skeleton(); }
@Test public void testGetScaledRadius() { double scaledRadius = bounds.getScaledRadius(); assertEquals(0, scaledRadius, 1e-14); }
public boolean intersectsWith(IBoundingVolume boundingVolume) { if (!(boundingVolume instanceof BoundingBox)) { return false; } BoundingBox boundingBox = (BoundingBox) boundingVolume; Vector3 otherMin = boundingBox.getTransformedMin(); Vector3 otherMax = boundingBox.getTransformedMax(); Vector3 min = mTransformedMin; Vector3 max = mTransformedMax; return (min.x < otherMax.x) && (max.x > otherMin.x) && (min.y < otherMax.y) && (max.y > otherMin.y) && (min.z < otherMax.z) && (max.z > otherMin.z); }