View Single Post
  #2  
Old 03-11-2005, 11:03 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
You can use hotspots to detect when the viewpoint has entered or left a given area. Here is a simple script that creates a circular hotspot at the location (0,3) with radius 1.
Code:
import viz
viz.go()

viz.add('tut_ground.wrl')

#Declare some hotspot IDs
ENTER = 0
LEAVE = 1

#Declare Radius of hotspot
RADIUS = 1

#Declare position of hotspot
HOTSPOT_X = 0
HOTSPOT_Z = 3

def onhotspot(id,x,y,z):
	if id == ENTER:
		print 'Entered hotspot'
		#Create a hotspot that will be triggered when we leave the circle
		viz.starthotspot(LEAVE,viz.CIRCLE_HOTSPOT_OUT,HOTSPOT_X,HOTSPOT_Z,RADIUS)
	elif id == LEAVE:
		print 'Leaving hotspot'
		#Create a hotspot that will be triggered when we enter the circle
		viz.starthotspot(ENTER,viz.CIRCLE_HOTSPOT_IN,HOTSPOT_X,HOTSPOT_Z,RADIUS)

viz.callback(viz.HOTSPOT_EVENT,onhotspot)

#Create a hotspot that will be triggered when we enter the circle
viz.starthotspot(ENTER,viz.CIRCLE_HOTSPOT_IN,HOTSPOT_X,HOTSPOT_Z,RADIUS)
Reply With Quote