View Single Post
  #1  
Old 01-27-2008, 11:59 AM
eirc eirc is offline
Member
 
Join Date: Jan 2008
Posts: 2
Hotspots and Video

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.

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)

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')
Reply With Quote