com.bulletphysics.collision.shapes
Class CompoundShape

java.lang.Object
  extended by com.bulletphysics.collision.shapes.CollisionShape
      extended by com.bulletphysics.collision.shapes.CompoundShape

public class CompoundShape
extends CollisionShape

CompoundShape allows to store multiple other CollisionShapes. This allows for moving concave collision objects. This is more general than the BvhTriangleMeshShape.


Constructor Summary
CompoundShape()
           
 
Method Summary
 void addChildShape(Transform localTransform, CollisionShape shape)
           
 void calculateLocalInertia(float mass, Vector3f inertia)
           
 void calculatePrincipalAxisTransform(float[] masses, Transform principal, Vector3f inertia)
          Computes the exact moment of inertia and the transform from the coordinate system defined by the principal axes of the moment of inertia and the center of mass to the current coordinate system.
 void getAabb(Transform trans, Vector3f aabbMin, Vector3f aabbMax)
          getAabb's default implementation is brute force, expected derived classes to implement a fast dedicated version.
 OptimizedBvh getAabbTree()
           
 ObjectArrayList<CompoundShapeChild> getChildList()
           
 CollisionShape getChildShape(int index)
           
 Transform getChildTransform(int index, Transform out)
           
 Vector3f getLocalScaling(Vector3f out)
           
 float getMargin()
           
 String getName()
           
 int getNumChildShapes()
           
 BroadphaseNativeType getShapeType()
           
 void recalculateLocalAabb()
          Re-calculate the local Aabb.
 void removeChildShape(CollisionShape shape)
          Remove all children shapes that contain the specified shape.
 void setLocalScaling(Vector3f scaling)
           
 void setMargin(float margin)
           
 
Methods inherited from class com.bulletphysics.collision.shapes.CollisionShape
calculateTemporalAabb, getAngularMotionDisc, getBoundingSphere, getUserPointer, isCompound, isConcave, isConvex, isInfinite, isPolyhedral, setUserPointer
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompoundShape

public CompoundShape()
Method Detail

addChildShape

public void addChildShape(Transform localTransform,
                          CollisionShape shape)

removeChildShape

public void removeChildShape(CollisionShape shape)
Remove all children shapes that contain the specified shape.


getNumChildShapes

public int getNumChildShapes()

getChildShape

public CollisionShape getChildShape(int index)

getChildTransform

public Transform getChildTransform(int index,
                                   Transform out)

getChildList

public ObjectArrayList<CompoundShapeChild> getChildList()

getAabb

public void getAabb(Transform trans,
                    Vector3f aabbMin,
                    Vector3f aabbMax)
getAabb's default implementation is brute force, expected derived classes to implement a fast dedicated version.

Specified by:
getAabb in class CollisionShape

recalculateLocalAabb

public void recalculateLocalAabb()
Re-calculate the local Aabb. Is called at the end of removeChildShapes. Use this yourself if you modify the children or their transforms.


setLocalScaling

public void setLocalScaling(Vector3f scaling)
Specified by:
setLocalScaling in class CollisionShape

getLocalScaling

public Vector3f getLocalScaling(Vector3f out)
Specified by:
getLocalScaling in class CollisionShape

calculateLocalInertia

public void calculateLocalInertia(float mass,
                                  Vector3f inertia)
Specified by:
calculateLocalInertia in class CollisionShape

getShapeType

public BroadphaseNativeType getShapeType()
Specified by:
getShapeType in class CollisionShape

setMargin

public void setMargin(float margin)
Specified by:
setMargin in class CollisionShape

getMargin

public float getMargin()
Specified by:
getMargin in class CollisionShape

getName

public String getName()
Specified by:
getName in class CollisionShape

getAabbTree

public OptimizedBvh getAabbTree()

calculatePrincipalAxisTransform

public void calculatePrincipalAxisTransform(float[] masses,
                                            Transform principal,
                                            Vector3f inertia)
Computes the exact moment of inertia and the transform from the coordinate system defined by the principal axes of the moment of inertia and the center of mass to the current coordinate system. "masses" points to an array of masses of the children. The resulting transform "principal" has to be applied inversely to all children transforms in order for the local coordinate system of the compound shape to be centered at the center of mass and to coincide with the principal axes. This also necessitates a correction of the world transform of the collision object by the principal transform.