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:
com.jme3.export.Savable
,com.jme3.util.clone.JmeCloneable
,Cloneable
,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
ModifierConstructorDescriptionprotected
No-argument constructor needed by SavableClassUtil.MultiSphere
(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
(com.jme3.bounding.BoundingSphere boundingSphere) Instantiate an eccentric sphere shape to match the specified BoundingSphere.MultiSphere
(com.jme3.math.Vector3f[] centers, float... radii) Instantiate a multi-sphere shape with the specified centers and radii.MultiSphere
(com.jme3.math.Vector3f center, float radius) Instantiate an eccentric sphere shape with the specified center and radius.MultiSphere
(List<com.jme3.math.Vector3f> centers, List<Float> radii) Instantiate a multi-sphere shape with the specified centers and radii.MultiSphere
(jme3utilities.math.RectangularSolid rectangularSolid) Instantiate a 4-sphere shape to fill the specified RectangularSolid.MultiSphere
(jme3utilities.math.RectangularSolid rectangularSolid, float fraction) Instantiate a 2-sphere shape to approximate the specified RectangularSolid. -
Method Summary
Modifier and TypeMethodDescriptionvoid
cloneFields
(com.jme3.util.clone.Cloner cloner, Object original) Callback fromCloner
to convert this shallow-cloned shape into a deep-cloned one, using the specified Cloner and original to resolve copied fields.com.jme3.math.Vector3f
copyCenter
(int sphereIndex, com.jme3.math.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.void
read
(com.jme3.export.JmeImporter importer) De-serialize the shape from the specified importer, for example when loading from a J3O file.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.void
write
(com.jme3.export.JmeExporter exporter) Serialize this shape to the specified exporter, for example when saving to a J3O file.Methods inherited from class com.jme3.bullet.collision.shapes.ConvexShape
isConcave, isConvex, toSplittableShape
Methods inherited from class com.jme3.bullet.collision.shapes.CollisionShape
aabbCenter, aabbScaledVolume, boundingBox, boundingBox, canScale, canSplit, copyShapeProperties, getDefaultMargin, getMargin, getScale, getScaleDp, getShapeType, getShapeType, isContactFilterEnabled, isInfinite, isNonMoving, isPolyhedral, jmeClone, maxRadius, nativeMargin, readShapeProperties, 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
protected MultiSphere()No-argument constructor needed by SavableClassUtil. -
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
public MultiSphere(com.jme3.bounding.BoundingSphere boundingSphere) Instantiate an eccentric sphere shape to match the specified BoundingSphere.- Parameters:
boundingSphere
- (not null, unaffected)
-
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
public MultiSphere(jme3utilities.math.RectangularSolid rectangularSolid) 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
public MultiSphere(jme3utilities.math.RectangularSolid rectangularSolid, float fraction) Instantiate a 2-sphere shape to approximate the specified RectangularSolid. The spheres will be of equal size, as in a capsule.- Parameters:
rectangularSolid
- the solid on which to base the shape (not null)fraction
- used to determine sphere radii (0→shortest axis, 1→medium axis)
-
MultiSphere
public MultiSphere(com.jme3.math.Vector3f center, float radius) 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
public MultiSphere(com.jme3.math.Vector3f[] centers, float... radii) 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
public com.jme3.math.Vector3f copyCenter(int sphereIndex, com.jme3.math.Vector3f storeResult) 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)
-
cloneFields
Callback fromCloner
to convert this shallow-cloned shape into a deep-cloned one, using the specified Cloner and original to resolve copied fields.- Specified by:
cloneFields
in interfacecom.jme3.util.clone.JmeCloneable
- Overrides:
cloneFields
in classCollisionShape
- Parameters:
cloner
- the Cloner that's cloning this shape (not null)original
- the instance from which this shape was shallow-cloned (not null, unaffected)
-
read
De-serialize the shape from the specified importer, for example when loading from a J3O file.- Specified by:
read
in interfacecom.jme3.export.Savable
- Overrides:
read
in classCollisionShape
- Parameters:
importer
- (not null)- Throws:
IOException
- from the importer
-
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
-
write
Serialize this shape to the specified exporter, for example when saving to a J3O file.- Specified by:
write
in interfacecom.jme3.export.Savable
- Overrides:
write
in classCollisionShape
- Parameters:
exporter
- (not null)- Throws:
IOException
- from the exporter
-