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
FieldsFields inherited from class com.jme3.bullet.collision.shapes.ConvexShape
loggerXFields inherited from class com.jme3.bullet.collision.shapes.CollisionShape
enableContactFilter, logger, margin, scaleFields inherited from class com.jme3.bullet.NativePhysicsObject
loggerN -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedNo-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 TypeMethodDescriptionvoidcloneFields(com.jme3.util.clone.Cloner cloner, Object original) Callback fromClonerto convert this shallow-cloned shape into a deep-cloned one, using the specified Cloner and original to resolve copied fields.com.jme3.math.Vector3fcopyCenter(int sphereIndex, com.jme3.math.Vector3f storeResult) Copy the location of the center of the indexed sphere.intCount the spheres in the shape.floatgetRadius(int sphereIndex) Return the radius of the indexed sphere.voidread(com.jme3.export.JmeImporter importer) De-serialize the shape from the specified importer, for example when loading from a J3O file.protected voidRecalculate the shape's bounding box if necessary.floatEstimate the volume of the shape, including scale and margin.Approximate this shape with a HullCollisionShape.voidwrite(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, toSplittableShapeMethods 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, userIndex2Methods 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
storeResultor 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 fromClonerto convert this shallow-cloned shape into a deep-cloned one, using the specified Cloner and original to resolve copied fields.- Specified by:
cloneFieldsin interfacecom.jme3.util.clone.JmeCloneable- Overrides:
cloneFieldsin 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:
readin interfacecom.jme3.export.Savable- Overrides:
readin classCollisionShape- Parameters:
importer- (not null)- Throws:
IOException- from the importer
-
recalculateAabb
protected void recalculateAabb()Recalculate the shape's bounding box if necessary.- Overrides:
recalculateAabbin classCollisionShape
-
scaledVolume
public float scaledVolume()Estimate the volume of the shape, including scale and margin.- Overrides:
scaledVolumein classConvexShape- Returns:
- the volume (in physics-space units cubed, ≥0)
-
toHullShape
Approximate this shape with a HullCollisionShape.- Overrides:
toHullShapein classConvexShape- Returns:
- a new shape
-
write
Serialize this shape to the specified exporter, for example when saving to a J3O file.- Specified by:
writein interfacecom.jme3.export.Savable- Overrides:
writein classCollisionShape- Parameters:
exporter- (not null)- Throws:
IOException- from the exporter
-