How does gameStates and scenegraph work together?

this is a really newbie question. but im a newbie anyways :smiley:



i have two gamestates both extends basicgamestate right now.

a universal state which contains, cullstate, skybox, lightstate, fogstate, hoekeys and mouse.

a terrain state which contains a terrain, a player, and a chasecamera.



they each has a rootnode which contains all the things in that state.



my question is will the lightstate, fogstate and ect in the universal state affect the player, terrain and ect in the other state?



from my newbie point of view, i think they dont affect each other since they are attached to two different rootnodes. is this correct



if they dont, how do i make everything in the universal state affect the things in the terrain state.

before when i was using basegame it looks like this





now with gamestates+standardgame it looks like this





whats going on? :?

The states will obiously only affect the nodes they are attached too (and their children). GameStates just provide a nice way of switching scenes on and off.

You'll have to duplicate your controls/states or pass them through to each gamestate so you may apply to them the rootNode, etc.

alright thx. i guess i need to reconsider the way i organize my states.

Yes. As well as GameStates there are GameStateNodes which you might find interesting, allowing to you build a tree like structure.

adamgp said:

Yes. As well as GameStates there are GameStateNodes which you might find interesting, allowing to you build a tree like structure.


whats the advantage of forming the gamestates into a tree like structure?

Havent got a clue! Thats one thing I need to read up about.

I'm guessing because you can disable the gameState, and it recurse down all nodes - whilst providing the functionality to disable various leafs of the tree.

adamgp said:

providing the functionality to disable various leafs of the tree.


but isnt that the same thing as calling state.setActivity(false)?

y do i need to organize them into a tree?

For example, if you have:



MyGameState

    - MySubGameState1

    - MySubGameState2



You can call myGameState.setEnabled(false) and it will also disable the sub game states as well.  This allows you to abstract parts of your application if you have multiple game states and want greater control over enabling / disabling without having to cycle through all the states and enable/disable them.

oh i c~



thx darkfrog, im now fully using standardgame + gamestates ha! :smiley: