Booley
Booley

Reputation: 859

jMonkeyEngine: Take screenshots without displaying game?

I want to take screenshots of rendered scenes without displaying the game itself. The procedure I want to follow is:

createScene();
for(i = 0; i < num_screenshots; i++)
{
    moveCameraRandomly();
    saveScreenshot();
}

Basically, I want to randomly reposition the camera in the scene for each screenshot I take. However, I need to call this as a function, so I don't want to display the game itself (but I'm fine with it running in the background). Ideally, I would like to have two projects, one which creates screenshots and one which creates the game, where the first one calls the second one. Is there a way to do this?

Upvotes: 0

Views: 184

Answers (1)

Stephan
Stephan

Reputation: 4443

Applications can be started in headless mode.

Application app = new Main();
app.start(JmeContext.Type.Headless);

http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:headless_server

The ScreenshotAppState can take screenshots:

http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:screenshots

Now you need to develop a combination of both, which is automatically taking screenshots. I recommend that you read the source code of ScreenshotAppState. A already did a similar thing and can tell it is possible.

Upvotes: 1

Related Questions