Class PhysicsCollisionObject

java.lang.Object
com.jme3.bullet.collision.PhysicsCollisionObject
All Implemented Interfaces:
Savable
Direct Known Subclasses:
PhysicsCharacter, PhysicsGhostObject, PhysicsRigidBody

public abstract class PhysicsCollisionObject extends Object implements Savable
Base class for collision objects (PhysicsRigidBody, PhysicsGhostObject)
  • Field Details

  • Constructor Details

    • PhysicsCollisionObject

      public PhysicsCollisionObject()
  • Method Details

    • setCollisionShape

      public void setCollisionShape(CollisionShape collisionShape)
      Sets a CollisionShape to this physics object, note that the object should not be in the physics space when adding a new collision shape as it is rebuilt on the physics side.
      Parameters:
      collisionShape - the CollisionShape to set
    • getCollisionShape

      public CollisionShape getCollisionShape()
      Returns:
      the CollisionShape of this PhysicsNode, to be able to reuse it with other physics nodes (increases performance)
    • getCollisionGroup

      public int getCollisionGroup()
      Returns the collision group for this collision shape
      Returns:
      a bitmask with 1 bit set
    • setCollisionGroup

      public void setCollisionGroup(int collisionGroup)
      Sets the collision group number for this physics object.
      The groups are integer bit masks and some pre-made variables are available in CollisionObject. All physics objects are by default in COLLISION_GROUP_01.
      Two object will collide when one of the parties has the collisionGroup of the other in its collideWithGroups set.
      Parameters:
      collisionGroup - the collisionGroup to set
    • addCollideWithGroup

      public void addCollideWithGroup(int collisionGroup)
      Add a group that this object will collide with.
      Two object will collide when one of the parties has the collisionGroup of the other in its collideWithGroups set.
      Parameters:
      collisionGroup - the groups to add, ORed together (bitmask)
    • removeCollideWithGroup

      public void removeCollideWithGroup(int collisionGroup)
      Remove a group from the list this object collides with.
      Parameters:
      collisionGroup - the groups to remove, ORed together (bitmask)
    • setCollideWithGroups

      public void setCollideWithGroups(int collisionGroups)
      Directly set the bitmask for collision groups that this object collides with.
      Parameters:
      collisionGroups - the desired groups, ORed together (bitmask, default=COLLISION_GROUP_01)
    • getCollideWithGroups

      public int getCollideWithGroups()
      Gets the bitmask of collision groups that this object collides with.
      Returns:
      a bitmask
    • getUserObject

      public Object getUserObject()
      Returns:
      the userObject
    • setUserObject

      public void setUserObject(Object userObject)
      Parameters:
      userObject - the userObject to set
    • write

      public void write(JmeExporter e) throws IOException
      Specified by:
      write in interface Savable
      Throws:
      IOException
    • read

      public void read(JmeImporter importer) throws IOException
      Specified by:
      read in interface Savable
      Throws:
      IOException