Class CollisionShapeFactory

java.lang.Object
com.jme3.bullet.util.CollisionShapeFactory

public class CollisionShapeFactory extends Object
A utility class for generating collision shapes from Spatials.

This class is shared between JBullet and Native Bullet.

  • Method Details

    • createMeshShape

      public static CollisionShape createMeshShape(Spatial spatial)
      Create a mesh shape for the given Spatial.

      This type of collision shape is mesh-accurate and meant for immovable "world objects". Examples include terrain, houses or whole shooter levels.

      Objects with "mesh" type collision shape will not collide with each other.

      Creates a HeightfieldCollisionShape if the supplied spatial is a TerrainQuad.

      Parameters:
      spatial - the spatial on which to base the shape (not null)
      Returns:
      A MeshCollisionShape or a CompoundCollisionShape with MeshCollisionShapes as children if the supplied spatial is a Node. A HeightfieldCollisionShape if a TerrainQuad was supplied.
    • createDynamicMeshShape

      public static CollisionShape createDynamicMeshShape(Spatial spatial)
      Create a hull shape for the given Spatial.

      For mesh-accurate animated meshes (CPU intense!) use GImpact shapes.

      Parameters:
      spatial - the spatial on which to base the shape (not null)
      Returns:
      a HullCollisionShape (if spatial is a Geometry) or a CompoundCollisionShape with HullCollisionShapes as children (if spatial is a Node)
    • createBoxShape

      public static CollisionShape createBoxShape(Spatial spatial)
      Create a box shape for the given Spatial.
      Parameters:
      spatial - the spatial on which to base the shape (not null)
      Returns:
      a BoxCollisionShape (if spatial is a Geometry) or a CompoundCollisionShape with BoxCollisionShapes as children (if spatial is a Node)
    • shiftCompoundShapeContents

      public static void shiftCompoundShapeContents(CompoundCollisionShape compoundShape, Vector3f vector)
      This method moves each child shape of a compound shape by the given vector
      Parameters:
      compoundShape - the shape to modify (not null)
      vector - the offset vector (not null, unaffected)