WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 07-14-2016, 01:37 PM
tokola tokola is offline
Member
 
Join Date: Nov 2012
Posts: 67
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!
Reply With Quote
  #2  
Old 07-15-2016, 05:39 AM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,445
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)
Reply With Quote
  #3  
Old 07-15-2016, 03:40 PM
tokola tokola is offline
Member
 
Join Date: Nov 2012
Posts: 67
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?
Reply With Quote
  #4  
Old 07-16-2016, 05:21 AM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,445
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)
Reply With Quote
  #5  
Old 07-17-2016, 12:44 PM
tokola tokola is offline
Member
 
Join Date: Nov 2012
Posts: 67
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?
Reply With Quote
  #6  
Old 07-18-2016, 02:37 AM
Erikvdb Erikvdb is offline
Member
 
Join Date: May 2013
Posts: 63
Quote:
Originally Posted by tokola View Post
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.
Reply With Quote
  #7  
Old 07-18-2016, 03:44 PM
tokola tokola is offline
Member
 
Join Date: Nov 2012
Posts: 67
Thanks Eric.
I'll take the advice from both of you and make it work the way I want.
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 09:31 PM.


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