com.jme3.app.SimpleApplication Java Examples

The following examples show how to use com.jme3.app.SimpleApplication. 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: TestRemoteCall.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
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();
    }
}
 
Example #2
Source File: TestApplet.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public static void startApp(){
    applet.add(canvas);
    app.startCanvas();

    app.enqueue(new Callable<Void>(){
        @Override
        public Void call(){
            if (app instanceof SimpleApplication){
                SimpleApplication simpleApp = (SimpleApplication) app;
                simpleApp.getFlyByCamera().setDragToRotate(true);
                simpleApp.getInputManager().setCursorVisible(true);
            }
            return null;
        }
    });
}
 
Example #3
Source File: TestRemoteCall.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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();
    }
}
 
Example #4
Source File: PopupState.java    From Lemur with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 *  Returns the GUI node that will be used to display the option
 *  panel.  By default, this is SimpleApplication.getGuiNode().  
 */
public Node getGuiNode() {
    if( guiNode != null ) {
        return guiNode;
    }
    Application app = getApplication();
    if( app instanceof SimpleApplication ) {
        this.guiNode = ((SimpleApplication)app).getGuiNode();
    }
    return guiNode;
}
 
Example #5
Source File: TestCanvas.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static void startApp(){
    app.startCanvas();
    app.enqueue(new Callable<Void>(){
        @Override
        public Void call(){
            if (app instanceof SimpleApplication){
                SimpleApplication simpleApp = (SimpleApplication) app;
                simpleApp.getFlyByCamera().setDragToRotate(true);
            }
            return null;
        }
    });

}
 
Example #6
Source File: WorldOfInception.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void initialize(AppStateManager stateManager, Application app) {
    super.initialize(stateManager, app);
    //only generate data and attach node when we are actually attached (or picking)
    initData();
    application = (SimpleApplication) app;
    application.getRootNode().attachChild(getRootNode());
    application.getStateManager().attach(physicsState);
}
 
Example #7
Source File: TestCanvas.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static void startApp(){
    app.startCanvas();
    app.enqueue(new Callable<Void>(){
        public Void call(){
            if (app instanceof SimpleApplication){
                SimpleApplication simpleApp = (SimpleApplication) app;
                simpleApp.getFlyByCamera().setDragToRotate(true);
            }
            return null;
        }
    });
    
}
 
Example #8
Source File: TestApplet.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static void startApp(){
    applet.add(canvas);
    app.startCanvas();

    app.enqueue(new Callable<Void>(){
        public Void call(){
            if (app instanceof SimpleApplication){
                SimpleApplication simpleApp = (SimpleApplication) app;
                simpleApp.getFlyByCamera().setDragToRotate(true);
                simpleApp.getInputManager().setCursorVisible(true);
            }
            return null;
        }
    });
}
 
Example #9
Source File: VRApplication.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void update() {    
    // Make sure the audio renderer is available to callables
    AudioContext.setAudioRenderer(audioRenderer);

    runQueuedTasks();

    if (speed != 0 && !paused) {

        timer.update();

        if (inputEnabled){
            inputManager.update(timer.getTimePerFrame());
        }

        if (audioRenderer != null){
            audioRenderer.update(timer.getTimePerFrame());
        }
    }
    
    if (speed == 0 || paused) {
        try {
            Thread.sleep(50); // throttle the CPU when paused
        } catch (InterruptedException ex) {
            Logger.getLogger(SimpleApplication.class.getName()).log(Level.SEVERE, null, ex);
        }
        return;
    }
    
    float tpf = timer.getTimePerFrame() * speed;
    
    // update states
    stateManager.update(tpf);

    // simple update and root node
    simpleUpdate(tpf);
 
    
    // render states
    stateManager.render(renderManager);
    
    // update VR pose & cameras
    if( viewmanager != null ) {
    	viewmanager.update(tpf);    
    } else if( observer != null ) {
        getCamera().setFrame(observer.getWorldTranslation(), observer.getWorldRotation());
    }
    
    //FIXME: check if this code is necessary.
    // Updates scene and gui states.
    rootNode.updateLogicalState(tpf);
    guiNode.updateLogicalState(tpf);
    
    rootNode.updateGeometricState();
    
    if( isInVR() == false || guiManager.getPositioningMode() == VRGUIPositioningMode.MANUAL ) {
        // only update geometric state here if GUI is in manual mode, or not in VR
        // it will get updated automatically in the viewmanager update otherwise
        guiNode.updateGeometricState();
    }
    
    renderManager.render(tpf, context.isRenderable());
    simpleRender(renderManager);
    stateManager.postRender();
    
    // update compositor?
    if( viewmanager != null ) {
    	viewmanager.postRender();
    }
}