Time for action – saving and loading .j3o files

Right-clicking a model in the SDK is not the only way to create j3o files. Another common situation is that you want to save the current scene when the player quits, and restore the game when the player restarts the application.

You can use com.jme3.export.binary.BinaryExporter to create j3o files, and the com.jme3.asset.plugins.FileLocator to register custom directories as AssetManager root directories. Switch over to your BasicGame project in the jMonkeyEngine SDK again.

  1. Make a copy of LoadModel.java and name the class SaveModel.java. Remember to also refactor the first line of the main() method to:
    SaveModel app = new SaveModel();
  2. Keep the light source. Replace the model loading code in the simpleInitApp() ...

Get jMonkeyEngine 3.0 Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.