/** * Returns the first state that is an instance of subclass of the specified class. * @param <T> * @param stateClass * @return First attached state that is an instance of stateClass */ public <T extends AppState> T getState(Class<T> stateClass){ return getState(stateClass, false); }
public void onAction(String name, boolean value, float tpf) { if (!value) { return; } if (name.equals(INPUT_MAPPING_EXIT)) { stop(); }else if (name.equals(INPUT_MAPPING_HIDE_STATS)){ if (stateManager.getState(StatsAppState.class) != null) { stateManager.getState(StatsAppState.class).toggleStats(); } } } }
public final <T extends AppState> T getState( Class<T> type, boolean failOnMiss ) { return getStateManager().getState( type, failOnMiss ); }
@Override public void simpleInitApp() { stateManager.detach(stateManager.getState(FlyCamAppState.class)); stateManager.detach(stateManager.getState(ResetStatsState.class)); stateManager.detach(stateManager.getState(DebugKeysAppState.class)); stateManager.detach(stateManager.getState(StatsAppState.class)); final Node jaime = LoadModel(); setupLights(); setupCamera(); setupFloor(); setupCinematic(jaime); setupInput(); }
@Override public void simpleUpdate(float tpf) { frame++; if (frame == 2) { final LightProbe probe = LightProbeFactory.makeProbe(stateManager.getState(EnvironmentCamera.class), rootNode, EnvMapUtils.GenerationType.Fast, new JobProgressAdapter<LightProbe>() { @Override public void done(LightProbe result) { System.err.println("Done rendering env maps"); tex = EnvMapUtils.getCubeMapCrossDebugViewWithMipMaps(result.getPrefilteredEnvMap(), assetManager); rootNode.getChild(0).setCullHint(Spatial.CullHint.Dynamic); } }); ((SphereProbeArea) probe.getArea()).setRadius(100); rootNode.addLight(probe); } } }
if (stateManager.getState(FlyCamAppState.class) != null) { flyCam = new FlyByCamera(cam); flyCam.setMoveSpeed(1f); // odd to set this here but it did it before stateManager.getState(FlyCamAppState.class).setCamera( flyCam ); if (stateManager.getState(StatsAppState.class) != null) { inputManager.addMapping(INPUT_MAPPING_HIDE_STATS, new KeyTrigger(KeyInput.KEY_F5)); inputManager.addListener(actionListener, INPUT_MAPPING_HIDE_STATS); if (stateManager.getState(StatsAppState.class) != null) { stateManager.getState(StatsAppState.class).setFont(guiFont); fpsText = stateManager.getState(StatsAppState.class).getFpsText();
@Override public void onAction(String name, boolean isPressed, float tpf) { if (name.equals("tex") && isPressed) { if (tex == null) { tex = EnvMapUtils.getCubeMapCrossDebugViewWithMipMaps(stateManager.getState(EnvironmentCamera.class).debugEnv, assetManager); } if (tex.getParent() == null) { guiNode.attachChild(tex); } else { tex.removeFromParent(); } } if (name.equals("switch") && isPressed) { switchMat(rootNode.getChild("Scene")); } if (name.equals("ref") && isPressed) { if (ref.getParent() == null) { guiNode.attachChild(ref); } else { ref.removeFromParent(); } } } }, "tex", "switch", "ref");
protected void reloadScene(Geometry g, Geometry boxGeo, Node cubeNodes) { MaterialDebugAppState debug = stateManager.getState(MaterialDebugAppState.class); Material m = debug.reloadMaterial(g.getMaterial()); if (m != null) { g.setMaterial(m); } m = debug.reloadMaterial(boxGeo.getMaterial()); if (m != null) { cubeNodes.setMaterial(m); } }
public WorldOfInception() { //base level vector position hash == seed super(new InceptionLevel(null, Vector3f.ZERO)); currentLevel = super.getStateManager().getState(InceptionLevel.class); currentLevel.takeOverParent(); currentLevel.getRootNode().setLocalScale(Vector3f.UNIT_XYZ); currentLevel.getRootNode().setLocalTranslation(Vector3f.ZERO); }
@Override public void simpleInitApp() { stateManager.getState(FlyCamAppState.class).getCamera().setMoveSpeed(10); mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mat.setColor("Color", ColorRGBA.Blue); // Create a deep, mostly static scene Spatial oct = createOctSplit("root", 500, 5); rootNode.attachChild(oct); // Position to see most of it cam.setLocation(new Vector3f(400.8009f, 370.16455f, -408.17984f)); cam.setRotation(new Quaternion(0.24906662f, -0.3756747f, 0.105560325f, 0.88639235f)); System.out.println("Total nodes:" + totalNodes + " Total Geometry:" + totalGeometry + " Total controls:" + totalControls ); }
@Override public void simpleUpdate(float tpf) { frame++; if (frame == 2) { modelNode.removeFromParent(); final LightProbe probe = LightProbeFactory.makeProbe(stateManager.getState(EnvironmentCamera.class), rootNode, new JobProgressAdapter<LightProbe>() { @Override public void done(LightProbe result) { System.err.println("Done rendering env maps"); tex = EnvMapUtils.getCubeMapCrossDebugViewWithMipMaps(result.getPrefilteredEnvMap(), assetManager); } }); ((SphereProbeArea) probe.getArea()).setRadius(100); rootNode.addLight(probe); //getStateManager().getState(EnvironmentManager.class).addEnvProbe(probe); } if (frame > 10 && modelNode.getParent() == null) { rootNode.attachChild(modelNode); } }
stateManager.detach(stateManager.getState(FlyCamAppState.class));
public boolean isHosting() { LobbyState lobbyState = stateManager.getState(LobbyState.class); if (lobbyState != null) { return lobbyState.isHosting(); } return false; }
protected List<Door> getAvailableDoors() { GameState gameState = stateManager.getState(GameState.class); List<Door> doors = gameState.getLevelData().getDoors(); return doors; }
@Override public void runCommand(Application app) { Logger.getLogger(getClass().getName()).info("Video recording stopped"); VideoRenderAppState videoAppState = app.getStateManager() .getState(VideoRenderAppState.class); if (videoAppState != null) { app.getStateManager().detach(videoAppState); } setState(State.Success); }