Search in sources :

Example 1 with SimpleApplication

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

the class BasicProfilerState method onEnable.

@Override
protected void onEnable() {
    // Set the number of visible frames to the current width of the screen
    setFrameCount(getApplication().getCamera().getWidth());
    getApplication().setAppProfiler(profiler);
    Node gui = ((SimpleApplication) getApplication()).getGuiNode();
    gui.attachChild(graph);
    gui.attachChild(background);
}
Also used : Node(com.jme3.scene.Node)

Example 2 with SimpleApplication

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

the class TestFBOPassthrough method simpleRender.

@Override
public void simpleRender(RenderManager rm) {
    Renderer r = rm.getRenderer();
    //do FBO rendering
    r.setFrameBuffer(fb);
    // FBO uses current camera
    rm.setCamera(cam, false);
    r.clearBuffers(true, true, true);
    rm.renderScene(fbNode, viewPort);
    rm.flushQueue(viewPort);
    //go back to default rendering and let
    //SimpleApplication render the default scene
    r.setFrameBuffer(null);
}
Also used : Renderer(com.jme3.renderer.Renderer)

Example 3 with SimpleApplication

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

the class TestChooser method startApp.

private void startApp(final Object[] appClass) {
    if (appClass == null) {
        JOptionPane.showMessageDialog(rootPane, "Please select a test from the list", "Error", JOptionPane.ERROR_MESSAGE);
        return;
    }
    new Thread(new Runnable() {

        public void run() {
            for (int i = 0; i < appClass.length; i++) {
                Class<?> clazz = (Class) appClass[i];
                try {
                    if (LegacyApplication.class.isAssignableFrom(clazz)) {
                        Object app = clazz.newInstance();
                        if (app instanceof SimpleApplication) {
                            final Method settingMethod = clazz.getMethod("setShowSettings", boolean.class);
                            settingMethod.invoke(app, showSetting);
                        }
                        final Method mainMethod = clazz.getMethod("start");
                        mainMethod.invoke(app);
                        Field contextField = LegacyApplication.class.getDeclaredField("context");
                        contextField.setAccessible(true);
                        JmeContext context = null;
                        while (context == null) {
                            context = (JmeContext) contextField.get(app);
                            Thread.sleep(100);
                        }
                        while (!context.isCreated()) {
                            Thread.sleep(100);
                        }
                        while (context.isCreated()) {
                            Thread.sleep(100);
                        }
                    } else {
                        final Method mainMethod = clazz.getMethod("main", (new String[0]).getClass());
                        mainMethod.invoke(clazz, new Object[] { new String[0] });
                    }
                    // wait for destroy
                    System.gc();
                } catch (IllegalAccessException ex) {
                    logger.log(Level.SEVERE, "Cannot access constructor: " + clazz.getName(), ex);
                } catch (IllegalArgumentException ex) {
                    logger.log(Level.SEVERE, "main() had illegal argument: " + clazz.getName(), ex);
                } catch (InvocationTargetException ex) {
                    logger.log(Level.SEVERE, "main() method had exception: " + clazz.getName(), ex);
                } catch (InstantiationException ex) {
                    logger.log(Level.SEVERE, "Failed to create app: " + clazz.getName(), ex);
                } catch (NoSuchMethodException ex) {
                    logger.log(Level.SEVERE, "Test class doesn't have main method: " + clazz.getName(), ex);
                } catch (Exception ex) {
                    logger.log(Level.SEVERE, "Cannot start test: " + clazz.getName(), ex);
                    ex.printStackTrace();
                }
            }
        }
    }).start();
}
Also used : JmeContext(com.jme3.system.JmeContext) Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Field(java.lang.reflect.Field) SimpleApplication(com.jme3.app.SimpleApplication)

Example 4 with SimpleApplication

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

the class StatsAppState method setFont.

/**
     *  Called by SimpleApplication to provide an early font
     *  so that the fpsText can be created before init.  This
     *  is because several applications expect to directly access
     *  fpsText... unfortunately.
     */
public void setFont(BitmapFont guiFont) {
    this.guiFont = guiFont;
    this.fpsText = new BitmapText(guiFont, false);
}
Also used : BitmapText(com.jme3.font.BitmapText)

Example 5 with SimpleApplication

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

the class TestRemoteCall method createServer.

public static void createServer() {
    serverApp = new SimpleApplication() {

        @Override
        public void simpleInitApp() {
        }
    };
    serverApp.start();
    try {
        Server server = Network.createServer(5110);
        server.start();
        ObjectStore store = new ObjectStore(server);
        store.exposeObject("access", new ServerAccessImpl());
    } catch (IOException ex) {
        ex.printStackTrace();
    }
}
Also used : ObjectStore(com.jme3.network.rmi.ObjectStore) Server(com.jme3.network.Server) SimpleApplication(com.jme3.app.SimpleApplication) IOException(java.io.IOException)

Aggregations

SimpleApplication (com.jme3.app.SimpleApplication)2 Renderer (com.jme3.renderer.Renderer)2 IOException (java.io.IOException)2 BitmapText (com.jme3.font.BitmapText)1 Server (com.jme3.network.Server)1 ObjectStore (com.jme3.network.rmi.ObjectStore)1 Node (com.jme3.scene.Node)1 JmeContext (com.jme3.system.JmeContext)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 Field (java.lang.reflect.Field)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1