WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 07-30-2014, 12:49 PM
lawry2 lawry2 is offline
Member
 
Join Date: Jul 2014
Posts: 2
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())
What I get here is just a black window. The model is never seen but the output window shows the camera Euler and position. I'm aware that the loop is blocking but how do I get around this?
Reply With Quote
  #2  
Old 07-30-2014, 02:35 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,461
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())
Reply With Quote
  #3  
Old 07-30-2014, 02:38 PM
lawry2 lawry2 is offline
Member
 
Join Date: Jul 2014
Posts: 2
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.
Reply With Quote
  #4  
Old 07-30-2014, 02:51 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,461
Vizard's task functions are implemented using Python generators which use yield statements.
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
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


All times are GMT -7. The time now is 08:45 PM.


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