Extends Application (instead of SimpleApplication)

I use application as well, cause I need a two step enderng for far and near objects, plus some shader postprocessing magic that is somewhat complex with simpleapplication

In SVN, I have modified SimpleApplication to have most of its extra behaviors added with app states. By default, the no-arg constructor will install three new app states:

FlyCamAppState: manages the flyCam instance.

StatsViewAppState: manages the visibility levels of the StatView

DebugKeysAppState: adds the ‘c’ and ‘m’ keys for dumping debug information to the console.



So by default, SimpleApplication has all of the behaviors it did before. Call super with a subset of these (or null) to drop the behaviors.



AppSettings is pretty integral to SimpleApplication and easy to ignore. Also, it’s not easily extracted in any normal way.



Some slight uncleanliness was required to preserve backwards compatibility with the protected fields.



The nice thing is that these app states can now be added or removed at will from any application that wants them… though now there are even fewer reasons to not extend SimpleApplication.



Given the different places that the StateManager is called I think the use-cases that would require overriding SimpleApplication.update() (not simpleUpdate()) would be really small. Between SceneProcessors and AppStates you can hook in almost anywhere.

3 Likes

Marvelous ! This is definately a step forward. :slight_smile:



[java]public final class JmeApplication extends SimpleApplication

{

public JmeApplication()

{

super( null );

}

…[/java]



Thank you a bunch pspeed. ^.^

Thanks Paul. Obviously it was some pooey design on my part …

It did its job. Now it’s just a bit more flexible… and makes a good app state example, I guess.

I’m not trying to discourage anyone from using SimpleApplication (which I love in secret) It’s just that I’m curious about the engine :blush: and I hope this will be helpfull for the next guy (kill that ***) that doesn’t like the so sexy SimpleApplication.
I found something interesting in the StatsAppState class, if you want to use ur custom (“class” extends Application) with the existing StatsAppState you get an error because of this:

if (app instanceof SimpleApplication) {
SimpleApplication simpleApp = (SimpleApplication)app;
if (guiNode == null) {
guiNode = simpleApp.guiNode;
}
if (guiFont == null ) {
guiFont = simpleApp.guiFont;
}
}

What I did: I wrote another StatsAppState calling my “class” extends Application