Package com.jme3.bullet.collision.shapes
Class MultiSphere
java.lang.Object
com.jme3.bullet.NativePhysicsObject
com.jme3.bullet.collision.shapes.CollisionShape
com.jme3.bullet.collision.shapes.ConvexShape
com.jme3.bullet.collision.shapes.MultiSphere
- All Implemented Interfaces:
Comparable<NativePhysicsObject>
A convex collision shape based on Bullet's
btMultiSphereShape
. Unlike
a CapsuleCollisionShape
or a SphereCollisionShape
, these
shapes have margins and can be scaled non-uniformly.-
Field Summary
Fields inherited from class com.jme3.bullet.collision.shapes.ConvexShape
loggerX
Fields inherited from class com.jme3.bullet.collision.shapes.CollisionShape
enableContactFilter, logger, margin, scale
Fields inherited from class com.jme3.bullet.NativePhysicsObject
loggerN
-
Constructor Summary
ConstructorDescriptionMultiSphere
(float radius) Instantiate a centered sphere shape with the specified radius.MultiSphere
(float radius, float height) Instantiate a centered Y-axis capsule shape with the specified radius and height.MultiSphere
(float radius, float height, int axisIndex) Instantiate a centered capsule shape with the specified radius, height, and axis.MultiSphere
(Vector3f[] centers, float... radii) Instantiate a multi-sphere shape with the specified centers and radii.MultiSphere
(Vector3f center, float radius) Instantiate an eccentric sphere shape with the specified center and radius.MultiSphere
(List<Vector3f> centers, List<Float> radii) Instantiate a multi-sphere shape with the specified centers and radii.MultiSphere
(RectangularSolid rectangularSolid) Instantiate a 4-sphere shape to fill the specified RectangularSolid. -
Method Summary
Modifier and TypeMethodDescriptioncopyCenter
(int sphereIndex, Vector3f storeResult) Copy the location of the center of the indexed sphere.int
Count the spheres in the shape.float
getRadius
(int sphereIndex) Return the radius of the indexed sphere.protected void
Recalculate the shape's bounding box if necessary.float
Estimate the volume of the shape, including scale and margin.Approximate this shape with a HullCollisionShape.Methods inherited from class com.jme3.bullet.collision.shapes.ConvexShape
isConcave, isConvex, toSplittableShape
Methods inherited from class com.jme3.bullet.collision.shapes.CollisionShape
aabbCenter, boundingBox, boundingBox, canScale, canSplit, getDefaultMargin, getMargin, getScale, getScaleDp, getShapeType, getShapeType, isContactFilterEnabled, isInfinite, isNonMoving, isPolyhedral, maxRadius, nativeMargin, setContactFilterEnabled, setDefaultMargin, setMargin, setNativeId, setScale, setScale, setUserIndex, setUserIndex2, toString, updateScale, userIndex, userIndex2
Methods inherited from class com.jme3.bullet.NativePhysicsObject
compareTo, countTrackers, dumpTrackers, equals, freeUnusedObjects, hasAssignedNativeObject, hashCode, nativeId, reassignNativeId, setNativeIdNotTracked, unassignNativeObject
-
Field Details
-
logger2
message logger for this class
-
-
Constructor Details
-
MultiSphere
public MultiSphere(float radius) Instantiate a centered sphere shape with the specified radius.- Parameters:
radius
- the desired radius (in shape units, ≥0)
-
MultiSphere
public MultiSphere(float radius, float height) Instantiate a centered Y-axis capsule shape with the specified radius and height.- Parameters:
radius
- the desired radius (in shape units, ≥0)height
- the desired height of the cylindrical portion (in shape units, ≥0)
-
MultiSphere
public MultiSphere(float radius, float height, int axisIndex) Instantiate a centered capsule shape with the specified radius, height, and axis.- Parameters:
radius
- the desired radius (in shape units, ≥0)height
- the desired height of the cylindrical portion (in shape units, ≥0)axisIndex
- which local axis to use for the height: 0→X, 1→Y, 2→Z
-
MultiSphere
Instantiate a multi-sphere shape with the specified centers and radii.- Parameters:
centers
- the list of center locations (in shape coordinates, not null, not empty)radii
- the list of radii (in shape units, not null, not empty, each ≥0)
-
MultiSphere
Instantiate a 4-sphere shape to fill the specified RectangularSolid. The spheres will be of equal size, arranged in a rectangle.- Parameters:
rectangularSolid
- the solid on which to base the shape (not null)
-
MultiSphere
Instantiate an eccentric sphere shape with the specified center and radius.- Parameters:
center
- the location of the sphere's center (in shape coordinates, not null, unaffected)radius
- the desired radius (in shape units, ≥0)
-
MultiSphere
Instantiate a multi-sphere shape with the specified centers and radii.- Parameters:
centers
- the array of center locations (in shape coordinates, not null, not empty)radii
- the array of radii (in shape units, not null, not empty, each ≥0)
-
-
Method Details
-
copyCenter
Copy the location of the center of the indexed sphere.- Parameters:
sphereIndex
- which sphere to read (≥0)storeResult
- storage for the result (modified if not null)- Returns:
- the center location (in shape coordinates, either
storeResult
or a new instance, not null)
-
countSpheres
public int countSpheres()Count the spheres in the shape.- Returns:
- the count (>0)
-
getRadius
public float getRadius(int sphereIndex) Return the radius of the indexed sphere.- Parameters:
sphereIndex
- which sphere to read (≥0)- Returns:
- the unscaled radius (≥0)
-
recalculateAabb
protected void recalculateAabb()Recalculate the shape's bounding box if necessary.- Overrides:
recalculateAabb
in classCollisionShape
-
scaledVolume
public float scaledVolume()Estimate the volume of the shape, including scale and margin.- Overrides:
scaledVolume
in classConvexShape
- Returns:
- the volume (in physics-space units cubed, ≥0)
-
toHullShape
Approximate this shape with a HullCollisionShape.- Overrides:
toHullShape
in classConvexShape
- Returns:
- a new shape
-