WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   vizinfo in multiple scenes (https://forum.worldviz.com/showthread.php?t=284)

vadrian 01-30-2005 06:20 PM

vizinfo in multiple scenes
 
hi, im trying to use the vizinfo module but the boxes only seem to appear in scene 1.
how can I add an info box to a different scene (while in another one)?
or how can I make a box appear after calling viz.scene(#>1) ?

thanks

farshizzo 01-31-2005 10:06 AM

Hi,

Do you want the same box in different scenes? If so, try the following:
Code:

info = vizinfo.add(....)
#Duplicate the box onto scene 2
info._group.duplicate(2)

If you have an older version then try this instead:
Code:

info.group.duplicate(2)
I think you asked a question a few months ago about adding checkboxes and sliders to the vizinfo box. Version 2.5 of Vizard now allows you to do this, you might want to check it out.

vadrian 02-02-2005 01:10 PM

how should i do it if I want to add multiple vizinfos into different scenes (at least 2 per scene).

also, is there a way I can check the version number of vizard so i can send an error message if the user tries to run a script in an older version?

farshizzo 02-02-2005 01:16 PM

Hi,

To add the vizinfo box to a different scene try the following:
Code:

#Place info box in scene 2
info._group.parent(viz.WORLD,2)

The following command will return a string that specifies the current version of Vizard:
Code:

version = viz.version()

vadrian 02-02-2005 02:11 PM

so i tried what you suggested, but it doesn't seem to work. i even made a little test script:

Code:

import viz
import vizinfo

viz.go()
viz.clearcolor(.5,.5,.5)

info = vizinfo.add('message')

scene = 1
def onkeydown(key):
        global info, scene
        #The keyboard button 'key' is being pressed
        if key == ' ':
                scene += 1
                viz.scene(scene)
       
        if key == 'd':
                info._group.duplicate(scene)
               
        if key == 'm':
                info._group.parent(viz.WORLD, scene)

viz.callback(viz.KEYDOWN_EVENT,onkeydown)


farshizzo 02-02-2005 02:20 PM

My bad, it should be:
Code:

info._group.parent(viz.SCREEN, scene)

vadrian 02-02-2005 08:21 PM

ok, so the parent trick works (maybe this should be added as a feature in future versions?). now i get an error when i try to scale vizinfo. what i have is this:

Code:

INFO_SIZE = [0.5,0.5]
info = vizinfo.add('blah')
info.scale(INFO_SIZE)

what I get is this:
Code:

Traceback (most recent call last):
    File "", line 12, in ?
    File "context_recall_02.py", line 123, in ?
        infoBox.scale(INFO_SIZE)
TypeError: scale() takes exactly 3 arguments (2 given)


farshizzo 02-03-2005 10:19 AM

The older version of vizinfo didn't support passing lists to the scale function. You will have to pass each value individually:
Code:

info.scale(INFO_SIZE[0],INFO_SIZE[1])
or you could also do the following:
Code:

info.scale(*INFO_SIZE)

vadrian 02-03-2005 10:32 AM

i have both 2.5 and the previous version (2.1?) installed. I was getting that error while using 2.5. Is it possible vizard was grabbing the vizinfo from the older version?

also, random python question. is there a python equivalent to:

x = (isBoolean)? y:z

i have a lot of checks, and i'm tired of repeating the 4 line if/else template ;)

farshizzo 02-03-2005 10:49 AM

It might be possible. Startup 2.5 and check the value of the following in the interactive window:
Code:

viz._WIN_VIZ_PATH
It should point to "C:\Program Files\Vizard25" or wherever you installed 2.5

Python doesn't support the one line if/else. If you can guarentee that the value of the boolean will always be either 0 or 1 you could do the following:
Code:

x = [z,y][isBoolean]
Otherwise you could create your own function:
Code:

def ifelse(boolean,trueVal,falseVal):
        if boolean:
                return trueVal
        return falseVal

x = ifelse(isBoolean,y,z)



All times are GMT -7. The time now is 10:05 PM.

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