Vive Tracker Matrix affected by HMD Position?

Vive Tracker Matrix affected by HMD Position?

chaaseLTH9X
Enthusiast Enthusiast
1,201 Views
4 Replies
Message 1 of 5

Vive Tracker Matrix affected by HMD Position?

chaaseLTH9X
Enthusiast
Enthusiast

Hi all,

 

I'm trying to control the orientation of a texture on a material based on the angle of a Vive tracker.  The script below works well for that, but there is an unexpected behavior.  When I turn my head while wearing the HMD, the texture rotates, even if the Vive tracker is not moving.  In the attachments, img1 is looking straight-on, and img2 is with the HMD turned to the right.  Any ideas?

 

Thanks,

CH

 

import math

 

tracker = vrDeviceService.getVRDevice('tracker-1')
tracker.enableRay('Z')

myDial = findNode('DialNode',True)
myMatl = myDial.getMaterial()
myTex = vrFieldAccess(myMatl.fields().getFieldContainer('colorComponentData'))
myComp = vrFieldAccess(myTex.getFieldContainer('diffuseComponent'))

def adjustDial():
   myMatx = tracker.getTrackingMatrix()
   rotXangle = math.atan2(-myMatx.row(1).z(), myMatx.row(2).z())
   sinXangle = math.sin(rotXangle)
   cosXangle = math.cos(rotXangle)
   rotZangle = math.atan2(cosXangle * myMatx.row(1).x() + sinXangle * myMatx.row(2).x(), cosXangle * myMatx.row(1).y() + sinXangle * myMatx.row(2).y())
   myComp.setReal32('rotate',math.degrees(rotZangle)+90)

 

tracker.signal().moved.connect(adjustDial)

0 Likes
Accepted solutions (1)
1,202 Views
4 Replies
Replies (4)
Message 2 of 5

CGBenner
Community Manager
Community Manager

@chaaseLTH9X 

 

Hello!  Do you still need assistance with this question?

Did you find a post helpful? Then feel free to give likes to these posts!
Did your question get successfully answered? Then just click on the 'Accept solution' button.  Thanks and Enjoy!



Chris Benner

Community Manager - NAMER / D&M


0 Likes
Message 3 of 5

chaaseLTH9X
Enthusiast
Enthusiast

Hi Chris,

 

Yes, I could still use some help!

 

Thanks,

Charles

0 Likes
Message 4 of 5

CGBenner
Community Manager
Community Manager

@michael_nikelsky @Christian_Garimberti @seiferp 

Gentlemen, do any of you have any thoughts on this question?  Thank you all in advance (I know nothing about VRED!)  🙂

Did you find a post helpful? Then feel free to give likes to these posts!
Did your question get successfully answered? Then just click on the 'Accept solution' button.  Thanks and Enjoy!



Chris Benner

Community Manager - NAMER / D&M


0 Likes
Message 5 of 5

chaaseLTH9X
Enthusiast
Enthusiast
Accepted solution

I stumbled on the solution when looking at another forum thread.

 

Changing:

myMatx = tracker.getTrackingMatrix()

 

to:

myMatx = tracker.getNode().getWorldTransform()

 

Does the trick.  It turns out Vive pucks (and controllers, I think) have their tracking matrix tied to the HMD tracking matrix.