WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 07-30-2014, 11:49 AM
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, 01:35 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
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, 01: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, 01:51 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
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 12:07 PM
Trouble transitioning from one vizard DBurks2818 Vizard 3 04-28-2009 02:46 PM
Collision trouble digitaldarklord Vizard 6 09-16-2008 04:04 PM
Trouble Exporting to .ive le perdusier Vizard 2 11-27-2007 04:31 PM
trouble with winviz.exe bnord Vizard 4 09-21-2006 04:22 AM


All times are GMT -7. The time now is 04:58 PM.


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