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!
Solved! Go to Solution.
Solved by sinje_thiedemann. Go to Solution.
Hi,
this should give you the world transform of the device:
matrix = device.getNode().getWorldTransform()
Can't find what you're looking for? Ask the community or share your knowledge.