WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 01-19-2016, 04:09 AM
VizMars VizMars is offline
Member
 
Join Date: Jan 2016
Posts: 40
Get the refresh rate to run Vizard in

Hi,

I want to get the current refresh rate Vizard is executing the vizact.onupdate commands with.
Are the gobal settings viz.monitor.refresh_rate and viz.display.frequency the same?
When I run viz.getOption('viz.monitor.refresh_rate',type=int) I get the current refresh rate of the monitor, but is this the refresh rate to run Vizard in?
I tried viz.getOption('viz.display.frequency',type=str) but it returns nothing.
Reply With Quote
  #2  
Old 01-19-2016, 10:21 AM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
Vizard's main loop will run only as fast as the refresh rate of the display. If the frame rate is 60 then the function registered with vizact.onupdate will be called 60 times/second. Perhaps the performance page will help explain further.
Reply With Quote
  #3  
Old 01-21-2016, 12:54 AM
VizMars VizMars is offline
Member
 
Join Date: Jan 2016
Posts: 40
I do understand this. But what's the difference between viz.monitor.refresh_rate and viz.display.frequency? And why is viz.getOption('viz.display.frequency',type=int) not working?
Reply With Quote
  #4  
Old 01-22-2016, 03:02 AM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
The viz.monitor.refresh_rate is a read only option that returns the refresh rate of the display.

Code:
print viz.getOption('viz.monitor.refresh_rate')
The viz.display.frequency option is used with the viz.setOption command. I'll check with a developer to find out how's it used and get back to you.
Reply With Quote
  #5  
Old 01-26-2016, 05:15 AM
VizMars VizMars is offline
Member
 
Join Date: Jan 2016
Posts: 40
All right, thank you.
Reply With Quote
  #6  
Old 01-27-2016, 10:42 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
The viz.display.frequency option specifies the requested refresh rate (120, 60, 30, etc..). A lot of monitors these days don't support changing the refresh rate, so it's not guaranteed to work.
Reply With Quote
  #7  
Old 01-28-2016, 01:13 AM
VizMars VizMars is offline
Member
 
Join Date: Jan 2016
Posts: 40
Thanks for your answer!
Reply With Quote
  #8  
Old 09-11-2018, 06:51 AM
peterparker peterparker is offline
Member
 
Join Date: Aug 2018
Posts: 12
Sorry for necroing this old thread. I did not want to create a new one on the same topic.

Turns out, I need this, too. I have a program that runs on 2D Monitors (one experimental condition) and also on VR HMDs. I want to perform a visual transition (change an object's color, e.g.) of a defined duration (1 s, e.g.). If I could find a method that tells me the current display's refresh rate, I could have this transition always taking 1 s irrespective of display device.

Initially, I was using this:

Code:
refresh_rate = int(viz.getOption('viz.monitor.refresh_rate'))
With the effect of the transition running faster on e.g. 90 Hz HMDs than on 60 Hz monitors, because 'monitor' does not return the refresh rate of the HMD.

I don't want to hard code, because "tomorrow" we might use another HMD or monitor with even another refresh rate. And I don't want to draw samples of elapsed frame time, because that might be unreliable.
Reply With Quote
  #9  
Old 09-11-2018, 07:33 AM
peterparker peterparker is offline
Member
 
Join Date: Aug 2018
Posts: 12
I apologize again, the example was badly chosen. There is the 'vizact.fadeTo()' method to perform this color transition.

Actually, for me it is changing the intensity of a light source. Knowing the refresh rate would allow me to compute the number of steps from 1 to 0 in a given time interval.

Alternatively, does the Vizard provide a method for computing such a sequence of (e.g. intensity) values for a transition between two real numbers over a fixed time interval? That would do as well.

However, I would prefer the first way. Being able to query the current refresh rate might come in handy in other situations.
Reply With Quote
  #10  
Old 09-11-2018, 10:59 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
I'll have to ask a developer if there is a way to get the refresh rate from a connected HMD. You could check to see if the HMD is connected and hardcode the rate based on that.

The following shows how to create create an action from a node3d command:

Code:
import viz
import vizact
viz.go()

viz.MainView.getHeadLight().disable()
viz.clearcolor(viz.SLATE)
ball = viz.addChild('basketball.osgb',pos=[0,1.8,3])

light = viz.addLight()
light.intensity(0)

mix = vizact.mix(0.0, 1.0, time=1.0)
change_intensity = vizact.method.intensity(mix)
light.addAction(change_intensity)
Reply With Quote
  #11  
Old 09-12-2018, 01:21 AM
peterparker peterparker is offline
Member
 
Join Date: Aug 2018
Posts: 12
Thanks for the info regrading actions, that would be the second way I outlined above. Good enough for now. As I pointed out earlier, hard coding would not be preferable. I do think, though, that the option for getting the current refresh rate would be great for a graphics/3D engine.

Btw., is there a Vizard command to get the current system time? Or do you have to rely on python's 'time' library?

From using the PsychToolbox I am used to have a command that waits for a particular system. There you can get a time stamp from basically every time critical command and then wait for this time stamp plus 10 ms, e.g.

But then the minimum time interval you can wait in the Vizard is bound to the refresh rate, correct? Unless you are using the director function, of course (which spawns another thread, iirc).
Reply With Quote
  #12  
Old 09-12-2018, 03:24 AM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
Quote:
Btw., is there a Vizard command to get the current system time? Or do you have to rely on python's 'time' library?
For the system time, you would need to use the Python library. Vizard provides the viz.tick command which returns the time elapsed from when the script was started.

Quote:
But then the minimum time interval you can wait in the Vizard is bound to the refresh rate, correct? Unless you are using the director function, of course (which spawns another thread, iirc).
If you're yielding for a Vizard action or event then it's bound to the refresh rate. What is it that you want to wait for and get a timestamp of?
Reply With Quote
  #13  
Old 09-14-2018, 05:04 AM
peterparker peterparker is offline
Member
 
Join Date: Aug 2018
Posts: 12
Thanks, viz.tick would suffice for this purpose.

If I was under time pressure I could have just coded this from scratch: change the light intensity by 1% and wait for 10 ms. Rinse, repeat. I would just ignore the fact that these slight changes do not coincide with frame buffer swaps. Like this I wouldn't have had to know the framerate.

Ideally, I would wait for 'lastTimeStamp + 10 ms' in order to be precise, which would basically be possible with the viz.tick command. But only using the 'viz.director', of course.

Sometimes it is faster to code yourself than to find out whether designated methods exist and how they work.
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Question about Vizard Expiration Timer Rate mizutani_jun Vizard 2 02-23-2011 09:13 PM
Vizard 4 Beta Testing farshizzo Announcements 0 02-01-2011 10:46 AM
Vizard 4 Beta Testing farshizzo Vizard 0 02-01-2011 10:46 AM
Vizard tech tip: Using the Python Imaging Library (PIL) Jeff Vizard 0 03-23-2009 11:13 AM
Vizard tech tip: Text to Speech Jeff Vizard 1 01-15-2009 09:39 PM


All times are GMT -7. The time now is 02:53 AM.


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