WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 11-17-2007, 06:24 AM
Murilo Murilo is offline
Member
 
Join Date: Nov 2007
Posts: 2
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
Reply With Quote
  #2  
Old 11-17-2007, 06:30 AM
Murilo Murilo is offline
Member
 
Join Date: Nov 2007
Posts: 2
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')
Reply With Quote
  #3  
Old 11-19-2007, 09:11 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
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.
Reply With Quote
Reply


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Visible and alpha commands mjabon Vizard 1 08-27-2007 09:21 AM
texblend or visible for multiple textures vizmaster Vizard 10 02-14-2007 03:50 PM
on/off button bailenson Vizard 1 09-28-2004 05:13 PM


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


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