com.jme3.app.state.AppStateManager Java Examples
The following examples show how to use
com.jme3.app.state.AppStateManager.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AdvancedAbstractEditor3DPart.java From jmonkeybuilder with Apache License 2.0 | 6 votes |
@Override @JmeThread public void initialize(@NotNull final AppStateManager stateManager, @NotNull final Application application) { super.initialize(stateManager, application); this.stateManager = stateManager; final Node rootNode = EditorUtil.getGlobalRootNode(); rootNode.attachChild(getStateNode()); final RenderFilterExtension filterExtension = RenderFilterExtension.getInstance(); filterExtension.enableFilters(); final EditorCamera editorCamera = getEditorCamera(); final InputManager inputManager = EditorUtil.getInputManager(); checkAndAddMappings(inputManager); registerActionListener(inputManager); registerAnalogListener(inputManager); if (editorCamera != null) { editorCamera.setEnabled(true); editorCamera.registerInput(inputManager); } }
Example #2
Source File: SceneEditor3DPart.java From jmonkeybuilder with Apache License 2.0 | 6 votes |
@Override @JmeThread public void initialize(@NotNull final AppStateManager stateManager, @NotNull final Application application) { super.initialize(stateManager, application); final SceneNode currentModel = getCurrentModel(); if (currentModel != null) { getModelNode().attachChild(currentModel); } final JmeApplication jmeApplication = JmeApplication.getInstance(); final FXAAFilter fxaaFilter = jmeApplication.getFXAAFilter(); fxaaFilter.setEnabled(false); final ToneMapFilter toneMapFilter = jmeApplication.getToneMapFilter(); toneMapFilter.setEnabled(false); }
Example #3
Source File: DebugKeysAppState.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void initialize(AppStateManager stateManager, Application app) { super.initialize(stateManager, app); this.app = app; this.inputManager = app.getInputManager(); if (app.getInputManager() != null) { inputManager.addMapping(INPUT_MAPPING_CAMERA_POS, new KeyTrigger(KeyInput.KEY_C)); inputManager.addMapping(INPUT_MAPPING_MEMORY, new KeyTrigger(KeyInput.KEY_M)); inputManager.addListener(keyListener, INPUT_MAPPING_CAMERA_POS, INPUT_MAPPING_MEMORY); } }
Example #4
Source File: ViewPortDemoState.java From Lemur with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void stateDetached( AppStateManager stateManager ) { // Here we have a legitimate use for stateDetached(). // (the only one I've found to date) // The issue here is that when this AppState is detached, it // won't actually get onDisable()/cleanup() called until the // start of the next frame. That's potentially enough time for the // ViewPort to be rendered again. If some aspect of the node's // state has changed since then (say because you had focused on // a button but then focused on a different button to close it...) // then you will randomly get the error about "scene not updated for // rendering... blah blah". // So, on stateDetached() we do the safest thing we can and simply // remove the root from the ViewPort. onDisable() will come along // later and remove the ViewPort itself. // Technically we could probably get away with disposing of the ViewPort // here but it's better to limit what we do here. stateDetached() is // called from the thread that detached the state... which may or may // not be the render thread. detachScene() is only updating a list // so we might consider it is the least dangerous of all options. if( vp != null ) { vp.detachScene(vpRoot); } }
Example #5
Source File: WorldOfInception.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void checkActiveChild(Vector3f vector3f) { AppStateManager stateManager = application.getStateManager(); if(vector3f == null){ if(currentActiveChild != null){ logger.log(Level.INFO, "Detach child {0}", currentActiveChild); stateManager.detach(currentActiveChild); currentActiveChild = null; } return; } if (currentActiveChild == null) { currentActiveChild = new InceptionLevel(this, vector3f); stateManager.attach(currentActiveChild); logger.log(Level.INFO, "Attach child {0}", currentActiveChild); } else if (!currentActiveChild.getPositionInParent().equals(vector3f)) { logger.log(Level.INFO, "Switching from child {0}", currentActiveChild); stateManager.detach(currentActiveChild); currentActiveChild = new InceptionLevel(this, vector3f); stateManager.attach(currentActiveChild); logger.log(Level.INFO, "Attach child {0}", currentActiveChild); } }
Example #6
Source File: Cinematic.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
public void initialize(AppStateManager stateManager, Application app) { if (niftyXmlPath != null) { NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay(app.getAssetManager(), app.getInputManager(), app.getAudioRenderer(), app.getGuiViewPort()); nifty = niftyDisplay.getNifty(); nifty.fromXmlWithoutStartScreen(niftyXmlPath); app.getGuiViewPort().addProcessor(niftyDisplay); } initEvent(app, this); for (CinematicEvent cinematicEvent : cinematicEvents) { cinematicEvent.initEvent(app, this); } initialized = true; }
Example #7
Source File: LegacyApplication.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void initStateManager(){ stateManager = new AppStateManager(this); // Always register a ResetStatsState to make sure // that the stats are cleared every frame stateManager.attach(new ResetStatsState()); }
Example #8
Source File: VRAppState.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void initialize(AppStateManager stateManager, Application app) { super.initialize(stateManager, app); this.application = app; this.stateManager = stateManager; // disable annoying warnings about GUI stuff being updated, which is normal behavior // for late GUI placement for VR purposes Logger.getLogger("com.jme3").setLevel(Level.SEVERE); app.getCamera().setFrustumFar(fFar); app.getCamera().setFrustumNear(fNear); if( environment.isInVR() ) { logger.config("VR mode enabled."); if( environment.getVRHardware() != null ) { environment.getVRHardware().initVRCompositor(environment.compositorAllowed()); } else { logger.warning("No VR system found."); } environment.getVRViewManager().setResolutionMultiplier(resMult); //inputManager.addMapping(RESET_HMD, new KeyTrigger(KeyInput.KEY_F9)); //setLostFocusBehavior(LostFocusBehavior.Disabled); } else { logger.config("VR mode disabled."); //viewPort.attachScene(rootNode); //guiViewPort.attachScene(guiNode); } if( environment.getVRViewManager() != null ) { environment.getVRViewManager().initialize(); } }
Example #9
Source File: BulletAppState.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
public void stateAttached(AppStateManager stateManager) { if (!initialized) { startPhysics(); } if (threadingType == ThreadingType.PARALLEL) { PhysicsSpace.setLocalThreadPhysicsSpace(pSpace); } }
Example #10
Source File: BulletAppState.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Transition this state from detached to initializing. Should be invoked * only by a subclass or by the AppStateManager. * * @param stateManager (not null) */ @Override public void stateAttached(AppStateManager stateManager) { super.stateAttached(stateManager); if (!isRunning) { startPhysics(); } if (threadingType == ThreadingType.PARALLEL) { PhysicsSpace.setLocalThreadPhysicsSpace(pSpace); } if (debugEnabled) { debugAppState = new BulletDebugAppState(pSpace); stateManager.attach(debugAppState); } }
Example #11
Source File: BulletAppState.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Initialize this state prior to its 1st update. Should be invoked only by * a subclass or by the AppStateManager. * * @param stateManager the manager for this state (not null) * @param app the application which owns this state (not null) */ @Override public void initialize(AppStateManager stateManager, Application app) { super.initialize(stateManager, app); this.app = app; this.stateManager = stateManager; startPhysics(); }
Example #12
Source File: BulletDebugAppState.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Initialize this state prior to its 1st update. Should be invoked only by * a subclass or by the AppStateManager. * * @param stateManager the manager for this state (not null) * @param app the application which owns this state (not null) */ @Override public void initialize(AppStateManager stateManager, Application app) { super.initialize(stateManager, app); this.app = app; this.rm = app.getRenderManager(); this.assetManager = app.getAssetManager(); setupMaterials(app); physicsDebugRootNode.setCullHint(Spatial.CullHint.Never); viewPort = rm.createMainView("Physics Debug Overlay", app.getCamera()); viewPort.setClearFlags(false, true, false); viewPort.attachScene(physicsDebugRootNode); }
Example #13
Source File: WorldOfInception.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@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); }
Example #14
Source File: BulletAppState.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
public void stateAttached(AppStateManager stateManager) { if (!initialized) { startPhysics(); } if (threadingType == ThreadingType.PARALLEL) { PhysicsSpace.setLocalThreadPhysicsSpace(pSpace); } }
Example #15
Source File: Cinematic.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * used internally * * @param stateManager the state manager * @param app the application */ @Override public void initialize(AppStateManager stateManager, Application app) { initEvent(app, this); for (CinematicEvent cinematicEvent : cinematicEvents) { cinematicEvent.initEvent(app, this); } if(!cameras.isEmpty()){ for(CameraNode n : cameras.values()){ n.setCamera(app.getCamera()); } } initialized = true; }
Example #16
Source File: AWTComponentAppState.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void stateAttached(final AppStateManager stateManager) { processor = new AWTFrameProcessor(); processor.setTransferMode(transferMode); AWTTaskExecutor.getInstance().addToExecute(new Runnable() { @Override public void run() { processor.bind(component, stateManager.getApplication(), stateManager.getApplication().getViewPort()); } }); }
Example #17
Source File: StatsAppState.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void initialize(AppStateManager stateManager, Application app) { super.initialize(stateManager, app); this.app = app; if (app instanceof SimpleApplication) { SimpleApplication simpleApp = (SimpleApplication)app; if (guiNode == null) { guiNode = simpleApp.guiNode; } if (guiFont == null ) { guiFont = simpleApp.guiFont; } } if (guiNode == null) { throw new RuntimeException( "No guiNode specific and cannot be automatically determined." ); } if (guiFont == null) { guiFont = app.getAssetManager().loadFont("Interface/Fonts/Default.fnt"); } loadFpsText(); loadStatsView(); loadDarken(); }
Example #18
Source File: ChaseCameraAppState.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void initialize(AppStateManager stateManager, Application app) { super.initialize(stateManager, app); this.inputManager = app.getInputManager(); target = new Node("ChaseCamTarget"); camNode.setCamera(app.getCamera()); camNode.setControlDir(CameraControl.ControlDirection.SpatialToCamera); target.attachChild(camNode); camNode.setLocalTranslation(0, 0, distance); upVector = app.getCamera().getUp().clone(); leftVector = app.getCamera().getLeft().clone(); registerWithInput(); rotateCamera(); }
Example #19
Source File: GroundController.java From OpenRTS with MIT License | 5 votes |
@Override public void stateAttached(AppStateManager stateManager) { super.stateAttached(stateManager); inputManager.setCursorVisible(false); guiController.activate(); logger.info("ground controller on line"); }
Example #20
Source File: BaseAppState.java From Lemur with BSD 3-Clause "New" or "Revised" License | 5 votes |
public final void initialize( AppStateManager stateManager, Application app ) { if( log.isTraceEnabled() ) { log.trace("initialize():" + this); } this.app = app; initialized = true; initialize(app); if( isEnabled() ) { enable(); } }
Example #21
Source File: Stats3DPart.java From jmonkeybuilder with Apache License 2.0 | 5 votes |
@Override @JmeThread public void initialize(@NotNull final AppStateManager stateManager, @NotNull final Application application) { super.initialize(stateManager, application); this.application = application; this.statistics = application.getRenderer().getStatistics(); this.statsData = new int[statistics.getLabels().length]; this.prevStatsData = new int[statistics.getLabels().length]; statistics.setEnabled(STATISTICS_ENABLED.incrementAndGet() > 0); EXECUTOR_MANAGER.addFxTask(() -> FXUtils.addToPane(statsContainer, parent)); }
Example #22
Source File: VRApplication.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void initStateManager(){ stateManager = new AppStateManager(this); // Always register a ResetStatsState to make sure // that the stats are cleared every frame stateManager.attach(new ResetStatsState()); }
Example #23
Source File: ModelEditorBulletPart.java From jmonkeybuilder with Apache License 2.0 | 5 votes |
@Override public void initialize(@NotNull final AppStateManager stateManager, @NotNull final Application app) { super.initialize(stateManager, app); final Spatial currentModel = editor3DPart.getCurrentModel(); if (currentModel != null) { updateNode(currentModel, physicsSpace); } }
Example #24
Source File: MaterialDebugAppState.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void initialize(AppStateManager stateManager, Application app) { renderManager = app.getRenderManager(); assetManager = app.getAssetManager(); inputManager = app.getInputManager(); for (Binding binding : bindings) { bind(binding); } super.initialize(stateManager, app); }
Example #25
Source File: EditorController.java From OpenRTS with MIT License | 5 votes |
@Override public void stateAttached(AppStateManager stateManager) { super.stateAttached(stateManager); inputManager.setCursorVisible(true); // view.getRootNode().attachChild(view.editorRend.mainNode); guiController.activate(); if (ModelManager.getBattlefield() != null) { ModelManager.getBattlefield().getEngagement().reset(); } }
Example #26
Source File: SceneToolController.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
public void stateAttached(AppStateManager asm) { // throw new UnsupportedOperationException("Not supported yet."); }
Example #27
Source File: BattlefieldController.java From OpenRTS with MIT License | 4 votes |
@Override public void stateAttached(AppStateManager stateManager) { super.stateAttached(stateManager); inputManager.setCursorVisible(true); guiController.activate(); }
Example #28
Source File: BulletAppState.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
public void initialize(AppStateManager stateManager, Application app) { if (!initialized) { startPhysics(); } initialized = true; }
Example #29
Source File: EditorController.java From OpenRTS with MIT License | 4 votes |
@Override public void stateDetached(AppStateManager stateManager) { ModelManager.getBattlefield().getEngagement().save(); super.stateDetached(stateManager); view.getRootNode().detachChild(view.editorRend.mainNode); }
Example #30
Source File: BaseMaterialEditor3DPart.java From jmonkeybuilder with Apache License 2.0 | 4 votes |
@Override @JmeThread public void initialize(@NotNull final AppStateManager stateManager, @NotNull final Application application) { super.initialize(stateManager, application); changeModeImpl(getCurrentModelType()); }