Class MultiSphere

All Implemented Interfaces:
com.jme3.export.Savable, com.jme3.util.clone.JmeCloneable, Cloneable, Comparable<NativePhysicsObject>

public class MultiSphere extends ConvexShape
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 Details

    • logger2

      public static final Logger 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

      public MultiSphere(List<com.jme3.math.Vector3f> centers, List<Float> radii)
      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

      public void cloneFields(com.jme3.util.clone.Cloner cloner, Object original)
      Callback from Cloner 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 interface com.jme3.util.clone.JmeCloneable
      Overrides:
      cloneFields in class CollisionShape
      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

      public void read(com.jme3.export.JmeImporter importer) throws IOException
      De-serialize the shape from the specified importer, for example when loading from a J3O file.
      Specified by:
      read in interface com.jme3.export.Savable
      Overrides:
      read in class CollisionShape
      Parameters:
      importer - (not null)
      Throws:
      IOException - from the importer
    • recalculateAabb

      protected void recalculateAabb()
      Recalculate the shape's bounding box if necessary.
      Overrides:
      recalculateAabb in class CollisionShape
    • scaledVolume

      public float scaledVolume()
      Estimate the volume of the shape, including scale and margin.
      Overrides:
      scaledVolume in class ConvexShape
      Returns:
      the volume (in physics-space units cubed, ≥0)
    • toHullShape

      public HullCollisionShape toHullShape()
      Approximate this shape with a HullCollisionShape.
      Overrides:
      toHullShape in class ConvexShape
      Returns:
      a new shape
    • write

      public void write(com.jme3.export.JmeExporter exporter) throws IOException
      Serialize this shape to the specified exporter, for example when saving to a J3O file.
      Specified by:
      write in interface com.jme3.export.Savable
      Overrides:
      write in class CollisionShape
      Parameters:
      exporter - (not null)
      Throws:
      IOException - from the exporter