Class MyShape

java.lang.Object
jme3utilities.minie.MyShape

public final class MyShape extends Object
Utility methods for physics collision shapes. All methods should be static.
  • Field Details

    • logger

      public static final Logger logger
      message logger for this class
  • Method Details

    • describeType

      public static String describeType(CollisionShape shape)
      Describe the type of the specified shape.
      Parameters:
      shape - the shape to describe (not null, unaffected)
      Returns:
      the type description (not null)
    • halfExtents

      public static com.jme3.math.Vector3f halfExtents(CollisionShape shape, com.jme3.math.Vector3f storeResult)
      Determine the unscaled half extents of the specified shape.
      Parameters:
      shape - (not null, unaffected)
      storeResult - storage for the result (modified if not null)
      Returns:
      a vector with all components non-negative (either storeResult or a new instance)
    • height

      public static float height(CollisionShape shape)
      Determine the unscaled height of the specified shape.
      Parameters:
      shape - (not null, unaffected)
      Returns:
      the unscaled height (≥0) used to create the shape, or NaN if that height is undefined or unknown
    • listVolumes

      public static float[] listVolumes(CompoundCollisionShape shape)
      Estimate the volume of each child in a CompoundCollisionShape.
      Parameters:
      shape - (not null, unaffected)
      Returns:
      a new array of volumes (each ≥0)
    • mainAxisIndex

      public static int mainAxisIndex(CollisionShape shape)
      Determine the main axis of the specified shape, provided it's a capsule, cone, or cylinder.
      Parameters:
      shape - (may be null, unaffected)
      Returns:
      0→X, 1→Y, 2→Z, -1→doesn't have a main axis
    • parseNativeId

      public static long parseNativeId(String string)
      Parse the native ID of a shape from its String representation.
      Parameters:
      string - the input text (not null, exactly one "#")
      Returns:
      the shape's ID
      See Also:
    • radius

      public static float radius(CollisionShape shape)
      Determine the unscaled radius of the specified shape.
      Parameters:
      shape - (not null, unaffected)
      Returns:
      the unscaled radius (≥0) used to create the shape, or NaN if that radius is undefined or unknown
    • setHalfExtents

      public static CollisionShape setHalfExtents(CollisionShape oldShape, com.jme3.math.Vector3f newHalfExtents)
      Copy a shape, altering only its half extents.
      Parameters:
      oldShape - input shape (not null, unaffected)
      newHalfExtents - (not null, no negative component, unaffected)
      Returns:
      a new shape, or null if not possible
    • setHeight

      public static CollisionShape setHeight(CollisionShape oldShape, float newHeight)
      Copy a shape, altering only its height.
      Parameters:
      oldShape - input shape (not null, unaffected)
      newHeight - the desired unscaled height (≥0)
      Returns:
      a new shape
    • setRadius

      public static CollisionShape setRadius(CollisionShape oldShape, float newRadius)
      Copy a shape, altering only its radius.
      Parameters:
      oldShape - input shape (not null, unaffected)
      newRadius - the desired unscaled radius (≥0)
      Returns:
      a new shape
    • volume

      public static float volume(CollisionShape shape)
      Estimate the scaled volume of a closed shape.
      Parameters:
      shape - (not null, unaffected)
      Returns:
      the volume (in physics-space units cubed, ≥0)