WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 04-08-2005, 11:19 AM
Adam Adam is offline
Member
 
Join Date: Apr 2005
Posts: 13
Nested Hotspots. Is it possible?

Hi All,

I was wondering if it was possible to have nested hotspots? (as the title of the thread indicates)

My plan was to create a zone of safe travel in the lab that would monitor a users position, and give them a warning when they exit the safe zone (which would be specified by a rectangle hotspot out).

Additionally, I wanted to make use of a circular hotspot, within that safe zone of travel. Is this possible?

I have had no luck as of yet getting both to work in conjunction. I realize I could achieve the same effect with if statements inside a timer that checks current position against the boundaries of the safe zone, but this is not a very elegant solution.

I really just need to get this to work however, and will resort to any means necessary to carry off the desired effect.

The code I have tried so far is as follows: (pardon the formatting)

import viz
viz.go()

SAFE = 1
UNSAFE = 2
TARGET = 3

viz.clearcolor(1,1,1)

def handlemyhotspots(id,x,y,z):

if id == SAFE:
print 'inside safe zone'
viz.clearcolor(1,1,1)
viz.starthotspot(UNSAFE,viz.RECTANGLE_HOTSPOT_OUT, 0,3,2.4,6)

elif id == UNSAFE:
print 'outside safe zone'
viz.clearcolor(0,0,0)
viz.starthotspot(SAFE,viz.RECTANGLE_HOTSPOT_IN,0,3 ,2.4,6)

elif id == TARGET:
print 'at target'

viz.callback(viz.HOTSPOT_EVENT, handlemyhotspots)

viz.starthotspot(UNSAFE,viz.RECTANGLE_HOTSPOT_OUT, 0,3,2.4,6)
viz.starthotspot(TARGET,viz.CIRCLE_HOTSPOT_IN,0,3, .5)

I would appreciate any assistance you can provide with regard to my question.

Adam
Reply With Quote
  #2  
Old 04-08-2005, 11:45 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi,

I tried out your script and it worked for me. I've modified your script so that it draws the area of the circular hotspot. This should make it easier for you to debug. Let me know if you still can't get it working.
Code:
import viz
viz.go()

SAFE = 1
UNSAFE = 2
TARGET = 3

viz.add('tut_ground.wrl')

CIRCLE_X = 0
CIRCLE_Z = 3
CIRCLE_RADIUS = 0.5

def handlemyhotspots(id,x,y,z):

	if id == SAFE:
		print 'inside safe zone'
		viz.clearcolor(1,1,1)
		viz.starthotspot(UNSAFE,viz.RECTANGLE_HOTSPOT_OUT,0,3,2.4,6)

	elif id == UNSAFE:
		print 'outside safe zone'
		viz.clearcolor(0,0,0)
		viz.starthotspot(SAFE,viz.RECTANGLE_HOTSPOT_IN,0,3,2.4,6)

	elif id == TARGET:
		print 'at target'

viz.callback(viz.HOTSPOT_EVENT, handlemyhotspots)
viz.starthotspot(UNSAFE,viz.RECTANGLE_HOTSPOT_OUT,0,3,2.4,6)
viz.starthotspot(TARGET,viz.CIRCLE_HOTSPOT_IN,CIRCLE_X,CIRCLE_Z,CIRCLE_RADIUS) 

import math
viz.startlayer(viz.LINES)
viz.linewidth(3)
viz.vertexcolor(viz.RED)
viz.vertex(CIRCLE_X,0,CIRCLE_Z)
viz.vertex(CIRCLE_X,2,CIRCLE_Z)
viz.startlayer(viz.LINE_LOOP)
for a in range(0,360,10):
	x = math.sin(viz.radians(a))*CIRCLE_RADIUS
	z = math.cos(viz.radians(a))*CIRCLE_RADIUS
	viz.vertex(x+CIRCLE_X,0.1,z+CIRCLE_Z)
viz.endlayer()
Reply With Quote
  #3  
Old 04-08-2005, 12:21 PM
Adam Adam is offline
Member
 
Join Date: Apr 2005
Posts: 13
Thanks for the quick reply.

It works just fine now, I haven't made any changes from before though.

This seems like it will be a good solution to my problem.

Thanks Again,

Adam
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 04:50 PM.


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