You mean BaseAppState and onEnable and onDisable, I think.
Well itās not available in 3.0.
but Iād definitely use this in 3.1
but how do I make my own rootnode actualy renders on screen ?
viewPort.attachScene(rootNode); ?
also in update() I see:
rootNode.updateLogicalState(tpf);
guiNode.updateLogicalState(tpf);
rootNode.updateGeometricState();
guiNode.updateGeometricState();
is maintaining my own rootnode going to mess everything ?
do I have to override/rewrite update() too ?
yes exactly
No, it wonāt. The appās rootNode will be updated, but since itās empty it wonāt do nothing.
However your appState will update its own rootNode and it will work as it should.
Not the one of the app.
you have to implement the update method of the AppState though and update the appStateās rootNode in it.
Trueā¦ but AbstractAppState doesnāt manage enable/disable for youā¦ so I was confused. It just has a raw flag and you have to manage āstateā yourself. OP can always cut and paste BaseAppStateās code to make their own, thoughā¦ until 3.1.
I dont know why I get this error, since the node is updated in an apptsate update() function
State was changed after rootNode.updateGeometricState() call.
Make sure you do not modify the scene from another thread!
Problem spatial name: myRootNode
at com.jme3.scene.Spatial.checkCulling(Spatial.java:260)
at com.jme3.renderer.RenderManager.renderSubScene(RenderManager.java:647)
at com.jme3.renderer.RenderManager.renderScene(RenderManager.java:640)
at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:974)
at com.jme3.renderer.RenderManager.render(RenderManager.java:1029)
at com.jme3.app.SimpleApplication.update(SimpleApplication.java:252)
here MyAppState extends AbstractAppState and is attached with stateManager.attach(scenario);
public class ScenarioAppState extends MyAppState implements PhysicsCollisionListener,ActionListener
{
...
@Override
public void update(float tpf)
{
switch(state)
{
case RUN:
rootNode.updateLogicalState(tpf);
rootNode.updateGeometricState();
break;
case WAIT_FOR_PLAYER:break;
}
ok I figured I had to add myrootnode appstate as the last one so update() was called after all other appstates modifying geometries
but I still get the error sometimes, not easy to track what is causing the issue
so I enqueued come parts of my code, so far so good
Do the updateGeometricState() in app stateās render() method instead.
Note: this code is strangeā¦ seems like you should just be setEnable(false/true) the app state to control this. update() only runs if isEnabled() returns true.
maybe I should put that updateLogicalState thing in another appstate devoted to that, so far it is in the appstate requesting the game to be paused and checking for āenterā to be pressed to resume the game
btw I never understood the meaning of the render method ??
render() is called after all update()s are called. Thatās it.
As to the other, if thatās all your update() is doing then you could just remove everything but the updateLogicalState() and then enabling or disabling the state would be the same as setting it to RUN or WAIT. I donāt know why youād want yet another state.
Else show us the whole state so we arenāt guessing.