WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Using highlighter tool with wand (https://forum.worldviz.com/showthread.php?t=5509)

Samuli 09-24-2015 01:08 AM

Using highlighter tool with wand
 
Hi,
I'm trying to convert WorldViz Highlighter tool example code (http://docs.worldviz.com/vizard/Tools_Highlighter.htm) into a script that uses wand as input (rather than mouse scrollwheel) and changes texture of an object. Here's the code:
Code:

import viz
import vizfx
import vizconnect
import vizact
import vizshape

viz.antialias = 4

viz.fullscreen = 1
viz.clearcolor = (0.5, 0.5, 0.5 )

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

#Add wand
wand= vizconnect.getTracker('r_hand_tracker').getNode3d()
wandInput=vizconnect.getInput('r_hand_tracker')
#Add a sky with an environment map
env = viz.add(viz.ENVIRONMENT_MAP, 'sky.jpg')
dome = viz.add('skydome.dlc')
dome.texture(env)

#Add showroom osgb file
showroom=viz.add('Showroom1.osgb')


for window in viz.getWindowList():
                window.getView().getHeadLight().disable()

#Add video texture
video=viz.addVideo('VisualisationDemoVideo_v2.mov')
video.play()
video.loop()
videowall=showroom.getChild('projection.002')
videowall.texture(video)

#Get a handle to a texture
texture1=viz.addTexture('VisualisationPic.png')

#Get and set highlighter tool
from tools import highlighter
tool=highlighter.Highlighter(highlightOnCollision=False,highlightMode=highlighter.MODE_OUTLINE)
tool.setItems([videowall])

viewGroup=viz.addGroup()
viewGroupLink=viz.link(viz.MainView,viewGroup)
viewGroupLink.preTrans([0, 0, 1])
arrow = vizshape.addArrow(length=0.2, color = viz.ORANGE,parent=viewGroup)
arrowLink = viz.link(wand,arrow,mask=viz.LINK_ORI)
arrowLink.postMultLinkable(viz.MainView)
viz.link(arrowLink,tool)
 
def updateHighlighter(tool):
 
    tool.highlight()

tool.setUpdateFunction(updateHighlighter)

def onHighlight(e):

    if e.new == videowall:
        print 'videowall is highlighted'
        tex1=videowall.getTexture()
        if tex1==video:
            print 'change'
            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)

We use wand 2014 local with PPT tracking.
The above mentioned code works, but not the way I want it to work. The beam of the highlighter tool starts from a fixed point and it doesn't follow the main view. How could the beam start point be main view and how would the target follow the wand?

Jeff 09-24-2015 12:38 PM

Quote:

How could the beam start point be main view and how would the target follow the wand?
Are you saying you want the line to start at the viewpoint location and finish at the location the wand is pointing to? If so, this is not possible with the highlighter tool. The attachment point of the highlighter determines both it's direction and starting point.

Samuli 09-24-2015 12:50 PM

Yes, that's exactly what I'm saying. Unity 3d has for example raycasting system from main camera point to a certain direction. That's easier to program with. Is there any other class/function in Vizard to use in this case instead of highlighter tool? How does the attachment point determine technically the direction and starting point?


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

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