Help to transform TestadvancedVehicle from SimplePhysicsTest to DebugGameState

I have problem when i try to transform my TestadvancedVehicle from SimplePhysicsTest to DebugGameState

The problem i think that is chasecamera,infact for example this camera work perfectly:

input = new FirstPersonHandler(DisplaySystem.getDisplaySystem().getRenderer().getCamera(), 10, 1);



this is the code  with a a chasecamera that don't work!

what is the problem?



package jm.vehicle;
import java.util.HashMap;



import com.jme.bounding.BoundingBox;
import com.jme.image.Texture;
import com.jme.input.ChaseCamera;
import com.jme.input.FirstPersonHandler;
import com.jme.input.InputHandler;
import com.jme.input.KeyBindingManager;
import com.jme.input.KeyInput;
import com.jme.input.action.InputAction;
import com.jme.input.action.InputActionEvent;
import com.jme.input.action.InputActionInterface;
import com.jme.input.thirdperson.ThirdPersonMouseLook;
import com.jme.math.FastMath;
import com.jme.math.Quaternion;
import com.jme.math.Vector3f;
import com.jme.scene.Spatial;
import com.jme.scene.shape.Box;
import com.jme.scene.shape.Quad;
import com.jme.scene.state.TextureState;
import com.jme.system.DisplaySystem;
import com.jme.util.TextureManager;
import com.jmex.game.state.CameraGameState;
import com.jmex.game.state.DebugGameState;
import com.jmex.game.state.GameStateManager;
import com.jmex.physics.DynamicPhysicsNode;
import com.jmex.physics.StaticPhysicsNode;
import com.jmex.physics.util.states.PhysicsGameState;

/**
 * @author Per Thulin
 */
public class IngameState extends DebugGameState {
    final PhysicsGameState physicsGameState = new PhysicsGameState("Physics tutorial");
   private InputHandler input;
   public Car car;
   ChaseCamera chaser;
   public IngameState(String name) {
      super();
      
      // Move the camera a bit.
      DisplaySystem.getDisplaySystem().getRenderer().getCamera().setLocation(new Vector3f(0,10,0));
      DisplaySystem.getDisplaySystem().getRenderer().getCamera().update();
      
       initInput();
      
       // Create a Quad.
       Quad q = new Quad("Quad", 200, 200);
       q.setModelBound(new BoundingBox());
       q.updateModelBound();
       q.setLocalRotation(new Quaternion(new float[] {90*FastMath.DEG_TO_RAD,0,0}));
      
       // Apply a texture to it.
       TextureState ts =
          DisplaySystem.getDisplaySystem().getRenderer().createTextureState();
       Texture texture =
          TextureManager.loadTexture(
                IngameState.class.getClassLoader().getResource(
                "jmetest/data/texture/dirt.jpg"),
                Texture.MM_LINEAR_LINEAR,
                Texture.FM_LINEAR);
       texture.setWrap(Texture.WM_WRAP_S_WRAP_T);
       ts.setTexture(texture);
       ts.setEnabled(true);      
       q.setRenderState(ts);
        car = new Car( physicsGameState.getPhysicsSpace() );
           car.setPosition(0, 0, 00);
           this.getRootNode().attachChild( car );
           buildChaseCamera(car.getChild(0));
       // Add it to the scene.
   //    this.getRootNode().attachChild(q);
      
       // Remember to update the rootNode before you get going.
       this.getRootNode().updateGeometricState(0, true);
       this.getRootNode().updateRenderState();
      
   //    StaticPhysicsNode staticNode = getPhysicsSpace().createStaticNode();


      // Now let jME know about the game states we've created.
   //   GameStateManager.getInstance().attachChild(debugGameState);
   //   debugGameState.setActive(true);

      GameStateManager.getInstance().attachChild(physicsGameState);
      physicsGameState.setActive(true);

      // first we will create the floor
      // as the floor can't move we create a _static_ physics node
      StaticPhysicsNode staticNode = physicsGameState.getPhysicsSpace().createStaticNode();

      // attach the node to the root node to have it updated each frameit
      this.getRootNode().attachChild(staticNode);

      // now we do not create a collision geometry but a visual box
      final Box visualFloorBox = new Box("floor", new Vector3f(), 80, 10f, 50);
      // note: we have used the constructor (name, center, xExtent, yExtent, zExtent)
      // thus our box is centered at (0,0,0) and has size (10, 0.5f, 10)
   
      // we have to attach it to our node
      staticNode.attachChild(visualFloorBox);
      staticNode.getLocalTranslation().set(0, -70f, 0);
      // now we let jME Physics 2 generate the collision geometry for our box
      staticNode.generatePhysicsGeometry();

   
      DynamicPhysicsNode dynamicNode = physicsGameState.getPhysicsSpace().createDynamicNode();
      this.getRootNode().attachChild(dynamicNode);

      // again we create a visual box
      final Box visualFallingBox = new Box("falling box", new Vector3f(), 10f, 10f, 10f);
      // note: again we have used the constructor (name, center, xExtent, yExtent, zExtent)
      // thus our box is centered at (0,0,0) and has size (1, 1, 1)
      // the center is really important here because we want the center of the box to lie in the
      // center
      // of the dynamic physics node - which is the center of gravity!

      // attach it to the dynamic node
      dynamicNode.attachChild(visualFallingBox);

      // and generate collision geometries again
      dynamicNode.generatePhysicsGeometry();

      // we have to move our dynamic node upwards such that is does not start in but above the
      // floor
      dynamicNode.getLocalTranslation().set(0, 70, 0);
      // note: we do not move the collision geometry but the physics node!

      // now we have visuals for the physics and don't necessarily need to activate the physics
      // debugger
      // though you can do it (V key) to see physics in the app

      // Once all this is set up, we need to update the render state on the root node.
      this.getRootNode().updateRenderState();
   }
   


   /**
    * Gets called every time the game state manager switches to this game state.
    * Sets the window title.
    */
   public void onActivate() {
      DisplaySystem.getDisplaySystem().
         setTitle("Test Game State System - Ingame State");
   //   super.onActivate();
   }
   
   /**
    * Gets called from super constructor. Sets up the input handler that let
    * us walk around using the w,s,a,d keys and mouse.
    */
   private void initInput() {
   //  input = new FirstPersonHandler(DisplaySystem.getDisplaySystem().getRenderer().getCamera(), 10, 1);
      
       // Bind the exit action to the escape key.
       KeyBindingManager.getKeyBindingManager().set(
           "exit",
           KeyInput.KEY_ESCAPE);
      
      
  //      input.removeFromAttachedHandlers( cameraInputHandler );


//           cameraInputHandler = new ChaseCamera( cam, car.getChassis().getChild( 0 )  );
       

        
         
        //   input.addToAttachedHandlers( cameraInputHandler );

           // Attaching the custom input actions (and its respective keys) to the carInput handler.
           input.addAction( new AccelAction( car, 1 ),
                   InputHandler.DEVICE_KEYBOARD, KeyInput.KEY_UP, InputHandler.AXIS_NONE, false );
           input.addAction( new AccelAction( car, -1 ),
                   InputHandler.DEVICE_KEYBOARD, KeyInput.KEY_DOWN, InputHandler.AXIS_NONE, false );
           input.addAction( new SteerAction( car, -1 ),
                   InputHandler.DEVICE_KEYBOARD, KeyInput.KEY_LEFT, InputHandler.AXIS_NONE, false );
           input.addAction( new SteerAction( car, 1 ),
                   InputHandler.DEVICE_KEYBOARD, KeyInput.KEY_RIGHT, InputHandler.AXIS_NONE, false );

        //   resetAction = new ResetAction();
          // input.addAction( resetAction, InputHandler.DEVICE_KEYBOARD, KeyInput.KEY_S, InputHandler.AXIS_NONE, false );
   }
   
   public void update(float tpf) {
      physicsGameState.getPhysicsSpace().update(tpf);
      super.update(tpf);
      input.update(tpf);
      //car.accelerate(1);
      
      if (input != null ) {
         
            this.getRootNode().updateRenderState();
         
         }
      if (KeyBindingManager.getKeyBindingManager().
            isValidCommand("exit", false)) {
         // Here we switch to the menu state which is already loaded
         GameStateManager.getInstance().activateChildNamed("menu");
         // And remove this state, because we don't want to keep it in memory.
         GameStateManager.getInstance().detachChild("ingame");
         
         
         this.getRootNode().updateGeometricState(tpf, true);
         
         

         
         
      }
   }
   public void buildChaseCamera(Spatial s) {

      HashMap<String, Object> props = new HashMap<String, Object>();
      //props.put(ThirdPersonMouseLook.PROP_MAXROLLOUT, "5");
      //props.put(ThirdPersonMouseLook.PROP_MINROLLOUT, "4");
      //props.put(ThirdPersonMouseLook.PROP_MOUSEBUTTON_FOR_LOOKING, "1");
      props.put(ThirdPersonMouseLook.PROP_MAXASCENT, ""+ 20 * FastMath.DEG_TO_RAD);
      props.put(ThirdPersonMouseLook.PROP_MINASCENT, ""+ 15 * FastMath.DEG_TO_RAD);
      props.put(ChaseCamera.PROP_INITIALSPHERECOORDS, new Vector3f(30, 25 * FastMath.DEG_TO_RAD, 30 *FastMath.DEG_TO_RAD));
      //props.put(ChaseCamera.PROP_DAMPINGK, "1");
      //props.put(ChaseCamera.PROP_SPRINGK, "1");
      //
      
      chaser = new ChaseCamera(DisplaySystem.getDisplaySystem().getRenderer().getCamera(), s, props);
      //chaser.setMaintainAzimuth(true);
      chaser.setMaxDistance(5);
      chaser.setMinDistance(3);
      //chaser.setActionSpeed(100);
      chaser.setStayBehindTarget(true);
      //chaser.setMaintainAzimuth(true);
      //chaser.getMouseLook().setEnabled(true);

      //chaser.setStayBehindTarget(true);
      
            
   }
   //public void update(float f){}
    private class AccelAction implements InputActionInterface {
        Car car;

        int direction;

        public AccelAction( final Car car, final int direction ) {
            this.car = car;
            this.direction = direction;
        }

        public void performAction( final InputActionEvent e ) {
            // If the key has just been pressed, lets accelerate in the desired direction
            if ( e.getTriggerPressed() ) {
                car.accelerate( direction );
            }
            // Otherwise, lets release the wheels.
            else {
                car.releaseAccel();
            }
        }
    }

    private class ResetAction extends InputAction {
        public void performAction( InputActionEvent evt ) {
            car.setPosition( 0, 50, 0 );
        }
    }
   
    private class SteerAction implements InputActionInterface {
        Car car;

        int direction;

        public SteerAction( Car car, int direction ) {
            this.car = car;
            this.direction = direction;
        }

        public void performAction( final InputActionEvent e ) {
            // If the key is down (left or right) lets steer
            if ( e.getTriggerPressed() ) {
                car.steer( direction );
            }
            // If it's up, lets unsteer
            else {
                car.unsteer();
            }
        }

    }