Pass and GameState

I have 4 questions for develop my game:



1 - I look many people work with pass, why?

2 - When use Pass or GameState in my Game?

3 - Can i work with pass and gamestate together in my game?

4 - If this was possible, how i do it?



Thanks

1 - I look many people work with pass, why?



With passes you can influence in what order things are drawn and it is also a nice way to divide and conquer your scene graph. as an example you can have an object be drawn in front of any object, even if it is actually behind it. Like in a game like splinter cell, you can switch on the warmth camera and you can draw a particle effect applied to an enemy in front of the wall (so you can see it) even though the enemy is actually behind the wall. also, many shaders are implemented as passes. a bloom effect that is applied to the scene needs the scene to be already rendered. after this is done the bloomRenderPass draws the bloom effect onto the finished image.



2 - When use Pass or GameState in my Game?



passes are to achieve things like the one described above. GameStates are for managing multiple scenegraphs that are independent from each other and that you want to enable/disable. A typical examples are MenuGameState and LoadingGameState.



3 - Can i work with pass and gamestate together in my game?



yes, combine them as much as you like. your GameState can have multiple renderpasses.



4 - If this was possible, how i do it?



in your gamestate you simply create multiple RenderPass objects and a BasicPassManager. Then you attach the scenegraphs to your passes. i think theres a good example in the wiki or search in the jme code.