WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 08-25-2009, 11:38 AM
vissimutah vissimutah is offline
Member
 
Join Date: Aug 2009
Posts: 2
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?
Reply With Quote
  #2  
Old 08-25-2009, 12:26 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
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)
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
writing joystick position to a data file Saz Vizard 3 12-17-2008 05:18 AM
default start position erchrastil Vizard 2 06-23-2008 08:15 AM
position of html-file on screen active_world Vizard 1 05-16-2008 07:24 PM
Avatar always returns in initial position pattie Vizard 2 08-31-2006 08:15 PM
Get position data in an own little program Researcher Precision Position Tracker (PPT) 2 02-01-2006 02:55 AM


All times are GMT -7. The time now is 03:53 PM.


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