Class MultiSphere

All Implemented Interfaces:
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

      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(List<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(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(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(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 Vector3f copyCenter(int sphereIndex, 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)
    • 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