Package com.jme3.bullet.util
Class CollisionShapeFactory
java.lang.Object
com.jme3.bullet.util.CollisionShapeFactory
A utility class for generating collision shapes from Spatials.
This class is shared between JBullet and Native Bullet.
-
Method Summary
Modifier and TypeMethodDescriptionstatic CollisionShape
createBoxShape
(Spatial spatial) Create a box shape for the given Spatial.static CollisionShape
createDynamicMeshShape
(Spatial spatial) Create a hull shape for the given Spatial.static CollisionShape
createMeshShape
(Spatial spatial) Create a mesh shape for the given Spatial.static void
shiftCompoundShapeContents
(CompoundCollisionShape compoundShape, Vector3f vector) This method moves each child shape of a compound shape by the given vector
-
Method Details
-
createMeshShape
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
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
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)
-