@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);
  }
Пример #2
0
  @Override
  public void initialize(AppStateManager stateManager, Application application) {
    System.out.println("Inititalize " + getClass().getSimpleName());
    super.initialize(stateManager, application);
    this.app = (SimpleApplication) application;
    this.assetManager = application.getAssetManager();

    worldAppState = app.getStateManager().getState(WorldAppState.class);
    houseAppState = app.getStateManager().getState(HouseAppState.class);
    bulletAppState = app.getStateManager().getState(BulletAppState.class);

    SmartPhoneFactory.init(
        bulletAppState,
        assetManager,
        app.getRenderManager(),
        app.getCamera(),
        app.getAudioRenderer());
  }