openvr icon indicating copy to clipboard operation
openvr copied to clipboard

How to get HMD Pose Matrix and the meaning of it

Open LouHan-0325 opened this issue 6 years ago • 0 comments

Hello, I learned sample of hellovr_opengl but I had some problems with HMD Pose Matrix. Can I get HMD Pose Matrix from this code `

vr::VRCompositor()->WaitGetPoses(m_rTrackedDevicePose, vr::k_unMaxTrackedDeviceCount, NULL, 0 );

m_iValidPoseCount = 0;
m_strPoseClasses = "";
for ( int nDevice = 0; nDevice < vr::k_unMaxTrackedDeviceCount; ++nDevice )
{
	if ( m_rTrackedDevicePose[nDevice].bPoseIsValid )
	{
		m_iValidPoseCount++;
		m_rmat4DevicePose[nDevice] = ConvertSteamVRMatrixToMatrix4( m_rTrackedDevicePose[nDevice].mDeviceToAbsoluteTracking );
		if (m_rDevClassChar[nDevice]==0)
		{
			switch (m_pHMD->GetTrackedDeviceClass(nDevice))
			{
			case vr::TrackedDeviceClass_Controller:        m_rDevClassChar[nDevice] = 'C'; break;
			case vr::TrackedDeviceClass_HMD:               m_rDevClassChar[nDevice] = 'H'; break;
			case vr::TrackedDeviceClass_Invalid:           m_rDevClassChar[nDevice] = 'I'; break;
			case vr::TrackedDeviceClass_GenericTracker:    m_rDevClassChar[nDevice] = 'G'; break;
			case vr::TrackedDeviceClass_TrackingReference: m_rDevClassChar[nDevice] = 'T'; break;
			default:                                       m_rDevClassChar[nDevice] = '?'; break;
			}
		}
		m_strPoseClasses += m_rDevClassChar[nDevice];
	}
}

if ( m_rTrackedDevicePose[vr::k_unTrackedDeviceIndex_Hmd].bPoseIsValid )
{
	m_mat4HMDPose = m_rmat4DevicePose[vr::k_unTrackedDeviceIndex_Hmd];
	m_mat4HMDPose.invert();//
}

` Is the result of HMD Pose Matrix stored in the m_mat4HMDPose? Because I lack VR equipment at present, I can't run the code to get the results .I want to know the specific meaning of the data stored in the matrix. It's very helpful for me to get the rotation angle of HMD in X, Y, Z. Can I get it directly from m_mat4HMDPose or I need to do some calculations?

Thank you for any help!

LouHan-0325 avatar Sep 17 '20 12:09 LouHan-0325