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)
###########