WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #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
 


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 11:42 AM.


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