Search in sources :

Example 31 with Application

use of com.jme3.app.Application in project jmonkeyengine by jMonkeyEngine.

the class ScreenshotAppState method initialize.

@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);
}
Also used : KeyTrigger(com.jme3.input.controls.KeyTrigger) ViewPort(com.jme3.renderer.ViewPort) InputManager(com.jme3.input.InputManager)

Example 32 with Application

use of com.jme3.app.Application in project jmonkeyengine by jMonkeyEngine.

the class TestApplication method main.

public static void main(String[] args) throws InterruptedException {
    System.out.println("Creating application..");
    LegacyApplication app = new LegacyApplication();
    System.out.println("Starting application in LWJGL mode..");
    app.start();
    System.out.println("Waiting 5 seconds");
    Thread.sleep(5000);
    System.out.println("Closing application..");
    app.stop();
    Thread.sleep(2000);
    System.out.println("Starting in fullscreen mode");
    app = new LegacyApplication();
    AppSettings settings = new AppSettings(true);
    settings.setFullscreen(true);
    // current width/height
    settings.setResolution(-1, -1);
    app.setSettings(settings);
    app.start();
    Thread.sleep(5000);
    app.stop();
    Thread.sleep(2000);
    System.out.println("Creating offscreen buffer application");
    app = new LegacyApplication();
    app.start(Type.OffscreenSurface);
    Thread.sleep(3000);
    System.out.println("Destroying offscreen buffer");
    app.stop();
}
Also used : AppSettings(com.jme3.system.AppSettings) LegacyApplication(com.jme3.app.LegacyApplication)

Example 33 with Application

use of com.jme3.app.Application in project jmonkeyengine by jMonkeyEngine.

the class TestResizableApp method simpleInitApp.

public void simpleInitApp() {
    flyCam.setDragToRotate(true);
    Box b = new Box(1, 1, 1);
    Geometry geom = new Geometry("Box", b);
    Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    mat.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg"));
    geom.setMaterial(mat);
    rootNode.attachChild(geom);
    txt = new BitmapText(loadGuiFont(), false);
    txt.setText("Drag the corners of the application to resize it.\n" + "Current Size: " + settings.getWidth() + "x" + settings.getHeight());
    txt.setLocalTranslation(0, settings.getHeight(), 0);
    guiNode.attachChild(txt);
}
Also used : Geometry(com.jme3.scene.Geometry) BitmapText(com.jme3.font.BitmapText) TestBox(jme3test.model.shape.TestBox) Box(com.jme3.scene.shape.Box) Material(com.jme3.material.Material)

Example 34 with Application

use of com.jme3.app.Application in project jmonkeyengine by jMonkeyEngine.

the class LightProbeFactory method generatePbrMaps.

/**
     * Internally called to generate the maps.
     * This method will spawn 7 thread (one for the IrradianceMap, and one for each face of the prefiltered env map).
     * Those threads will be executed in a ScheduledThreadPoolExecutor that will be shutdown when the genration is done.
     * 
     * @param envMap the raw env map rendered by the env camera
     * @param probe the LigthProbe 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, final JobProgressListener<LightProbe> listener) {
    IrradianceMapGenerator irrMapGenerator;
    PrefilteredEnvMapFaceGenerator[] pemGenerators = new PrefilteredEnvMapFaceGenerator[6];
    final JobState jobState = new JobState(new ScheduledThreadPoolExecutor(7));
    irrMapGenerator = new IrradianceMapGenerator(app, new JobListener(listener, jobState, probe, 6));
    int size = envMap.getImage().getWidth();
    irrMapGenerator.setGenerationParam(EnvMapUtils.duplicateCubeMap(envMap), size, EnvMapUtils.FixSeamsMethod.Wrap, probe.getIrradianceMap());
    jobState.executor.execute(irrMapGenerator);
    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.Wrap, probe.getPrefilteredEnvMap());
        jobState.executor.execute(pemGenerators[i]);
    }
}
Also used : IrradianceMapGenerator(com.jme3.environment.generation.IrradianceMapGenerator) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) PrefilteredEnvMapFaceGenerator(com.jme3.environment.generation.PrefilteredEnvMapFaceGenerator)

Example 35 with Application

use of com.jme3.app.Application in project jmonkeyengine by jMonkeyEngine.

the class EnvironmentCamera method initialize.

@Override
protected void initialize(Application app) {
    this.backGroundColor = app.getViewPort().getBackgroundColor();
    final Camera[] cameras = new Camera[6];
    Texture2D[] textures = new Texture2D[6];
    viewports = new ViewPort[6];
    framebuffers = new FrameBuffer[6];
    buffers = new ByteBuffer[6];
    images = new Image[6];
    for (int i = 0; i < 6; i++) {
        cameras[i] = createOffCamera(size, position, axisX[i], axisY[i], axisZ[i]);
        viewports[i] = createOffViewPort("EnvView" + i, cameras[i]);
        framebuffers[i] = createOffScreenFrameBuffer(size, viewports[i]);
        textures[i] = new Texture2D(size, size, imageFormat);
        framebuffers[i].setColorTexture(textures[i]);
    }
}
Also used : Texture2D(com.jme3.texture.Texture2D) Camera(com.jme3.renderer.Camera)

Aggregations

AppSettings (com.jme3.system.AppSettings)11 Material (com.jme3.material.Material)10 Vector2f (com.jme3.math.Vector2f)8 ViewPort (com.jme3.renderer.ViewPort)8 Geometry (com.jme3.scene.Geometry)8 Camera (com.jme3.renderer.Camera)6 Spatial (com.jme3.scene.Spatial)6 Texture2D (com.jme3.texture.Texture2D)6 Node (com.jme3.scene.Node)5 FrameBuffer (com.jme3.texture.FrameBuffer)5 KeyTrigger (com.jme3.input.controls.KeyTrigger)4 InputManager (com.jme3.input.InputManager)3 OSVR (com.jme3.input.vr.OSVR)3 VRAPI (com.jme3.input.vr.VRAPI)3 Application (ca.uhn.hl7v2.app.Application)2 BitmapText (com.jme3.font.BitmapText)2 MouseInput (com.jme3.input.MouseInput)2 ActionListener (com.jme3.input.controls.ActionListener)2 MouseButtonTrigger (com.jme3.input.controls.MouseButtonTrigger)2 Vector3f (com.jme3.math.Vector3f)2