public void registerAllAndroidDevicesInScenario() { List<Spatial> devices = SpatialUtils.getSpatialsByRole(app.getRootNode(), "AndroidDevice"); for (Spatial device : devices) { String id = device.getUserData("ID"); if (id != null) { addDevice(id, (Node) device); } } }
@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); }