And here is the Test class:
import com.jme.math.Vector3f;
import com.jme.scene.shape.Box;
import com.jme.system.PreferencesGameSettings;
import com.jme.util.GameTaskQueueManager;
import com.jme.light.PointLight;
import com.jmex.game.StandardGame;
import com.jmex.game.state.GameStateManager;
import sf.mon.state.DevelopmentState;
import java.util.concurrent.Callable;
import java.util.prefs.BackingStoreException;
import java.util.prefs.Preferences;
/**
* Inspired by darkfrog's great post:
* http://www.jmonkeyengine.com/wiki/doku.php?id=standardgame_gamestates_and_multithreading_a_new_way_of_thinking
*/
public class Test {
public static final Preferences PREFERENCES = Preferences.userRoot().node( "JME 2.0 Test" );
public static PreferencesGameSettings SETTINGS;
public static void main(final String[] args) {
// 1/ set preferences (framerate in windows registry)
setPreferences();
// 2/ initialize "game"
final StandardGame game = new StandardGame( "Test", StandardGame.GameType.GRAPHICAL, SETTINGS);
game.setBackgroundColor( DevelopmentState.BACKGROUND_COLOR );
game.start();
// 3/ apply state
final DevelopmentState state = new DevelopmentState();
GameStateManager.getInstance().attachChild(state);
state.setActive( true );
// 4/ add spatial
final Box box = new Box("Ground", new Vector3f(), 1.0f, 1.0f, 1.0f);
box.setRandomColors();
GameTaskQueueManager.getManager().update(new Callable<Object>() {
public Object call() throws Exception {
box.lock();
return null;
}
});
box.updateRenderState();
state.getRootNode().attachChild(box);
// 5/ add a light
final PointLight light = new PointLight();
light.setLocation( new Vector3f( 1.5f, 2f, -1f ) );
light.setEnabled( true );
state.getLightState().attach( light );
state.getRootNode().updateRenderState();
state.getRootNode().updateWorldBound();
state.getRootNode().updateGeometricState(0.0f, true);
}
private static void setPreferences() {
try {
PREFERENCES.put( "GameFramerate", "63" );
PREFERENCES.sync();
}
catch(BackingStoreException bse){
bse.printStackTrace();
}
SETTINGS = new PreferencesGameSettings(PREFERENCES);
}
}