com.jme3.app.Application Java Examples
The following examples show how to use
com.jme3.app.Application.
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: TestContextRestart.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
public static void main(String[] args) throws InterruptedException{ AppSettings settings = new AppSettings(true); final Application app = new Application(); app.setSettings(settings); app.start(); Thread.sleep(3000); settings.setFullscreen(true); settings.setResolution(-1, -1); app.setSettings(settings); app.restart(); Thread.sleep(3000); app.stop(); }
Example #2
Source File: ArmatureDebugAppState.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override protected void initialize(Application app) { vp = app.getRenderManager().createMainView("debug", app.getCamera()); vp.attachScene(debugNode); vp.setClearDepth(true); this.app = app; for (ArmatureDebugger armatureDebugger : armatures.values()) { armatureDebugger.initialize(app.getAssetManager(), app.getCamera()); } app.getInputManager().addListener(actionListener, "shoot", "toggleJoints"); app.getInputManager().addMapping("shoot", new MouseButtonTrigger(MouseInput.BUTTON_LEFT), new MouseButtonTrigger(MouseInput.BUTTON_RIGHT)); app.getInputManager().addMapping("toggleJoints", new KeyTrigger(KeyInput.KEY_F10)); debugNode.addLight(new DirectionalLight(new Vector3f(-1f, -1f, -1f).normalizeLocal())); debugNode.addLight(new DirectionalLight(new Vector3f(1f, 1f, 1f).normalizeLocal(), new ColorRGBA(0.5f, 0.5f, 0.5f, 1.0f))); vp.setEnabled(false); }
Example #3
Source File: ScreenshotAppState.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void initialize(AppStateManager stateManager, Application app) { if (!super.isInitialized()){ InputManager inputManager = app.getInputManager(); inputManager.addMapping("ScreenShot", new KeyTrigger(KeyInput.KEY_SYSRQ)); inputManager.addListener(this, "ScreenShot"); List<ViewPort> vps = app.getRenderManager().getPostViews(); ViewPort last = vps.get(vps.size()-1); last.addProcessor(this); if (shotName == null) { shotName = app.getClass().getSimpleName(); } } super.initialize(stateManager, app); }
Example #4
Source File: CameraMovementState.java From Lemur with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override protected void cleanup(Application app) { AppMode.getInstance().clearModeLinks( this ); InputMapper inputMapper = GuiGlobals.getInstance().getInputMapper(); inputMapper.removeDelegate( MainFunctions.F_TOGGLE_MOVEMENT, this, "toggleEnabled" ); inputMapper.removeAnalogListener( this, CameraMovementFunctions.F_Y_LOOK, CameraMovementFunctions.F_X_LOOK, CameraMovementFunctions.F_MOVE, CameraMovementFunctions.F_ALTITUDE, CameraMovementFunctions.F_STRAFE); inputMapper.removeStateListener( this, CameraMovementFunctions.F_RUN); }
Example #5
Source File: AWTFrameProcessor.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Bind this processor. * * @param destination the destination. * @param application the application. * @param viewPort the view port. * @param main true if this processor is main. */ public void bind(final Component destination, final Application application, ViewPort viewPort, boolean main) { if (hasApplication()) { throw new RuntimeException("This process is already bonded."); } setApplication(application); setEnabled(true); this.main = main; this.viewPort = viewPort; this.viewPort.addProcessor(this); if (EventQueue.isDispatchThread()) { bindDestination(application, destination); } else { EventQueue.invokeLater(new Runnable() { @Override public void run() { bindDestination(application, destination); }}); } }
Example #6
Source File: LightProbeFactory.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Internally called to generate the maps. * This method will spawn 7 thread (one for the Irradiance spherical harmonics generator, and one for each face of the prefiltered env map). * Those threads will be executed in a ScheduledThreadPoolExecutor that will be shutdown when the generation is done. * * @param envMap the raw env map rendered by the env camera * @param probe the LightProbe to generate maps for * @param app the Application * @param listener a progress listener. (can be null if no progress reporting is needed) */ private static void generatePbrMaps(TextureCubeMap envMap, final LightProbe probe, Application app, EnvMapUtils.GenerationType genType, final JobProgressListener<LightProbe> listener) { IrradianceSphericalHarmonicsGenerator irrShGenerator; PrefilteredEnvMapFaceGenerator[] pemGenerators = new PrefilteredEnvMapFaceGenerator[6]; final JobState jobState = new JobState(new ScheduledThreadPoolExecutor(7)); irrShGenerator = new IrradianceSphericalHarmonicsGenerator(app, new JobListener(listener, jobState, probe, 6)); int size = envMap.getImage().getWidth(); irrShGenerator.setGenerationParam(EnvMapUtils.duplicateCubeMap(envMap), probe); jobState.executor.execute(irrShGenerator); for (int i = 0; i < pemGenerators.length; i++) { pemGenerators[i] = new PrefilteredEnvMapFaceGenerator(app, i, new JobListener(listener, jobState, probe, i)); pemGenerators[i].setGenerationParam(EnvMapUtils.duplicateCubeMap(envMap), size, EnvMapUtils.FixSeamsMethod.None, genType, probe.getPrefilteredEnvMap()); jobState.executor.execute(pemGenerators[i]); } }
Example #7
Source File: BulletDebugAppState.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Initialize the materials. * * @param app the application which owns this state (not null) */ private void setupMaterials(Application app) { AssetManager manager = app.getAssetManager(); DEBUG_BLUE = new Material(manager, "Common/MatDefs/Misc/Unshaded.j3md"); DEBUG_BLUE.getAdditionalRenderState().setWireframe(true); DEBUG_BLUE.setColor("Color", ColorRGBA.Blue); DEBUG_GREEN = new Material(manager, "Common/MatDefs/Misc/Unshaded.j3md"); DEBUG_GREEN.getAdditionalRenderState().setWireframe(true); DEBUG_GREEN.setColor("Color", ColorRGBA.Green); DEBUG_RED = new Material(manager, "Common/MatDefs/Misc/Unshaded.j3md"); DEBUG_RED.getAdditionalRenderState().setWireframe(true); DEBUG_RED.setColor("Color", ColorRGBA.Red); DEBUG_YELLOW = new Material(manager, "Common/MatDefs/Misc/Unshaded.j3md"); DEBUG_YELLOW.getAdditionalRenderState().setWireframe(true); DEBUG_YELLOW.setColor("Color", ColorRGBA.Yellow); DEBUG_MAGENTA = new Material(manager, "Common/MatDefs/Misc/Unshaded.j3md"); DEBUG_MAGENTA.getAdditionalRenderState().setWireframe(true); DEBUG_MAGENTA.setColor("Color", ColorRGBA.Magenta); DEBUG_PINK = new Material(manager, "Common/MatDefs/Misc/Unshaded.j3md"); DEBUG_PINK.getAdditionalRenderState().setWireframe(true); DEBUG_PINK.setColor("Color", ColorRGBA.Pink); }
Example #8
Source File: MainActivity.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Check to see if the class extends Application or SimpleApplication * @param className Class name to check * @return true if the check passes, false otherwise */ private boolean checkClassType(String className) { boolean include = true; try { Class<?> clazz = Class.forName(className); if (Application.class.isAssignableFrom(clazz)) { Log.d(TAG, "Class " + className + " is a jME Application"); } else { include = false; Log.d(TAG, "Skipping Class " + className + ". Not a jME Application"); } } catch (NoClassDefFoundError ncdf) { include = false; Log.d(TAG, "Skipping Class " + className + ". No Class Def found."); } catch (ClassNotFoundException cnfe) { include = false; Log.d(TAG, "Skipping Class " + className + ". Class not found."); } return include; }
Example #9
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 #10
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 #11
Source File: SoundTrack.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
@Override public void initEvent(Application app, Cinematic cinematic) { super.initEvent(app, cinematic); audioNode = new AudioNode(app.getAssetManager(), path, stream); setLoopMode(loopMode); }
Example #12
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 #13
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 #14
Source File: AWTFrameProcessor.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Bind this processor. * * @param application the application. * @param destination the destination. */ protected void bindDestination(Application application, Component destination) { if (!EventQueue.isDispatchThread()) { throw new RuntimeException("bind has to be done from the Event Dispatching thread."); } if (isMain()) { if (application.getContext() != null) { if (application.getContext() instanceof AWTContext) { AWTContext context = (AWTContext) application.getContext(); AWTMouseInput mouseInput = context.getMouseInput(); mouseInput.bind(destination); AWTKeyInput keyInput = context.getKeyInput(); keyInput.bind(destination); setDestination(destination); bindListeners(); notifyComponentResized(getDestinationWidth(), getDestinationHeight(), isPreserveRatio()); } else { throw new IllegalArgumentException("Underlying application has to use AWTContext (actually using "+application.getContext().getClass().getSimpleName()+")"); } } else { throw new IllegalArgumentException("Underlying application has to use a valid AWTContext (context is null)"); } } }
Example #15
Source File: AWTFrameProcessor.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Bind this processor. * * @param destination the destination. * @param application the application. */ public void bind(Component destination, Application application) { final RenderManager renderManager = application.getRenderManager(); if (renderManager == null) { throw new RuntimeException("No render manager available from the application."); } List<ViewPort> postViews = renderManager.getPostViews(); if (postViews.isEmpty()) { throw new RuntimeException("the list of a post view is empty."); } bind(destination, application, postViews.get(postViews.size() - 1), true); }
Example #16
Source File: ScaleTrack.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
@Override public void initEvent(Application app, Cinematic cinematic) { super.initEvent(app, cinematic); if (spatial == null) { spatial = cinematic.getScene().getChild(spatialName); if (spatial == null) { } else { log.log(Level.WARNING, "spatial {0} not found in the scene", spatialName); } } }
Example #17
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 #18
Source File: PhysicsTestHelper.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * creates the necessary inputlistener and action to shoot balls from the camera * * @param app the application that's running * @param rootNode where ball geometries should be added * @param space where collision objects should be added */ public static void createBallShooter(final Application app, final Node rootNode, final PhysicsSpace space) { ActionListener actionListener = new ActionListener() { @Override public void onAction(String name, boolean keyPressed, float tpf) { Sphere bullet = new Sphere(32, 32, 0.4f, true, false); bullet.setTextureMode(TextureMode.Projected); Material mat2 = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); TextureKey key2 = new TextureKey("Textures/Terrain/Rock/Rock.PNG"); key2.setGenerateMips(true); Texture tex2 = app.getAssetManager().loadTexture(key2); mat2.setTexture("ColorMap", tex2); if (name.equals("shoot") && !keyPressed) { Geometry bulletg = new Geometry("bullet", bullet); bulletg.setMaterial(mat2); bulletg.setShadowMode(ShadowMode.CastAndReceive); bulletg.setLocalTranslation(app.getCamera().getLocation()); RigidBodyControl bulletControl = new RigidBodyControl(10); bulletg.addControl(bulletControl); bulletControl.setLinearVelocity(app.getCamera().getDirection().mult(25)); bulletg.addControl(bulletControl); rootNode.attachChild(bulletg); space.add(bulletControl); } } }; app.getInputManager().addMapping("shoot", new MouseButtonTrigger(MouseInput.BUTTON_LEFT)); app.getInputManager().addListener(actionListener, "shoot"); }
Example #19
Source File: PositionTrack.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
@Override public void initEvent(Application app, Cinematic cinematic) { super.initEvent(app, cinematic); if (spatial == null) { spatial = cinematic.getScene().getChild(spatialName); if (spatial == null) { } else { log.log(Level.WARNING, "spatial {0} not found in the scene", spatialName); } } }
Example #20
Source File: SoundEvent.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void initEvent(Application app, Cinematic cinematic) { super.initEvent(app, cinematic); audioNode = new AudioNode(app.getAssetManager(), path, stream); audioNode.setPositional(false); setLoopMode(loopMode); }
Example #21
Source File: FocusNavigationState.java From Lemur with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override protected void initialize( Application app ) { FocusNavigationFunctions.initializeDefaultMappings(inputMapper); inputMapper.addStateListener(inputHandler, FocusNavigationFunctions.F_NEXT, FocusNavigationFunctions.F_PREV, FocusNavigationFunctions.F_X_AXIS, FocusNavigationFunctions.F_Y_AXIS, FocusNavigationFunctions.F_ACTIVATE ); }
Example #22
Source File: FocusNavigationState.java From Lemur with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override protected void cleanup( Application app ) { inputMapper.removeStateListener(inputHandler, FocusNavigationFunctions.F_NEXT, FocusNavigationFunctions.F_PREV, FocusNavigationFunctions.F_X_AXIS, FocusNavigationFunctions.F_Y_AXIS, FocusNavigationFunctions.F_ACTIVATE ); }
Example #23
Source File: KeyInterceptState.java From Lemur with BSD 3-Clause "New" or "Revised" License | 5 votes |
public KeyInterceptState( Application app ) { setEnabled(true); // We do this as early as possible because we want to // make sure to be able to capture everything if we // are enabled. app.getInputManager().addRawInputListener(keyObserver); }
Example #24
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 #25
Source File: PhysicsTestHelper.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
/** * creates the necessary inputlistener and action to shoot balls from teh camera * @param app * @param rootNode * @param space */ public static void createBallShooter(final Application app, final Node rootNode, final PhysicsSpace space) { ActionListener actionListener = new ActionListener() { public void onAction(String name, boolean keyPressed, float tpf) { Sphere bullet = new Sphere(32, 32, 0.4f, true, false); bullet.setTextureMode(TextureMode.Projected); Material mat2 = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); TextureKey key2 = new TextureKey("Textures/Terrain/Rock/Rock.PNG"); key2.setGenerateMips(true); Texture tex2 = app.getAssetManager().loadTexture(key2); mat2.setTexture("ColorMap", tex2); if (name.equals("shoot") && !keyPressed) { Geometry bulletg = new Geometry("bullet", bullet); bulletg.setMaterial(mat2); bulletg.setShadowMode(ShadowMode.CastAndReceive); bulletg.setLocalTranslation(app.getCamera().getLocation()); RigidBodyControl bulletControl = new RigidBodyControl(1); bulletg.addControl(bulletControl); bulletControl.setLinearVelocity(app.getCamera().getDirection().mult(25)); bulletg.addControl(bulletControl); rootNode.attachChild(bulletg); space.add(bulletControl); } } }; app.getInputManager().addMapping("shoot", new MouseButtonTrigger(MouseInput.BUTTON_LEFT)); app.getInputManager().addListener(actionListener, "shoot"); }
Example #26
Source File: CameraMovementState.java From Lemur with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override protected void cleanup(Application app) { inputMapper.removeAnalogListener( this, CameraMovementFunctions.F_Y_LOOK, CameraMovementFunctions.F_X_LOOK, CameraMovementFunctions.F_MOVE, CameraMovementFunctions.F_ELEVATE, CameraMovementFunctions.F_STRAFE); inputMapper.removeStateListener( this, CameraMovementFunctions.F_RUN); }
Example #27
Source File: FocusManagerState.java From Lemur with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override protected void initialize( Application app ) { }
Example #28
Source File: GuiGlobals.java From Lemur with BSD 3-Clause "New" or "Revised" License | 4 votes |
protected GuiGlobals( Application app ) { this.assets = app.getAssetManager(); if( isHeadless(app) ) { // Do only minimal initialization... and nothing requiring // input, a screen, etc. styles = new Styles(); setDefaultStyles(); iconBase = getClass().getPackage().getName().replace( '.', '/' ) + "/icons"; return; } this.keyInterceptor = new KeyInterceptState(app); // For now, pick either mouse or touch based on the // availability of touch. It's an either/or at the // moment but the rest of the code is setup to support // both at once should we ever want to support touch // devices that also may have a mouse connected. if (app.getContext().getTouchInput() == null) { this.mouseState = new MouseAppState(app); } else { this.touchState = new TouchAppState(app); } this.inputMapper = new InputMapper(app.getInputManager()); this.focusState = new FocusManagerState(); this.focusNavState = new FocusNavigationState(inputMapper, focusState); this.animationState = new AnimationState(); this.popupState = new PopupState(); // Write the app state dependencies directly so that: // a) they are there before initialization // b) so that the states don't have to rely on GuiGlobals to find // them. // c) so that we might disable them properly even at runtime // if the user kills or replaces the nav state focusState.setFocusNavigationState(focusNavState); app.getStateManager().attach(keyInterceptor); if( mouseState != null ) { app.getStateManager().attach(mouseState); } if( touchState != null ) { app.getStateManager().attach(touchState); } app.getStateManager().attach(focusState); app.getStateManager().attach(focusNavState); app.getStateManager().attach(animationState); app.getStateManager().attach(popupState); styles = new Styles(); setDefaultStyles(); iconBase = getClass().getPackage().getName().replace( '.', '/' ) + "/icons"; ViewPort main = app.getViewPort(); setupGuiComparators(main); // By default all of our app picking states are enabled so we should // make a 'formal' request. setCursorEventsEnabled(true); gammaEnabled = app.getContext().getSettings().isGammaCorrection(); }
Example #29
Source File: FocusManagerState.java From Lemur with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override protected void cleanup( Application app ) { }
Example #30
Source File: GuiGlobals.java From Lemur with BSD 3-Clause "New" or "Revised" License | 4 votes |
public static void initialize( Application app ) { setInstance(new GuiGlobals(app)); }