예제 #1
0
  public void ghostNoChildren(boolean ghost) {
    int flags = body.getCollisionFlags();
    int noContact = CollisionFlags.NO_CONTACT_RESPONSE;

    if (ghost) flags |= noContact;
    else flags &= ~noContact;

    body.setCollisionFlags(flags);
  }
예제 #2
0
 public void dynamics(boolean restore) {
   if (currBodyType.equals("DYNAMIC") || currBodyType.equals("RIGID_BODY")) {
     if (restore) {
       bodyType(currBodyType);
     } else { // suspend
       body.setCollisionFlags(body.getCollisionFlags() | CollisionFlags.KINEMATIC_OBJECT);
     }
   }
 }
예제 #3
0
 public void bodyType(String s) {
   int flags = body.getCollisionFlags();
   if (body.isInWorld()) scene.world.removeRigidBody(body);
   if (s.equals("NO_COLLISION")) {
     for (GameObject g : touchingObjects) g.activate();
     flags &= ~CollisionFlags.KINEMATIC_OBJECT;
   } else {
     if (s.equals("STATIC")) {
       flags |= CollisionFlags.KINEMATIC_OBJECT;
     } else if (s.equals("SENSOR")) {
       flags |= CollisionFlags.KINEMATIC_OBJECT;
       flags |= CollisionFlags.NO_CONTACT_RESPONSE;
     } else {
       // NO_COLLISION -> DYNAMIC or RIGID_BODY hack
       if (currBodyType.equals("NO_COLLISION")) {
         body.clearForces();
         body.setLinearVelocity(new Vector3f());
       }
       // kinematic initialization hack
       if (mass() == Float.POSITIVE_INFINITY) {
         mass(1); // Blender default
         flags &= ~CollisionFlags.KINEMATIC_OBJECT;
         body.setCollisionFlags(flags);
       }
       flags &= ~CollisionFlags.KINEMATIC_OBJECT;
       if (s.equals("DYNAMIC")) {
         body.setAngularVelocity(new Vector3f());
         body.setAngularFactor(0);
       } else if (s.equals("RIGID_BODY")) {
         body.setAngularFactor(1);
       } else {
         throw new RuntimeException(s + " is no valid bodyType name.");
       }
     }
     scene.world.addRigidBody(body);
     activate();
   }
   body.setCollisionFlags(flags);
   currBodyType = s;
 }
예제 #4
0
 public boolean ghost() {
   int noContact = body.getCollisionFlags() & CollisionFlags.NO_CONTACT_RESPONSE;
   return noContact != 0 ? true : false;
 }