PDA

View Full Version : Wand triggers event


Samuli
09-02-2015, 03:29 AM
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:
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,onHighlig ht)

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?

Samuli
09-02-2015, 04:32 AM
The code is run with ppt-tracking, Oculus DK2 and wand. The error message that the code produces is as follows: 'trying serial 3
Wand: input buffer not flushed
(Make sure port name is valid and it has not been opened by another program)'.