WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 02-20-2007, 02:58 PM
codexter codexter is offline
Member
 
Join Date: Feb 2007
Posts: 9
Coldspots?

Hello,

I'm having a problem inserting hotspots under an event class. Is this even possible? I want to be able to automatically create a hotspot for every item in an event class, but vizard wouldn't recognize self.starthotspot. I managed to go around this by manually creating a viz.starthotspot after I created instances for the event class, but this method is lengthy. Any tips on what I'm doing wrong, or is there no hotspot creation code available under an event class?

Thanks.
Reply With Quote
  #2  
Old 02-20-2007, 03:11 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
An event class should be able to handle hotspots. However, unlike timers, hotspot IDs are not unique to each class, but are shared globally. So you need to make sure each event class has its own unique hotspot ID. Here is a sample script that shows how to use event classes with hotspots:
Code:
import viz
viz.go()

viz.add('tut_ground.wrl')

#Declare Radius of hotspot
RADIUS = 1

#Declare position of hotspot
HOTSPOT_X = 0
HOTSPOT_Z = 3

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

HotspotClass(0,1)
HotspotClass(2,3)
Let me know if I misunderstood your question.
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


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


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