/** * 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 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; }
@Override public String toString() { return "BoundingSphere radius: " + Double.toString(getScaledRadius()); }
private boolean intersectsWith(BoundingSphere bsphere) { return Intersector.intersectRaySphere(mRayStart, mRayEnd, bsphere.getPosition(), bsphere.getRadius(), mHitPoint); }
} else if (volume instanceof BoundingSphere) { BoundingSphere bs = (BoundingSphere) volume; Vector3 bs_position = bs.getPosition(); double radius = bs.getScaledRadius(); Vector3 rad = new Vector3(); rad.setAll(radius, radius, radius);
bsphere.calculateBounds(o.getGeometry()); bsphere.transform(o.getModelMatrix());
mGeometry.getBoundingSphere().transform(getModelMatrix()); mGeometry.getBoundingSphere().drawBoundingVolume(camera, vpMatrix, projMatrix, vMatrix, mMMatrix);
@Override protected void doTask() { // ensure all cameras can see the far side of the skybox float out_radius = (float)skybox.getGeometry().getBoundingSphere().getRadius(); float in_radius = out_radius/(float)Math.sqrt(3); float median_diagonal = in_radius + out_radius; for (int i = 0, j = mCameras.size(); i < j; ++i) if(mCameras.get(i).getFarPlane() < median_diagonal) { mCameras.get(i).setFarPlane(median_diagonal); } } };
@Test public void testGetScale() { double scale = bounds.getScale(); assertEquals(0, scale, 1e-14); }
@Test public void testGetPosition() { Vector3 position = bounds.getPosition(); assertEquals(0, position.x, 1e-14); assertEquals(0, position.y, 1e-14); assertEquals(0, position.z, 1e-14); }
public BoundingSphere(Geometry3D geometry) { this(); mGeometry = geometry; calculateBounds(mGeometry); }
/** * The reload method is called whenever the OpenGL context needs to be re-created. When the OpenGL context was lost, * the vertex, uv coord, index etc data needs to be re-uploaded. */ public void reload() { if (!mIsContainerOnly) { mGeometry.reload(); } for (int i = 0, j = mChildren.size(); i < j; i++) { mChildren.get(i).reload(); } if (mGeometry.hasBoundingBox() && getBoundingBox().getVisual() != null) { getBoundingBox().getVisual().reload(); } if (mGeometry.hasBoundingSphere() && mGeometry.getBoundingSphere().getVisual() != null) { mGeometry.getBoundingSphere().getVisual().reload(); } }
private boolean intersectsWith(BoundingSphere bsphere) { return Intersector.intersectRaySphere(mRayStart, mRayEnd, bsphere.getPosition(), bsphere.getRadius(), mHitPoint); }
} else if (volume instanceof BoundingSphere) { BoundingSphere bs = (BoundingSphere) volume; Vector3 bs_position = bs.getPosition(); double radius = bs.getScaledRadius(); Vector3 rad = new Vector3(); rad.setAll(radius, radius, radius);
bsphere.calculateBounds(o.getGeometry()); bsphere.transform(o.getModelMatrix());
mGeometry.getBoundingSphere().transform(getModelMatrix()); mGeometry.getBoundingBox().drawBoundingVolume(camera, vpMatrix, projMatrix, vMatrix, mMMatrix); if (mGeometry.hasBoundingSphere()) mGeometry.getBoundingSphere().drawBoundingVolume(camera, vpMatrix, projMatrix, vMatrix, mMMatrix);
@Test public void testGetRadius() { double radius = bounds.getRadius(); assertEquals(0, radius, 1e-14); }
public BoundingSphere(Geometry3D geometry) { this(); mGeometry = geometry; calculateBounds(mGeometry); }
/** * The reload method is called whenever the OpenGL context needs to be re-created. When the OpenGL context was lost, * the vertex, uv coord, index etc data needs to be re-uploaded. */ public void reload() { if (!mIsContainerOnly) { mGeometry.reload(); } for (int i = 0, j = mChildren.size(); i < j; i++) mChildren.get(i).reload(); if (mGeometry.hasBoundingBox() && mGeometry.getBoundingBox().getVisual() != null) mGeometry.getBoundingBox().getVisual().reload(); if (mGeometry.hasBoundingSphere() && mGeometry.getBoundingSphere().getVisual() != null) mGeometry.getBoundingSphere().getVisual().reload(); }
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; }