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);
}
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();
}
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);
}
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]);
}
}
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]);
}
}
Aggregations