Search in sources :

Example 26 with AppSettings

use of com.jme3.system.AppSettings in project Lina by MisterCavespider.

the class Test method main.

public static void main(String[] args) {
    Test t = new Test();
    AppSettings sets = new AppSettings(true);
    sets.setFrameRate(60);
    t.setSettings(sets);
    t.start();
}
Also used : AppSettings(com.jme3.system.AppSettings)

Example 27 with AppSettings

use of com.jme3.system.AppSettings in project TeachingInSimulation by ScOrPiOzzy.

the class TestJmeToJFXCanvas method makeJmeApplication.

@NotNull
private static JmeToJFXApplication makeJmeApplication() {
    final AppSettings settings = JmeToJFXIntegrator.prepareSettings(new AppSettings(true), 60);
    final JmeToJFXApplication application = new JmeToJFXApplication() {

        protected Geometry player;

        Boolean isRunning = true;

        @Override
        public void simpleInitApp() {
            super.simpleInitApp();
            flyCam.setDragToRotate(true);
            Box b = new Box(1, 1, 1);
            player = new Geometry("Player", b);
            Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
            mat.setColor("Color", ColorRGBA.Blue);
            player.setMaterial(mat);
            rootNode.attachChild(player);
            // 添加鼠标监听
            inputManager.addMapping("pick", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
            inputManager.addListener((ActionListener) (name, isPressed, tpf) -> {
                if (isPressed) {
                    System.out.println(inputManager.getCursorPosition());
                    System.out.println(settings.getWidth());
                    System.out.println(settings.getHeight());
                    // @Nullable
                    // Geometry picked = JmeUtil.getGeometryFromCursor(root, cam, inputManager);
                    // if (picked != null) {
                    // System.err.println(picked);
                    // }
                    @Nullable Vector3f point = JmeUtil.getContactPointFromCursor(rootNode, cam, inputManager);
                    if (point != null) {
                        Geometry ball = JmeUtil.getSphere(assetManager, 32, 0.1f, ColorRGBA.Red);
                        rootNode.attachChild(ball);
                        ball.setLocalTranslation(point);
                    }
                }
            }, "pick");
        // initKeys(); // load my custom keybinding
        }
    };
    application.setSettings(settings);
    application.setShowSettings(false);
    return application;
}
Also used : Geometry(com.jme3.scene.Geometry) Button(javafx.scene.control.Button) Scene(javafx.scene.Scene) JmeToJFXApplication(com.jme3x.jfx.injfx.JmeToJFXApplication) AppSettings(com.jme3.system.AppSettings) JmeUtil(com.cas.sim.tis.util.JmeUtil) Vector3f(com.jme3.math.Vector3f) ActionListener(com.jme3.input.controls.ActionListener) Canvas(javafx.scene.canvas.Canvas) MouseButtonTrigger(com.jme3.input.controls.MouseButtonTrigger) StackPane(javafx.scene.layout.StackPane) MouseInput(com.jme3.input.MouseInput) Application(javafx.application.Application) Nullable(org.jetbrains.annotations.Nullable) JFXMouseInput(com.jme3x.jfx.injfx.input.JFXMouseInput) Stage(javafx.stage.Stage) Material(com.jme3.material.Material) JmeToJFXIntegrator(com.jme3x.jfx.injfx.JmeToJFXIntegrator) ColorRGBA(com.jme3.math.ColorRGBA) NotNull(org.jetbrains.annotations.NotNull) Geometry(com.jme3.scene.Geometry) Box(com.jme3.scene.shape.Box) JmeToJFXApplication(com.jme3x.jfx.injfx.JmeToJFXApplication) AppSettings(com.jme3.system.AppSettings) Vector3f(com.jme3.math.Vector3f) Box(com.jme3.scene.shape.Box) Material(com.jme3.material.Material) MouseButtonTrigger(com.jme3.input.controls.MouseButtonTrigger) NotNull(org.jetbrains.annotations.NotNull)

Example 28 with AppSettings

use of com.jme3.system.AppSettings in project jmonkeyengine by jMonkeyEngine.

the class JmeDesktopSystem method showSettingsDialog.

@Override
public boolean showSettingsDialog(AppSettings sourceSettings, final boolean loadFromRegistry) {
    if (SwingUtilities.isEventDispatchThread()) {
        throw new IllegalStateException("Cannot run from EDT");
    }
    if (GraphicsEnvironment.isHeadless()) {
        throw new IllegalStateException("Cannot show dialog in headless environment");
    }
    final AppSettings settings = new AppSettings(false);
    settings.copyFrom(sourceSettings);
    String iconPath = sourceSettings.getSettingsDialogImage();
    if (iconPath == null) {
        iconPath = "";
    }
    final URL iconUrl = JmeSystem.class.getResource(iconPath.startsWith("/") ? iconPath : "/" + iconPath);
    if (iconUrl == null) {
        throw new AssetNotFoundException(sourceSettings.getSettingsDialogImage());
    }
    final AtomicBoolean done = new AtomicBoolean();
    final AtomicInteger result = new AtomicInteger();
    final Object lock = new Object();
    final SelectionListener selectionListener = new SelectionListener() {

        public void onSelection(int selection) {
            synchronized (lock) {
                done.set(true);
                result.set(selection);
                lock.notifyAll();
            }
        }
    };
    SwingUtilities.invokeLater(new Runnable() {

        public void run() {
            synchronized (lock) {
                SettingsDialog dialog = new SettingsDialog(settings, iconUrl, loadFromRegistry);
                dialog.setSelectionListener(selectionListener);
                dialog.showDialog();
            }
        }
    });
    synchronized (lock) {
        while (!done.get()) {
            try {
                lock.wait();
            } catch (InterruptedException ex) {
            }
        }
    }
    sourceSettings.copyFrom(settings);
    return result.get() == SettingsDialog.APPROVE_SELECTION;
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) AssetNotFoundException(com.jme3.asset.AssetNotFoundException) URL(java.net.URL) SettingsDialog(com.jme3.app.SettingsDialog) SelectionListener(com.jme3.app.SettingsDialog.SelectionListener)

Example 29 with AppSettings

use of com.jme3.system.AppSettings 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 30 with AppSettings

use of com.jme3.system.AppSettings in project jmonkeyengine by jMonkeyEngine.

the class TestContextRestart method main.

public static void main(String[] args) throws InterruptedException {
    AppSettings settings = new AppSettings(true);
    final LegacyApplication app = new LegacyApplication();
    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();
}
Also used : AppSettings(com.jme3.system.AppSettings) LegacyApplication(com.jme3.app.LegacyApplication)

Aggregations

AppSettings (com.jme3.system.AppSettings)40 LegacyApplication (com.jme3.app.LegacyApplication)5 IOException (java.io.IOException)4 AL (com.jme3.audio.openal.AL)3 ALAudioRenderer (com.jme3.audio.openal.ALAudioRenderer)3 ALC (com.jme3.audio.openal.ALC)3 EFX (com.jme3.audio.openal.EFX)2 MouseInput (com.jme3.input.MouseInput)2 Vector2f (com.jme3.math.Vector2f)2 Mesh (com.jme3.scene.Mesh)2 JmeToJFXApplication (com.jme3x.jfx.injfx.JmeToJFXApplication)2 GraphicsDevice (java.awt.GraphicsDevice)2 BufferedReader (java.io.BufferedReader)2 File (java.io.File)2 InputStream (java.io.InputStream)2 TextView (android.widget.TextView)1 JmeUtil (com.cas.sim.tis.util.JmeUtil)1 SettingsDialog (com.jme3.app.SettingsDialog)1 SelectionListener (com.jme3.app.SettingsDialog.SelectionListener)1 AssetNotFoundException (com.jme3.asset.AssetNotFoundException)1