WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Nested Hotspots. Is it possible? (https://forum.worldviz.com/showthread.php?t=319)

Adam 04-08-2005 11:19 AM

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

farshizzo 04-08-2005 11:45 AM

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()


Adam 04-08-2005 12:21 PM

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


All times are GMT -7. The time now is 09:02 AM.

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