WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Visible On/Off for a "menu" (https://forum.worldviz.com/showthread.php?t=1275)

Murilo 11-17-2007 06:24 AM

Visible On/Off for a "menu"
 
Hi... I'm trying to make visible or not pushing a key for a future menu...

Code:

import viz
viz.go()

menuScene = viz.addScene()

menuView = viz.addView()
menuView.setScene(menuScene)

menuWindow = viz.addWindow()
menuWindow.setClearMask(viz.GL_DEPTH_BUFFER_BIT)
menuWindow.setPosition(0,1)
menuWindow.setSize(1,1)
menuWindow.viewpoint(menuView)

#Create root node for menu quads
menu = viz.addGroup(scene = menuScene)
menu.translate(0,1.8,5)

#Create texture to apply to quads
tex = viz.addTexture('ball.jpg')

quad = viz.addTexQuad(parent=menu)
quad.texture(tex)
quad.alpha(0.7)

       
vizact.onkeydown( 'a', menuScene.visible(viz.ON) )
vizact.onkeydown( 's', menuScene.visible(viz.OFF) )



viz.add('gallery.ive')

When I push 'a' or 's', show this:
Traceback (most recent call last):
File "C:\Arquivos de programas\WorldViz\Vizard30/python\vizact.py", line 2667, in __onkeydown
self._callGroup(self.__keydownmap[key])
File "C:\Arquivos de programas\WorldViz\Vizard30/python\vizact.py", line 2619, in _callGroup
val = e.call(arg)
File "C:\Arquivos de programas\WorldViz\Vizard30/python\vizact.py", line 2470, in _callStatic
return self.func(*self.args,**self.kwargs)
TypeError: 'NoneType' object is not callable

What can I do!?
thanks,
Murilo

Murilo 11-17-2007 06:30 AM

I found a way!

Code:

import viz
viz.go()

menuScene = viz.addScene()

menuView = viz.addView()
menuView.setScene(menuScene)

menuWindow = viz.addWindow()
menuWindow.setClearMask(viz.GL_DEPTH_BUFFER_BIT)
menuWindow.setPosition(0,1)
menuWindow.setSize(1,1)
menuWindow.viewpoint(menuView)

#Create root node for menu quads
menu = viz.addGroup(scene = menuScene)
menu.translate(0,1.8,5)

#Create texture to apply to quads
tex = viz.addTexture('ball.jpg')

quad = viz.addTexQuad(parent=menu)
quad.texture(tex)
quad.alpha(0.7)


def press(key):
        if key == 'a':
                menuScene.visible(viz.ON)
        if key == 'b':
                menuScene.visible(viz.OFF)
viz.callback(viz.KEYBOARD_EVENT, press)

viz.add('gallery.ive')


farshizzo 11-19-2007 09:11 AM

The problem with the original code was that you were using the vizact.onkeydown command incorrectly. It should be:
Code:

vizact.onkeydown( 'a', menuScene.visible,viz.ON)
vizact.onkeydown( 's', menuScene.visible,viz.OFF)

The second parameter to the command needs to be a function object. All other parameters will be passed to the function when the specified key is pressed.


All times are GMT -7. The time now is 01:06 PM.

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