@Override
 public void initialize(AppStateManager stateManager, Application app) {
   super.initialize(stateManager, app);
   this.assetManager = app.getAssetManager();
   this.audioRenderer = app.getAudioRenderer();
   this.worldManager = app.getStateManager().getState(WorldManager.class);
 }
Ejemplo n.º 2
0
  @SuppressWarnings("unchecked")
  @Override
  public void initialize(AppStateManager stateManager, Application app) {
    super.initialize(stateManager, app);

    bulletAppState = new BulletAppState();
    app.getStateManager().attach(bulletAppState);

    StaticWorldHelper.addStaticWorld(
        App.rally.getRootNode(), getPhysicsSpace(), world, App.rally.sky.ifShadow);

    cb = new CarBuilder();
    cb.addCar(getPhysicsSpace(), 0, car, world.start, Matrix3f.IDENTITY, false);

    camNode = new MyCamera("Cam Node 2", App.rally.getCamera(), null);
    camNode.setLocalTranslation(0, 3, 7);
    camNode.lookAt(new Vector3f(0, 1.2f, 0), new Vector3f(0, 1, 0));

    Container myWindow = new Container();
    App.rally.getGuiNode().attachChild(myWindow);
    myWindow.setLocalTranslation(300, 300, 0);

    // Add some elements to it
    myWindow.addChild(new Label("Main Menu"));
    Button startFast = myWindow.addChild(new Button("Start Fast"));
    startFast.addClickCommands(
        new Command<Button>() {
          @Override
          public void execute(Button source) {
            startFast();
            App.rally.getGuiNode().detachChild(myWindow);
          }
        });
    Button start = myWindow.addChild(new Button("Start"));
    start.addClickCommands(
        new Command<Button>() {
          @Override
          public void execute(Button source) {
            startBasic();
            App.rally.getGuiNode().detachChild(myWindow);
          }
        });
  }
  @Override
  public void runCommand(Application app) {
    DevicesAppState devicesAppState = app.getStateManager().getState(DevicesAppState.class);

    Spatial device = SpatialUtils.getSpatialById(((SimpleApplication) app).getRootNode(), sensorID);
    Node sensor;
    System.out.println("DEVICE ===== " + device);
    if (device != null && device instanceof Node) {
      sensor = (Node) device;
    } else {
      sensor = SmartPhoneFactory.createAccelGeometry(sensorID, dimensions);
    }
    sensor.setName(sensorID);

    SmartPhoneFactory.enableAccelerometerFacility(sensor);

    if (attachCoordinateAxes) {
      Debug.attachCoordinateAxes(Vector3f.ZERO, 0.5f, SmartPhoneFactory.assetManager, sensor);
    }
    devicesAppState.addDevice(sensorID, sensor);
    setState(State.Success);
  }