View Single Post
  #1  
Old 09-02-2015, 02:29 AM
Samuli Samuli is offline
Member
 
Join Date: Aug 2015
Posts: 15
Wand triggers event

Hi,
We're trying to implement an event triggered by wand key press, that changes a texture of an object that the wand points to. It doesn't work for now. Here's the code:
Code:
import viz
import vizfx
import vizconnect
import vizact
viz.antialias = 4
# Lines beginning with the '#' symbol will be treated as comments
viz.fullscreen = 1
viz.clearcolor = (0.5, 0.5, 0.5 )
#viz.go()

if __name__ == "__main__":
	vizconnect.go('./vizconnect_config.py')
	viz.MainView.getHeadLight().disable()
else:
	vizconnect.go('./multiscript_vizconnect_config.py')

#Add wand
ppt=viz.add('ppt.dle')
wand = ppt.addWand(1)

#Add a sky with an environment map
env = viz.add(viz.ENVIRONMENT_MAP, 'sky.jpg')
dome = viz.add('skydome.dlc')
dome.texture(env)
showroom=viz.add('Showroom1.osgb')

#showroom.setPosition(3,-6,3)
for window in viz.getWindowList():
		window.getView().getHeadLight().disable()

video=viz.addVideo('Visvid_ver_2.mp4')
video.play()
video.loop()
texture1=viz.addTexture('VisualisationPic.png')
videowall=showroom.getChild('projection.002')
videowall.texture(video)

from tools import highlighter
tool=highlighter.Highlighter()
tool.setItems([videowall])

viz.link(wand,tool)

#def onTrigger():
#    print 'Trigger pressed'
#    updateHighlighter(tool)
  
def updateHighlighter(tool):
    #state = viz.mouse.getState()
   
    tool.highlight()
        
    
vizact.onsensordown(wand, ppt.BUTTON_UP, updateHighlighter)


tool.setUpdateFunction(updateHighlighter)

def onHighlight(e):
    if e.new == videowall:
        print 'videowall is highlighted'
        if videowall.texture==video:
            videowall.texture(texture1)
        else:
            videowall.texture(video)
    
viz.callback(highlighter.HIGHLIGHT_EVENT,onHighlight)

showroom.disable(viz.LIGHTING)
headlight=viz.MainView.getHeadLight()
headlight.disable()
viz.MainView.setPosition(-5,2,-5)
light=viz.addLight()
light.position(0,2,0,1)
light.spread(180)
#light.disable()
light.color(0.2,0.2,0.2)
light.quadraticAttenuation(.04)
light.intensity(100)
pointlight=vizfx.addPointLight(color=viz.WHITE,pos=(5,0,5))
pointlight.intensity(.5)
pointlight.quadraticAttenuation(.01)
#pointlight.disable()
I would appreciate if someone would know how to help with this issue.
Another issue is that a videotexture is not visible (just white background), only the sound of the video is heard. Why?
Reply With Quote