SteamVR Developer Hardware

SteamVR Developer Hardware

italiansc Jul 27, 2016 @ 10:29am
How to decompose the pose matrix?
the IVRCompositor::WaitGetPose() can return the pose matrix of hmd or controller device,I observe the 3x4 matrix,found the m03,m13,m23 is the translate parameters of device,the other seems to be the rotate parameters,so is it possible to decompose x/y/z rorate paramter from the remainder 3x3 matrix? or can i extract the pos/view/up parameters of "gluLookAt()" function from the pose matrix?
< >
Showing 1-3 of 3 comments
zoinks Jul 28, 2016 @ 12:42pm 
It's mathematically possible to derive the parameters that would go with the old gluLookAt but remember, you are not supposed to use that anymore, as the user controls the orientation of the camera at all times via the HMD. The 3x3 part is a set of orthogonal unit vectors that describe the orientation of the pose in the absolute coordinate system. So, it relates positions in the pose-local coordinate system to the absolute/world coordinate system. From openvr.h:

struct TrackedDevicePose_t { HmdMatrix34_t mDeviceToAbsoluteTracking; // ... };

The name "device to absolute tracking" suggests that the 3x3 relates device-local to absolute. If you remember your linear algebra, multiplying a column vector on its left by an orthogonal 3x3 matrix like this will interpret the vector in the output coordinate space, in this case, the absolute space. In essence, this is a rotation.

So, if you take the view vector in local HMD space (I believe this is looking down the -Z axis, so [0 0 -1]) and multiply it by this 3x3 matrix, you will get the view direction vector in world space. You already know the position. As for the "up" vector, this is the local vector [0 1 0], so multiply that by the 3x3 as well to get it in world space. If you think about it, this is only using 0, 1, or -1 as multipliers, so you can actually code a shortcut to get lookat and up vectors from the 3x3 just by pulling out the column you want and possibly negating it.

Hope that helps...
Last edited by zoinks; Jul 28, 2016 @ 12:43pm
zoinks Jul 28, 2016 @ 12:49pm 
Actually, it seems the old gluLookAt specification calls for the position of what the eye is looking at, rather than a vector in the view direction. You could simulate this by adding the world-space view vector as calculated above to the world-space position. https://www.opengl.org/sdk/docs/man2/xhtml/gluLookAt.xml But again, it's no longer proper to use gluLookAt.
< >
Showing 1-3 of 3 comments
Per page: 1530 50

Date Posted: Jul 27, 2016 @ 10:29am
Posts: 3