Package com.jme3.bounding
Class BoundingSphere
java.lang.Object
com.jme3.bounding.BoundingVolume
com.jme3.bounding.BoundingSphere
- All Implemented Interfaces:
- Collidable,- Savable,- Cloneable
BoundingSphere defines a sphere that defines a container for a
 group of vertices of a particular piece of geometry. This sphere defines a
 radius and a center. A typical usage is to allow the class define the center and radius by calling either
containAABB or averagePoints. A call to
 computeFramePoint in turn calls containAABB.- 
Nested Class SummaryNested classes/interfaces inherited from class com.jme3.bounding.BoundingVolumeBoundingVolume.Type
- 
Field SummaryFields inherited from class com.jme3.bounding.BoundingVolumecenter, checkPlane
- 
Constructor SummaryConstructorsConstructorDescriptionDefault constructor instantiates a newBoundingSphereobject.BoundingSphere(float r, Vector3f c) Constructor instantiates a newBoundingSphereobject.
- 
Method SummaryModifier and TypeMethodDescriptionvoidaveragePoints(Vector3f[] points) averagePointsselects the sphere center to be the average of the points and the sphere radius to be the smallest value to enclose all points.voidcalcWelzl(FloatBuffer points) Calculates a minimum bounding sphere for the set of points.clone(BoundingVolume store) clonecreates a new BoundingSphere object containing the same data as this one.intcollideWith(Collidable other) intcollideWith(Collidable other, CollisionResults results) Check collision with another Collidable.voidcomputeFromPoints(FloatBuffer points) computeFromPointscreates a new Bounding Sphere from a given set of points.voidcomputeFromTris(Triangle[] tris, int start, int end) computeFromTriscreates a new Bounding Box from a given set of triangles.booleandetermines if a given point is contained within this bounding volume.floatdistanceToEdge(Vector3f point) Find the distance from the nearest edge of this Bounding Volume to the given point.floatgetRadiusreturns the radius of the bounding sphere.getType()getType returns the type of bounding volume this is.floatbooleandetermines if this bounding volume and a second given volume are intersecting.booleanintersects(Ray ray) determines if a ray intersects this bounding volume.booleanintersects(Vector3f point) Determines if a given point intersects (touches or is inside) this bounding volume.booleandetermines if this bounding volume and a given bounding box are intersecting.booleandetermines if this bounding volume and a given bounding sphere are intersecting.merge(BoundingVolume volume) mergecombines this sphere with a second bounding sphere.mergeLocal(BoundingVolume volume) mergeLocalcombines this sphere with a second bounding sphere locally.voidread(JmeImporter importer) voidsetRadius(float radius) setRadiussets the radius of this bounding sphere.toString()toStringreturns the string representation of this object.transform(Matrix4f trans, BoundingVolume store) transform(Transform trans, BoundingVolume store) transformmodifies the center of the sphere to reflect the change made via a rotation, translation and scale.whichSidetakes a plane (typically provided by a view frustum) to determine which side this bound is on.voidwrite(JmeExporter e) Methods inherited from class com.jme3.bounding.BoundingVolumeclone, distanceSquaredTo, distanceTo, getCenter, getCenter, getCheckPlane, setCenter, setCenter, setCheckPlane, transform
- 
Constructor Details- 
BoundingSpherepublic BoundingSphere()Default constructor instantiates a newBoundingSphereobject.
- 
BoundingSphereConstructor instantiates a newBoundingSphereobject.- Parameters:
- r- the radius of the sphere.
- c- the center of the sphere.
 
 
- 
- 
Method Details- 
getTypeDescription copied from class:BoundingVolumegetType returns the type of bounding volume this is.- Specified by:
- getTypein class- BoundingVolume
- Returns:
- an enum value
 
- 
getRadiuspublic float getRadius()getRadiusreturns the radius of the bounding sphere.- Returns:
- the radius of the bounding sphere.
 
- 
setRadiuspublic void setRadius(float radius) setRadiussets the radius of this bounding sphere.- Parameters:
- radius- the new radius of the bounding sphere.
 
- 
computeFromPointscomputeFromPointscreates a new Bounding Sphere from a given set of points. It uses thecalcWelzlmethod as default.- Specified by:
- computeFromPointsin class- BoundingVolume
- Parameters:
- points- the points to contain.
 
- 
computeFromTriscomputeFromTriscreates a new Bounding Box from a given set of triangles. It is used in OBBTree calculations.- Parameters:
- tris- triangle data (unaffected)
- start- the index of the first triangle to be used
- end- the index of the triangle after the last one to be used
 
- 
calcWelzlCalculates a minimum bounding sphere for the set of points. The algorithm was originally found in C++ at
 http://flipcode.com/archives/Smallest_Enclosing_Spheres.shtml
 and translated to java by Cep21- Parameters:
- points- The points to calculate the minimum bounds from.
 
- 
averagePointsaveragePointsselects the sphere center to be the average of the points and the sphere radius to be the smallest value to enclose all points.- Parameters:
- points- the list of points to contain.
 
- 
transformtransformmodifies the center of the sphere to reflect the change made via a rotation, translation and scale.- Specified by:
- transformin class- BoundingVolume
- Parameters:
- trans- the transform to apply
- store- sphere to store result in
- Returns:
- either store or a new BoundingSphere
 
- 
transform- Specified by:
- transformin class- BoundingVolume
 
- 
whichSidewhichSidetakes a plane (typically provided by a view frustum) to determine which side this bound is on.- Specified by:
- whichSidein class- BoundingVolume
- Parameters:
- plane- the plane to check against.
- Returns:
- side
 
- 
mergemergecombines this sphere with a second bounding sphere. This new sphere contains both bounding spheres and is returned.- Specified by:
- mergein class- BoundingVolume
- Parameters:
- volume- the sphere to combine with this sphere.
- Returns:
- a new sphere
 
- 
mergeLocalmergeLocalcombines this sphere with a second bounding sphere locally. Altering this sphere to contain both the original and the additional sphere volumes;- Specified by:
- mergeLocalin class- BoundingVolume
- Parameters:
- volume- the sphere to combine with this sphere.
- Returns:
- this
 
- 
cloneclonecreates a new BoundingSphere object containing the same data as this one.- Specified by:
- clonein class- BoundingVolume
- Parameters:
- store- where to store the cloned information. if null or wrong class, a new store is created.
- Returns:
- the new BoundingSphere
 
- 
toStringtoStringreturns the string representation of this object. The form is: "Radius: RRR.SSSS Center: vector".
- 
intersectsDescription copied from class:BoundingVolumedetermines if this bounding volume and a second given volume are intersecting. Intersecting being: one volume contains another, one volume overlaps another or one volume touches another.- Specified by:
- intersectsin class- BoundingVolume
- Parameters:
- bv- the second volume to test against.
- Returns:
- true if this volume intersects the given volume.
 
- 
intersectsSphereDescription copied from class:BoundingVolumedetermines if this bounding volume and a given bounding sphere are intersecting.- Specified by:
- intersectsSpherein class- BoundingVolume
- Parameters:
- bs- the bounding sphere to test against.
- Returns:
- true if this volume intersects the given bounding sphere.
 
- 
intersectsBoundingBoxDescription copied from class:BoundingVolumedetermines if this bounding volume and a given bounding box are intersecting.- Specified by:
- intersectsBoundingBoxin class- BoundingVolume
- Parameters:
- bb- the bounding box to test against.
- Returns:
- true if this volume intersects the given bounding box.
 
- 
intersectsDescription copied from class:BoundingVolumedetermines if a ray intersects this bounding volume.- Specified by:
- intersectsin class- BoundingVolume
- Parameters:
- ray- the ray to test.
- Returns:
- true if this volume is intersected by a given ray.
 
- 
collideWithDescription copied from interface:CollidableCheck collision with another Collidable.- Parameters:
- other- The object to check collision against
- results- Will contain the list of- CollisionResults.
- Returns:
- how many collisions were found between this and other
 
- 
collideWith- Overrides:
- collideWithin class- BoundingVolume
 
- 
containsDescription copied from class:BoundingVolumedetermines if a given point is contained within this bounding volume. If the point is on the edge of the bounding volume, this method will return false. Use intersects(Vector3f) to check for edge intersection.- Specified by:
- containsin class- BoundingVolume
- Parameters:
- point- the point to check
- Returns:
- true if the point lies within this bounding volume.
 
- 
intersectsDescription copied from class:BoundingVolumeDetermines if a given point intersects (touches or is inside) this bounding volume.- Specified by:
- intersectsin class- BoundingVolume
- Parameters:
- point- the point to check
- Returns:
- true if the point lies within this bounding volume.
 
- 
distanceToEdgeDescription copied from class:BoundingVolumeFind the distance from the nearest edge of this Bounding Volume to the given point.- Specified by:
- distanceToEdgein class- BoundingVolume
- Parameters:
- point- The point to get the distance to
- Returns:
- distance
 
- 
write- Specified by:
- writein interface- Savable
- Overrides:
- writein class- BoundingVolume
- Throws:
- IOException
 
- 
read- Specified by:
- readin interface- Savable
- Overrides:
- readin class- BoundingVolume
- Throws:
- IOException
 
- 
getVolumepublic float getVolume()- Specified by:
- getVolumein class- BoundingVolume
 
 
-