Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Difference in VR API 2.0 tracking matrix

LeviathanLevi
Contributor

Difference in VR API 2.0 tracking matrix

LeviathanLevi
Contributor
Contributor

I have some old VRED scripts that used the VR API 1.0 to let you move a node around with the touchpad just on the X and Y axis. It looked kinda like this:

def translate(self, speed, dirVector):
        if self.allowMove:
            current = getTransformNodeTranslation(self.moveNode, True)
            dist = speed * self.MOVE_SPEED
            newX = current.x() - dirVector.x() * dist
            newY = current.y() - dirVector.y() * dist
            setTransformNodeTranslation(self.moveNode, newX, newY, current.z(), True)
 
def controllerMoved(self, controller):
    touch = controller.getTouchpadPosition()
    controller.getWorldMatrix()
    mover.translate(touch.y(), Vec3f(matrix[2], matrix[6], 0))
    mover.translate(-touch.x(), Vec3f(matrix[0], matrix[4], 0))

controller.connectSignal('controllerMoved', controls.controllerMoved, controller0)

 I'm re-writing this script with VR API 2.0 however instead of controller.getWorldMatrix() I use device.getTrackingMatrix(). I'm not sure what the difference between these two 4x4Matrices is and how it's changed with new version of VRED

    def touchpadMove(self, device):
        touch = device.getButtonState("Touchpad").getPosition()
        matrix = device.getTrackingMatrix() #V2.0
        mover.translate(-touch.y(), Vec3f(matrix[0,2], matrix[1,2], 0)) # matrix values not the same
        mover.translate(touch.x(), Vec3f(matrix[0,0], matrix[1,0], 0))

My current understanding is .getTrackingMatrix() is relative to the HMD but .getWorldMatrix() is tied to the world origin. Is there a way for me to get the controller matrix relative to the world? Any insights into how these two method calls are different would be much appreciated.  

 

Cheers!

0 Likes
Reply
Accepted solutions (1)
406 Views
2 Replies
Replies (2)

sinje_thiedemann
Autodesk
Autodesk
Accepted solution

Hi,

this should give you the world transform of the device:

matrix = device.getNode().getWorldTransform()

 

LeviathanLevi
Contributor
Contributor
Thanks so much, that's exactly what I was looking for
0 Likes