WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Vive: trouble setting node as a child of the head (https://forum.worldviz.com/showthread.php?t=6112)

performlabrit 02-26-2018 08:49 AM

Vive: trouble setting node as a child of the head
 
Hello folks,

I'm trying to do a routine operation with the vive, and am having trouble. I would like to set a node (a vizshape sphere) in front of the head eye. One approach is to child the node to the mainview, or the head tracker. However, neither approach seems to work!

For example, if you use the standard vizconnect VIVE config and add the following code to main:

HTML Code:

import vizshape
ht = vizconnect.getRawTracker('head_tracker')
r = vizshape.addSphere(0.05, color = viz.RED)
r.setParent(ht)
r.setPosition([0,0,1]) # Doesn't work for any forward direction (e.g. [1,0,0])

It also doesn't work if I child it to the mainview.
Am I missing something?

Also, in the code above, note that the assumption is that the head is facing down Z in the model's local coordinate system. I'm not sure that this assumption is true (although, no other directions work either). What direction is "forward" and what direction "up" for the Vive?

Jeff 02-26-2018 07:55 PM

Try using the .setReferenceFrame command. Does this work for you?

performlabrit 02-28-2018 05:34 AM

Success with <node>.setReferenceFrame()
 
Thanks jeff! The following code worked...
HTML Code:

        import vizshape
        r = vizshape.addSphere(0.05, color = viz.RED)
        r.setReferenceFrame(viz.RF_VIEW)
        r.setPosition([0,0,1])


performlabrit 03-01-2018 07:41 AM

Problems continue. What's going on?
 
Sadly, my attempts to place a sphere along the gaze vector are still not behaving as expected. None of the parenting functions work, and viz.setRefrenceFrame is producing unpredictable results.

Here are two new attempts dropped into my vizconfig main function that uses the standard VIVE template. Neither work. Any advice from the peanut gallery?
HTML Code:


############# Attempt 1, what I thought would work...

        import vizshape
       
        IPD = viz.MainWindow.getIPD()

# It does seem that the right eye base is in the correct position and updates with head position
        rightEyeBase = vizshape.addSphere(0.05, color = viz.BLUE)
        rightEyeBase.setReferenceFrame(viz.RF_VIEW)
        rightEyeBase.setPosition([IPD/2,0,0])
        rightEyeBase.alpha(0.00)

link = viz.link(viz.MainView,rightEyeBase,viz.PRIORITY_SCENEGRAPH) # I tried with and without the link here
        link.setMask(viz.LINK_ORI)

        rightGazePoint = vizshape.addSphere(0.05, color = viz.YELLOW)
rightGazePoint.setReferenceFrame(rightEyeBase)
       
        smi = viz.add('smi_vive.dle')
        eyeTracker = smi.addEyeTracker()

        def updateGazeNode(vecLength = 3.0):
               
rDir = eyeTracker.getRightGazeDirection()
rightGazePoint.setPosition(rDir[0]*vecLength,rDir[1]*vecLength,rDir[2]*vecLength) 
               
        vizact.onupdate(viz.PRIORITY_LAST_UPDATE,updateGazeNode)

###########



############# Attempt 2, based on the example provided by Worldviz (smiViveExample.py)
## Note that this doesn't accoutn for the right eye offset.

        import vizshape
       
        IPD = viz.MainWindow.getIPD()
        rightEyeBase = vizshape.addSphere(0.05, color = viz.BLUE)
        rightEyeBase.setReferenceFrame(viz.RF_VIEW)
        rightEyeBase.setPosition([IPD/2,0,0])
        rightEyeBase.alpha(0.00)

        rightGazePoint = vizshape.addSphere(0.05, color = viz.YELLOW)
        #rightGazePoint.setReferenceFrame(rightEyeBase)
       
       
        smi = viz.add('smi_vive.dle')
        eyeTracker = smi.addEyeTracker()

        def updateGazeNode(vecLength = 3.0):
               
                gazeMat = eyeTracker.getMatrix()
                gazeMat.postMult(viz.MainView.getMatrix())
                rightGazePoint.setMatrix(gazeMat)
               
        vizact.onupdate(viz.PRIORITY_LAST_UPDATE,updateGazeNode)
###########



All times are GMT -7. The time now is 08:25 PM.

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