public Void call() throws Exception { Spatial spatial = serverApp.getAssetManager().loadModel(finalModel); serverApp.getRootNode().attachChild(spatial); return null; } });
@Override public void cleanup() { super.cleanup(); //detach everything when we are detached application.getRootNode().detachChild(rootNode); application.getStateManager().detach(physicsState); cleanupData(); }
@Override public void initialize(AppStateManager stateManager, Application app) { super.initialize(stateManager, app); //only generate data and attach node when we are actually attached (or picking) initData(); application = (SimpleApplication) app; application.getRootNode().attachChild(getRootNode()); application.getStateManager().attach(physicsState); }
@Override @Deprecated public Node getRootNode() { // should be using zUpNode now so that there is no axis flip flopping going on. return super.getRootNode(); }
@Override @Deprecated public Node getRootNode() { // should be using zUpNode now so that there is no axis flip flopping going on. return super.getRootNode(); }
/** jME3 AppState methods */ @Override public void initialize(AppStateManager stateManager, Application app) { super.initialize(stateManager, app); this.app = (SimpleApplication) app; rootNode = this.app.getRootNode(); System.out.println("jME3 AppState methods"); }
/** Reads the colors of first column of an image and creates a gradient texture.*/ public static void test(SimpleApplication scene) { BufferedImage image = new BufferedImage(512, 512, BufferedImage.TYPE_INT_ARGB); Graphics2D g2d = image.createGraphics(); ImageUtilities.verticalGradient(image, g2d, Color.RED, Color.YELLOW, Color.GREEN, Color.BLUE); g2d.setFont(new Font("SansSerif", Font.PLAIN, 70)); g2d.setColor(Color.BLACK); g2d.drawString("Hello World", 70, 70); image = ImageUtilities.rotateImage(image, FastMath.HALF_PI); scene.getRootNode().attachChild(Utilities.createBillboard(Utilities.getUnshadedMaterial(ImageUtilities.createTexture(image,g2d), null, BlendMode.Off, scene.getAssetManager()), 5f)); }
/** Reads the colors of first column of an image and creates a gradient texture.*/ public static void test(SimpleApplication scene) { BufferedImage image = new BufferedImage(512, 512, BufferedImage.TYPE_INT_ARGB); Graphics2D g2d = image.createGraphics(); ImageUtilities.verticalGradient(image, g2d, Color.RED, Color.YELLOW, Color.GREEN, Color.BLUE); g2d.setFont(new Font("SansSerif", Font.PLAIN, 70)); g2d.setColor(Color.BLACK); g2d.drawString("Hello World", 70, 70); image = ImageUtilities.rotateImage(image, FastMath.HALF_PI); scene.getRootNode().attachChild(Utilities.createBillboard(Utilities.getUnshadedMaterial(ImageUtilities.createTexture(image,g2d), null, BlendMode.Off, scene.getAssetManager()), 5f)); }
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 initialize(AppStateManager stateManager, Application application) { System.out.println("Inititalize " + getClass().getSimpleName()); super.initialize(stateManager, application); this.app = (SimpleApplication) application; this.assetManager = application.getAssetManager(); this.rootNode = app.getRootNode(); this.audioRenderer = app.getAudioRenderer(); this.listener = app.getListener(); PHATUtils.checkAndCreatePath("./assets/Sounds/"); assetManager.registerLocator("assets", FileLocator.class); AudioFactory.init(audioRenderer, assetManager, rootNode); }
@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(); this.rootNode = app.getRootNode(); bodiesAppState = app.getStateManager().getState(BodiesAppState.class); houseAppState = app.getStateManager().getState(HouseAppState.class); devicesAppState = app.getStateManager().getState(DevicesAppState.class); serverAppState = app.getStateManager().getState(ServerAppState.class); for (Agent a : availableAgents.values()) { a.setAgentsAppState(this); } }
void createBodyPresenceSensor(String id, Vector3f pos, Vector3f dir) { Node devicePS1 = new Node(); devicePS1.setUserData("ROLE", "PresenceSensor"); devicePS1.setUserData("ID", id); devicePS1.move(pos); devicePS1.rotate(new Quaternion().fromAngles(dir.x, dir.y, dir.z)); app.getRootNode().attachChild(devicePS1); }
@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); }
DevicesAppState devicesAppState = app.getStateManager().getState(DevicesAppState.class); Spatial device = SpatialUtils.getSpatialById(((SimpleApplication)app).getRootNode(), smartphoneId); Node smartphone; System.out.println("DEVICE ===== "+device);
/** Reads the colors of first column of an image and creates a gradient texture.*/ public static void testMain(SimpleApplication scene) { String shape = "shapes/public domain/tribal_star.png"; float height = 0.05f; //Apply image effects. BufferedImage shapeImage = ImageUtilities.loadImage(shape, scene.getAssetManager()); shapeImage = ImageUtilities.symmetrifyX(shapeImage, true, false); //Get shape. com.jme3.scene.Geometry g = createShape(shapeImage, height); g.setMaterial(Utilities.getUnshadedMaterial(scene.getAssetManager().loadTexture("Textures/CobbleStone.png"), null, BlendMode.Off, scene.getAssetManager())); g.scale(10f); g.rotate(FastMath.HALF_PI*3, 0, 0); scene.getRootNode().attachChild(g); scene.getViewPort().setBackgroundColor(new ColorRGBA(0.7f, 0.8f, 1f, 1f)); }
/** Reads the colors of first column of an image and creates a gradient texture.*/ public static void testMain(SimpleApplication scene) { String shape = "shapes/public domain/tribal_star.png"; float height = 0.05f; //Apply image effects. BufferedImage shapeImage = ImageUtilities.loadImage(shape, scene.getAssetManager()); shapeImage = ImageUtilities.symmetrifyX(shapeImage, true, false); //Get shape. com.jme3.scene.Geometry g = createShape(shapeImage, height); g.setMaterial(Utilities.getUnshadedMaterial(scene.getAssetManager().loadTexture("Textures/CobbleStone.png"), null, BlendMode.Off, scene.getAssetManager())); g.scale(10f); g.rotate(FastMath.HALF_PI*3, 0, 0); scene.getRootNode().attachChild(g); scene.getViewPort().setBackgroundColor(new ColorRGBA(0.7f, 0.8f, 1f, 1f)); }
@Override public void runCommand(Application app) { DevicesAppState devicesAppState = app.getStateManager().getState(DevicesAppState.class); WorldAppState worldAppState = app.getStateManager().getState(WorldAppState.class); Spatial object = SpatialUtils.getSpatialById(((SimpleApplication) app).getRootNode(), objectId); if (object != null) { Node sensorNode = new Node(doorSensorId); object.getParent().attachChild(sensorNode); sensorNode.setName(doorSensorId); PHATDoorSensor doorSensor = new PHATDoorSensor( doorSensorId, worldAppState.getCalendar()); sensorNode.addControl(doorSensor); devicesAppState.addDevice(doorSensorId, sensorNode); setState(State.Success); return; } setState(State.Fail); }
WorldAppState worldAppState = app.getStateManager().getState(WorldAppState.class); Spatial device = SpatialUtils.getSpatialById(((SimpleApplication)app).getRootNode(), presenceSensorId); Node psNode; if(device != null && device instanceof Node) {
@Override public void init(SimpleApplication app) { SpatialFactory.init(app.getAssetManager(), app.getRootNode());
@Override public void init(SimpleApplication app) { SpatialFactory.init(app.getAssetManager(), app.getRootNode());