PDA

View Full Version : Hotspots and Video


eirc
01-27-2008, 11:59 AM
Hello,

I don't know if it's a bug but just using viz.addVideo in a world screws up the hotspots. The hotspot code below is a working mix from two other posts and I added the two commented blocks. Uncomment each one and see for yourself.

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)

import math
viz.startlayer(viz.LINES)
viz.linewidth(3)
viz.vertexcolor(viz.RED)
viz.vertex(HOTSPOT_X,0,HOTSPOT_Z)
viz.vertex(HOTSPOT_X,2,HOTSPOT_Z)
viz.startlayer(viz.LINE_LOOP)
for a in range(0,360,10):
x = math.sin(viz.radians(a))*RADIUS
z = math.cos(viz.radians(a))*RADIUS
viz.vertex(x+HOTSPOT_X,0.1,z+HOTSPOT_Z)
viz.endlayer()

# uncomment here and:
# enter activates at the beginning
# leave activates at your first move (anywhere)
#viz.addVideo('mona.mpg')

HotspotClass(0,1)
HotspotClass(2,3)

# uncomment here and:
# both enter and leave activate when you enter the hotspot
# but never again
#viz.addVideo('mona.mpg')

farshizzo
01-28-2008, 09:26 AM
I ran your sample script with the uncommented lines and everything worked fine. Were you able to reproduce the problem with this exact script?

eirc
01-28-2008, 09:49 AM
yeah and I still can't get it to wok :S
could this have something to have with the version I am running?
it's 3.00.2155
or that it's the trial version?

(you sure you uncommented the addvideo lines? :P)

farshizzo
01-29-2008, 08:58 AM
I commented out each one individually and I also uncommented both lines, and they all worked fine. The version you have should work fine, the latest version is 3.00.2317.