WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Distance or position based event? (https://forum.worldviz.com/showthread.php?t=2227)

vissimutah 08-25-2009 11:38 AM

Distance or position based event?
 
We're trying to play a sound when the viewpoint reaches a certain point in the virtual environment. Do we have to register a custom event to do this? Is there a way to use a loop without freezing the program?

farshizzo 08-25-2009 12:26 PM

It seems like you simply want to run some code every frame. In that case you can register a timer function, which will be called every frame. Here is an example that plays a sound when the Z position of the view passes 3 meters:
Code:

import viz
viz.go()

viz.add('tut_ground.wrl')

def CheckView():
        """Plays a sound when Z position of view is greater than 3"""
        x,y,z = viz.MainView.getPosition()
        if z > 3:
                # Play sound and unregister timer function
                viz.playsound('elaugh1.wav')
                return vizact.EventRemove
vizact.ontimer(0,CheckView)



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

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