Pausing a scene?

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Even just invoking drawAll() on one scene manager isn't sufficient. All of the animators use the system timer. This timer is a shared global resource. All of the animators, regardless of which scene manager they belong to, will believe that time is moving forward when the timer is running and the will believe it has stopped if the timer is paused.

To be able to independently stop/start animation of entities in different scene graphs, you'd need to seperate the shared clock from the animators. Either giving them their own timer code and allowing them to share or not share a timer.

The other way would be to switch over to using a task engine [like the dusty engine]. Each task can be independently started and stopped, and tasks can be grouped so that if you stop one all of the tasks that are children would be stopped also.

Travis
Sean H.
Posts: 21
Joined: Mon Aug 06, 2007 12:25 am

Post by Sean H. »

Couldn't you just use irr::ITimer::setSpeed(0) for pausing?
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Yes. Well actually you would write something more like

Code: Select all

device->getTimer()->setSpeed(0.f)
That is basically what I described in my post when I said If you stop the timer, you stop the animators. Simple as that.. Unfortunately that doesn't solve the more general case, and the second issue that was mentioned...
Another one...is there a way to isolate the Scenes and having the Device.Run() act only upon one "active" scene?

<days later>

What I need is defenitively a way to isolate scenes (or scenemanagers) from each other. So you could have a scene with guielements and scenenodes on it but the scene would not be automaticaly updated, drawn nor presented with device.Run(), Begin/EndScene().
The timer that Irrlicht provides is global. Every node could get some methods for rescaling or stopping time, but that would be crazy. It would make much more sense to apply a timer framework. That way you get fine grained control over the time for different parts of simulation/game.

Travis
Grey Lantern
Posts: 34
Joined: Sat Jul 30, 2005 9:45 am
Contact:

Post by Grey Lantern »

I had something similar (if I read it correctly, though i'm in a rush).

I wanted to pause timers (to stop animators/pause the 3D scene) but still wanted timers to run on for my other parts of game (gui/menus which are animated with custom code).

I abstracted the base irrlicht code to give it another timer (subtimer) basically adding 2 timers a 3D timer and a 2D 'paused' timer, you can do this a number of ways and I certainly can't remember off the top of my head how much irrlicht code I changed and how much was just my extra timer code in my timer class but it may be something to look into. Then I just pause my subtimer which 'starves' the scenemanager of any updates (timedelta = 0 effectively) while the real timer still runs on (keeping the game reactive and allowing user interfaces to still work/animate).

ymmv ;)
G3LO
Posts: 16
Joined: Mon Aug 20, 2007 10:37 am
Location: Poland

Post by G3LO »

How about removing animators and using `memento` design pattern?
Wouldn`t it be convinient enough?

pseudocode:

Code: Select all

//save scene-state
foreach (gameObject)
{
object->save()
}
//restore
foreach (gameObject)
{
object->restore()
}
//object::save
self->memento = self->requestMemento() //memento is initalized
self->freeze() //object is removing animators
//object::restore
self->restore (self->memento) //object restoring state using memento`s information
h4ck d4 5y5t3m
FlyingIsFun1217
Posts: 219
Joined: Fri Apr 13, 2007 8:29 pm
Location: Illinois
Contact:

Post by FlyingIsFun1217 »

Well, if pausing all animations causes blurs and stuff to 'disappear', and you want them paused too, I would think you could render a texture of the desired screen size from the active camera, pause anything going on in the scene, and display the texture you took.

I would think this would be ideal for game-type situations, although I can't say it would be easier or better than any other method. Just my thoughts!

FlyingIsFun1217
Post Reply