Ejemplo n.º 1
0
 private void addGhostObject(PhysicsGhostObject node) {
   if (physicsGhostObjects.containsKey(node.getObjectId())) {
     logger.log(
         Level.WARNING, "GhostObject {0} already exists in PhysicsSpace, cannot add.", node);
     return;
   }
   physicsGhostObjects.put(node.getObjectId(), node);
   logger.log(
       Level.FINE,
       "Adding ghost object {0} to physics space.",
       Long.toHexString(node.getObjectId()));
   addCollisionObject(physicsSpaceId, node.getObjectId());
 }
Ejemplo n.º 2
0
 /**
  * adds an object to the physics space
  *
  * @param obj the PhysicsControl or Spatial with PhysicsControl to add
  */
 public void add(Object obj) {
   if (obj instanceof PhysicsControl) {
     ((PhysicsControl) obj).setPhysicsSpace(this);
   } else if (obj instanceof Spatial) {
     Spatial node = (Spatial) obj;
     for (int i = 0; i < node.getNumControls(); i++) {
       if (node.getControl(i) instanceof PhysicsControl) {
         add(((PhysicsControl) node.getControl(i)));
       }
     }
   } else if (obj instanceof PhysicsCollisionObject) {
     addCollisionObject((PhysicsCollisionObject) obj);
   } else if (obj instanceof PhysicsJoint) {
     addJoint((PhysicsJoint) obj);
   } else {
     throw (new UnsupportedOperationException(
         "Cannot add this kind of object to the physics space."));
   }
 }