PDA

View Full Version : Coldspots?


codexter
02-20-2007, 02:58 PM
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.

farshizzo
02-20-2007, 03:11 PM
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: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.