WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 07-18-2013, 11:37 PM
javadi javadi is offline
Member
 
Join Date: Mar 2013
Location: London
Posts: 33
Simultaneous Actions on Multiple Objects

Hi,

I am wondering how I can run actions on multiple objects at the same time. It is a very basic task, but I cannot find any solution to it. The structure of my code is as follows: I have a scheduler that calls function MainProcedure. There I want to for example spin two objects ('Object1' & 'Object2') simultaneously. A part of my code goes below

Code:
if __name__ == "__main__":
	...
	viztask.schedule(MainProcedure())
	...

def MainProcedure():
	...

	TempActionSpinObject1 = vizact.spinTo(euler = [90, 0, 0], speed = SpeedTurn)
	TempActionSpinObject2 = vizact.spinTo(euler = [0, 90, 0], speed = SpeedTurn)

	yield viztask.addAction(Object1, TempActionSpinObject1)
	yield viztask.addAction(Object2, TempActionSpinObject2)

	...
The code as it stands now, first spins the first object and then the second one. I tried the following code (removing 'yield') to test whether the objects spins together, but it turned out that the first objects doesn't spin at all, but the second object spins fine.

Code:
	viztask.addAction(Object1, TempActionSpinObject1)
	yield viztask.addAction(Object2, TempActionSpinObject2)
I thought perhaps it has something to do with 'pool' numbers. I thought perhaps the 2nd action overwrites the first one, if the pool numbers are both set to default (zero). so, I tried the following code, but again no luck.

Code:
	viztask.addAction(Object1, TempActionSpinObject1, pool = 0)
	yield viztask.addAction(Object2, TempActionSpinObject2, pool = 1)
I know about vizact.sequence and vizact.parallel. As far as I understand they act on one object. Any idea how to solve this problem? Very many thanks.

Greetings
Amir
Reply With Quote
  #2  
Old 07-19-2013, 10:43 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
You can use viztask.waitAll to wait for a specified set of actions to complete. Here is an example:
Code:
import viz
import vizact
import viztask
viz.go()

Object1 = viz.add('beachball.osgb',pos=(-1,2,5))
Object2 = viz.add('soccerball.osgb',pos=(1,2,5))

def MainTask():

	yield viztask.waitKeyDown(' ')

	spin1 = vizact.spinTo(euler=[90,0,0], speed=45)
	spin2 = vizact.spinTo(euler=[0,90,0], speed=45)

	waitSpin1 = viztask.waitTask( viztask.addAction(Object1, spin1) )
	waitSpin2 = viztask.waitTask( viztask.addAction(Object2, spin2) )

	yield viztask.waitAll( [waitSpin1, waitSpin2] )

	print 'finished'

viztask.schedule( MainTask() )
Reply With Quote
  #3  
Old 07-19-2013, 04:54 PM
javadi javadi is offline
Member
 
Join Date: Mar 2013
Location: London
Posts: 33
Hi,

Very many thanks for your detailed reply. Very helpful.

Greetings
Amir
Reply With Quote
Reply


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
Transparency on multiple objects NASA GRC Vizard 0 03-15-2010 01:46 PM
removing multiple objects durf Vizard 7 08-05-2009 10:15 AM
run multiple actions simultaneously durf Vizard 1 05-08-2009 01:17 PM
multiple objects durf Vizard 1 04-10-2009 02:42 PM
Problems with making multiple objects from one .wrl? mjabon Vizard 3 07-10-2007 02:23 PM


All times are GMT -7. The time now is 05:19 PM.


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