WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rating: Thread Rating: 4 votes, 5.00 average. Display Modes
  #1  
Old 04-25-2005, 02:25 AM
exhale exhale is offline
Member
 
Join Date: Feb 2005
Posts: 19
multiple timer trouble

Hello,

I'm having trouble using multiple timers. One is for handling keyboard input to control the viewpoint.

The other is created when a hotspot is entered and is used to move a certain object at a certain rate.

The problem is, when i enter the hotspot, the infinite timer (used for keybcontrol) seems to call the function for moving the object (which is supposed to be run only 100 times), and it does not call the keyboard handling function.

So on entering hotspot, keyboard handling stops, and the object keeps moving. (while it should only do 100 steps).

(btw i used different ID's for both timers)

I included the script as an attachment.

thx in advance,

Kevin
Attached Files
File Type: txt 01.txt (2.5 KB, 2021 views)
Reply With Quote
  #2  
Old 04-25-2005, 11:00 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi Kevin,

You can only have one function registered with a timer callback at a time. What you will need to do is combine your mytimer and keybcontrols functions to look something like the following:
Code:
def mytimer(timerNum):
	if timerNum == 0:
		if viz.iskeydown(viz.KEY_UP):
			view.move(0,0,MOVE_SPEED*viz.elapsed(),viz.BODY_ORI)
		if viz.iskeydown(viz.KEY_DOWN):
			view.move(0,0,-MOVE_SPEED*viz.elapsed(),viz.BODY_ORI)
		if viz.iskeydown(viz.KEY_RIGHT):
			view.rotate(0,1,0,TURN_SPEED*viz.elapsed(),viz.BODY_ORI,viz.RELATIVE_WORLD)
		if viz.iskeydown(viz.KEY_LEFT):
			view.rotate(0,1,0,-TURN_SPEED*viz.elapsed(),viz.BODY_ORI,viz.RELATIVE_WORLD)
	elif timerNum == 1:
		pos = tbox.get(viz.POSITION) 
		z = pos[2] - 0.01
		print 'z: ', z
		tbox.translate(34,0,z)
Reply With Quote
  #3  
Old 04-26-2005, 01:21 AM
exhale exhale is offline
Member
 
Join Date: Feb 2005
Posts: 19
Hello,

Ow, so that's how the ID works.
I had tried a few things with it, but hadnt
got it to work.

Thank you a lot!

greets,

Kevin
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


All times are GMT -7. The time now is 02:24 PM.


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