WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   multiple timer trouble (https://forum.worldviz.com/showthread.php?t=330)

exhale 04-25-2005 01:25 AM

multiple timer trouble
 
1 Attachment(s)
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

farshizzo 04-25-2005 10:00 AM

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)


exhale 04-26-2005 12:21 AM

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


All times are GMT -7. The time now is 10:31 PM.

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