![]() |
|
|
|
#1
|
|||
|
|||
|
Newbie - Trouble using loops
Hi all,
I'm new to using Vizard and am having difficulty using loops. My issue is that when I use a loop, it blocks the environment from being rendered. I thought that this was OK as I was using the same method I saw in the Vizard documentation. Code:
import viz
import viztask
env = viz.add('../models/environment.OSGB')
viz.go()
def run():
while True:
# Something simple
print viz.MainView.getPosition()
print viz.MainView.getEuler()
viztask.schedule(run())
|
|
#2
|
|||
|
|||
|
Functions scheduled with viztask must contain a yield command. The following should work:
Code:
import viz
import viztask
env = viz.add('dojo.osgb')
viz.go()
def run():
while True:
# Something simple
yield viztask.waitTime(1)
print viz.MainView.getPosition()
print viz.MainView.getEuler()
viztask.schedule(run())
|
|
#3
|
|||
|
|||
|
Thanks for the quick reply.
Yep, that worked. I must ask though, why is this? Using what you said, I have put the print statements in another function and I call that using a yield statement. |
|
#4
|
|||
|
|||
|
Vizard's task functions are implemented using Python generators which use yield statements.
|
![]() |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| trouble tracking multiple lights | Vkathrynr | Precision Position Tracker (PPT) | 2 | 08-26-2009 01:07 PM |
| Trouble transitioning from one vizard | DBurks2818 | Vizard | 3 | 04-28-2009 03:46 PM |
| Collision trouble | digitaldarklord | Vizard | 6 | 09-16-2008 05:04 PM |
| Trouble Exporting to .ive | le perdusier | Vizard | 2 | 11-27-2007 05:31 PM |
| trouble with winviz.exe | bnord | Vizard | 4 | 09-21-2006 05:22 AM |