WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 04-10-2009, 02:43 PM
whj whj is offline
Member
 
Join Date: Apr 2008
Posts: 60
Oh!!! I always thought the second argument of vizact.ontimer2 was the number of times to active the timer. Sorry about that. I should set it to 0. I'll correct it and see what happened....

Thanks a lot!
Reply With Quote
  #2  
Old 04-10-2009, 03:44 PM
whj whj is offline
Member
 
Join Date: Apr 2008
Posts: 60
Thank you, Jeff. It works!

Now I make a little change on the reset part. I would like to reset the object (duck or ball) right before being played. But I got the following error:

Traceback (most recent call last):
File "C:\Program Files\WorldViz\Vizard30/python\vizact.py", line 2980, in __ontimer
val = event.call()
File "C:\Program Files\WorldViz\Vizard30/python\vizact.py", line 2803, in _callStatic
return self.func(*self.args,**self.kwargs)
TypeError: 'NoneType' object is not callable



Could you please help me find the problem again? Thanks!


Code:
import viz
import math
viz.go()


viz.clearcolor(0.5,0.5,1)
viz.add('tut_ground.wrl')

#Add 2 models.
#One is a ball, the other is a duck.
model = []
ball = viz.add('ball.wrl')
duck = viz.add('duck.cfg')
model.append(ball)
model.append(duck)


#Add the path.
#path[0] is for the ball, path[1] is for the duck.
path = [] 
for x in range(2):
	pa = viz.addAnimationPath()
	path.append(pa)

positions = [ [5,1,6], [0,1,3], [-150,1,6] ]
for x in range(len(positions)):
    cp = viz.addControlPoint()
    cp.setPosition(positions[x])
    path[0].add(cp,x+1)
    path[1].add(cp,x+1)

for x in range(2):
	path[x].constantspeed(viz.ON,10)
	path[x].loop(viz.OFF)
	path[x].translatemode(viz.BEZIER)
	path[x].setAutoRotate(viz.ON)

#Link the model to a path.
ball.link(path[0])
duck.link(path[1])



def mytimer(num):
	pass

def reset(k):
	path[k].pause()
	path[k].reset()
	model[k].setPosition(0,0,0)
	

#The following arrays means:
#Firstly: duck start to move
#After 3 seconds, ball start to move
#After another 3 seconds, ball start to move again
time_to_go = [0, 3, 6] 
object = [1, 0, 0] #1 means duck, 0 means ball


#Create an array of timer action
for x in range(len(object)):
	if (x == 0) : 
		path[object[0]].play()
	else: 
		wait = time_to_go[x] - time_to_go[0]
		vizact.ontimer2(wait, 0, reset(object[x]))
		vizact.ontimer2(wait+0.00001, 0, path[object[x]].play)
	

	
viz.callback(viz.TIMER_EVENT,mytimer)
viz.starttimer(0,0,viz.PERPETUAL)
Reply With Quote
  #3  
Old 04-11-2009, 06:55 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
The error is in this line
Code:
vizact.ontimer2(wait, 0, reset(object[x]))
You need to pass the argument to your function like this
Code:
vizact.ontimer2(wait, 0, reset, object[x])
Reply With Quote
  #4  
Old 04-12-2009, 08:48 AM
whj whj is offline
Member
 
Join Date: Apr 2008
Posts: 60
Thank you so much for your help, especially at weekend.
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
array problem mrvr Vizard 8 03-10-2014 09:20 PM
Sound Looping Problem JMOwens Vizard 4 09-29-2010 09:42 PM
Timer speed Jerry Vizard 1 12-08-2006 11:01 AM
problem with female animations vmonkey Vizard 1 10-07-2005 10:36 AM
Weird lagging/choppiness when avatars perform actions vjonshih Vizard 8 11-30-2004 04:08 PM


All times are GMT -7. The time now is 01:22 PM.


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