WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Pause and resume simulation without user input (https://forum.worldviz.com/showthread.php?t=5786)

tokola 07-14-2016 12:37 PM

Pause and resume simulation without user input
 
Hi Jeff (or anyone else),

I'm trying to pause and resume the simulation automatically, based on time delay. However, since the timers stop working during pause(), I don't know how this can be accomplished. Neither viztask or any other timer-based solution works. How can I call play() at a predefined time after pause() has been called?

What I want to do is resume the simulation a) after a video finishes playing and b) after vizhtml receives input from clients. In the latter case there is a workaround, to receive the trigger for play() from one of the clients, although by being network-dependent I run the risk of blocking playback in case there's a network glitch.

Any help will be greatly appreciated!:confused:

Jeff 07-15-2016 04:39 AM

The viz.tick command will still update when the timers are paused. You can check the viz.tick value from a function that's registered with the vizact.onupdate command:

Code:

import viz
import vizact
import vizinfo

viz.go()

info = vizinfo.InfoPanel('paused for 5 seconds')

viz.pause()

def updateFunction():
        print 'frame time',viz.getFrameTime()
        print 'viz.tick',viz.tick()
        if viz.tick() > 5.0:
                viz.play()
                info.setText('playing')
               
vizact.onupdate(0,updateFunction)


tokola 07-15-2016 02:40 PM

Thanks Jeff, that could do the trick.

A side question is this: is there a way to pause timer events but still have actions running?

Jeff 07-16-2016 04:21 AM

Instead of pausing the simulation time, you could pause timers individually. This will not affect running actions:

Code:

timerHandle = vizact.ontimer(0,timerFunction)
#disable timer
timerHandle.setEnabled(viz.OFF)
#enable timer
timerHandle.setEnabled(viz.ON)


tokola 07-17-2016 11:44 AM

Yeap, I knew this.
However I've got schedulers and starttimer() events occurring randomly during playback, so it's really hard to address specific timers. Pause() takes care of all these, freezing their operation without cancelling them, but also deactivates animations (actions). I guess there's no other way around it, right?

Erikvdb 07-18-2016 01:37 AM

Quote:

Originally Posted by tokola (Post 18538)
Yeap, I knew this.
However I've got schedulers and starttimer() events occurring randomly during playback, so it's really hard to address specific timers.

Just keep a list of active timers and start/stop them on pause ;)
Schedulers may be a bit more tricky, but you could use some while loops to wait when the game is paused.

tokola 07-18-2016 02:44 PM

Thanks Eric.
I'll take the advice from both of you and make it work the way I want.


All times are GMT -7. The time now is 04:39 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC