State Manager
State Manager
Hi all,
I've problem with projecting of State Manager. Should I use a different Scene Manager for each state? Earlier I use one Scene Manager and when I was changing states I was setting Visible = false; for each Scene Node used in previous state. What do you think about it? Thanks for answers and sorry for my english
I've problem with projecting of State Manager. Should I use a different Scene Manager for each state? Earlier I use one Scene Manager and when I was changing states I was setting Visible = false; for each Scene Node used in previous state. What do you think about it? Thanks for answers and sorry for my english
-
- Posts: 1186
- Joined: Fri Dec 29, 2006 12:04 am
Re: State Manager
The one by vitek works very well.UrsaMajor wrote:Hi all,
I've problem with projecting of State Manager. Should I use a different Scene Manager for each state? Earlier I use one Scene Manager and when I was changing states I was setting Visible = false; for each Scene Node used in previous state. What do you think about it? Thanks for answers and sorry for my english
"Whoops..."
Re: State Manager
Do you need your nodes to stay in the manager for later use or what? I would clean up the scene. tough if you need them to stay there, than I guess its ok, as long as you know what you're doing.UrsaMajor wrote:Hi all,
... I was setting Visible = false; for each Scene Node used in previous state. What do you think about it?
Working on game: Marrbles (Currently stopped).
well you could make that way simpler. just create a "state" node which is basicly just an empty scenenode and use that node as root for all the nodes in a specific state. when you than change the state just call remove on that state node. and all nodes will not be rendered nor processed. When you than come back to the state just call setParent(SceneManager->getRootSceneNode()) on the state node.
of course you will have to grab the state node otherwise it will be deleted on remove.
of course you will have to grab the state node otherwise it will be deleted on remove.
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
I had the same problem, I think it would be better to have menu in the same state. Tough I don't really know what your project configuration is, so its better to decide on your own how to do this.UrsaMajor wrote:Yes, I need them because when I change state from Level to Menu and then from Menu to Level I don't want reload them.Do you need your nodes to stay in the manager for later use or what?
Erm, yeah lets hack irrlicht to do all the game engine job.Sudi wrote:well you could make that way simpler. just create a "state" node which is basicly just an empty scenenode and use that node as root for all the nodes in a specific state. when you than change the state just call remove on that state node. and all nodes will not be rendered nor processed. When you than come back to the state just call setParent(SceneManager->getRootSceneNode()) on the state node.
of course you will have to grab the state node otherwise it will be deleted on remove.
Working on game: Marrbles (Currently stopped).
Actually that is not hacking the system its using the nature of a tree system...
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
Well that depends is the state actually left/closed? or is just put to sleep/backround?
if its closed sure delete all resources. but if it is just sleeping like your game is running and you open the ingame menu which actually should be a different state. then gamestate is just sitting in the background maybe even still running and waiting to be top state again.
if its closed sure delete all resources. but if it is just sleeping like your game is running and you open the ingame menu which actually should be a different state. then gamestate is just sitting in the background maybe even still running and waiting to be top state again.
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
Sudi's method makes perfect sense for any case where you are going to go back to the state you just left, picking up exactly where you left off. This is common in games where you might hit ESC and go into a menu screen, then return to the game.
On top of that, it's highly efficient because you just pull the empty "state" root node out of the scene graph. It doesn't consume processing resources because it doesn't get touched by the scene manager during updates. And you don't wait forever for your assets to reload when you want to go back.
Of course, if you don't need those resources anymore at all, you would choose to remove that "state" node permanently, or destroy the scene manager and create a new one.
It depends on the application.
On top of that, it's highly efficient because you just pull the empty "state" root node out of the scene graph. It doesn't consume processing resources because it doesn't get touched by the scene manager during updates. And you don't wait forever for your assets to reload when you want to go back.
Of course, if you don't need those resources anymore at all, you would choose to remove that "state" node permanently, or destroy the scene manager and create a new one.
It depends on the application.
You can also do that by just making the menu appear in the same state, thus you can have your objects visible. And making node invisible won't stop physics from not updating, unless using irrlicht animators, or doning checks if the root node is visible, but it looks way too unorganized.Mikhail9 wrote:Sudi's method makes perfect sense for any case where you are going to go back to the state you just left, picking up exactly where you left off. This is common in games where you might hit ESC and go into a menu screen, then return to the game.
Working on game: Marrbles (Currently stopped).
Making a menu in the same state as the game is actually pretty messy and unorganized. A menu is obviously a state so it deserves it own state with its own vars etc.serengeor wrote: You can also do that by just making the menu appear in the same state, thus you can have your objects visible. And making node invisible won't stop physics from not updating, unless using irrlicht animators, or doning checks if the root node is visible, but it looks way too unorganized.
Besides we talked about irrlicht and not physics when you want to disable physics just don't call the physics update function while the game state is not active...simple right
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
Messy eh? And Making entities do the game framework job is not messy ? ok..Sudi wrote: Making a menu in the same state as the game is actually pretty messy and unorganized. A menu is obviously a state so it deserves it own state with its own vars etc.
Besides we talked about irrlicht and not physics when you want to disable physics just don't call the physics update function while the game state is not active...simple right
And by talking about menu, I was thinking of pause menu, and not many games really allow you to enter the main menu without quiting your game state.
Working on game: Marrbles (Currently stopped).
It looks pretty good. Thanks.well you could make that way simpler. just create a "state" node which is basicly just an empty scenenode and use that node as root for all the nodes in a specific state. when you than change the state just call remove on that state node. and all nodes will not be rendered nor processed. When you than come back to the state just call setParent(SceneManager->getRootSceneNode()) on the state node.
of course you will have to grab the state node otherwise it will be deleted on remove.
And I have another question. I want make a simple transitions. I made a texture(rectangle 640x480 - for my default resolution) with half-transparent borders. It works good for 640x480, but when I change resolution, texture have the same resolution. How can I change resolution of this texture? I wrote this:
Code: Select all
video::SMaterial material;
material.setTexture(0,texture);
core::matrix4 matrix = material.getTextureMatrix(0);
matrix.setTextureScale(2.1f,2.0f);
material.setTextureMatrix(0,matrix);
texture = material.getTexture(0);
//EDIT: I managed to do that. I used gui::IGUIImage instead of video::ITexture. Here is the link for property usage of SetAlingment if someone have the same problem: http://irrlicht.sourceforge.net/phpBB2/ ... scaleimage