Open redjjm opened 6 years ago
Rotation has been resolved in the following ways
PoseConverterFunction
Matrix4x4 matrixObj
(
matPose.m[0][0], -matPose.m[1][0], -matPose.m[2][0], 0.0f,
-matPose.m[0][1], matPose.m[1][1], -matPose.m[2][1], 0.0f,
-matPose.m[0][2], -matPose.m[1][2], matPose.m[2][2], 0.0f,
matPose.m[0][3], matPose.m[1][3], matPose.m[2][3], 1.0f
);
However, there was a trembling of the screen during the rotation.
hmmm.....
It should be...
mpProjectionMatrix = m_matProj * m_mat4HMDPose;
The HMD should be the only view matrix. For rendering something as the HMD...
m_mat4HMDPose = ConvertSteamVRMatrixToMatrix4(m_rTrackedDevicePose[vr::k_unTrackedDeviceIndex_Hmd].mDeviceToAbsoluteTracking);
mpProjectionMatrix = m_matProj * m_mat4HMDPose;
Also on another note are you using OpenVR's given projection matrix? If not you need to, to get desirable results.
@Karutoh -- I am using OpenVR's given projection matrix matProj = m_pHMD->GetProjectionMatrix(eEye, nearClip, farClip); matEyes = InverseMatrix(m_pHMD->GetEyeToHeadTransform(eVrEye)); matHmd = InverseMatrix(m_rTrackedDevicePose[vr::k_unTrackedDeviceIndex_Hmd]); projectionMatrix = matProj matEyes matHmd;
-- and I am using custom MyViewMatrix Vector3 worldCurrentLook; // base Vector3(0.0f, 1.0f, 0.0f); Y Vector3 worldCurrentUp; // base Vector3(0.0f, 0.0f, 1.0f); Z Vector3 worldPosition; myViewMatrix = MatrixLookAtRH(worldPosition, worldLook, worldUp); // RightHanded
-- Current result viewProjMatrix = myViewMatrix * projectionMatrix
-- Conflict myViewMatrix Look & Up HMDViewMatrix Look & Up
This is what you should have. As a side note you have no
perspective projection matrix for your camera? Also you only need to use m_pHMD->GetEyeToHeadTransform(eVrEye)
when you need to render for each eye or want to render the eye.
matProj = m_pHMD->GetProjectionMatrix(eEye, nearClip, farClip);
matEyes = m_pHMD->GetEyeToHeadTransform(eVrEye);
matHmd = m_rTrackedDevicePose[vr::k_unTrackedDeviceIndex_Hmd];
hmdModel = matHmd * matEyes;
Vector3 worldCurrentLook; // base Vector3(0.0f, 1.0f, 0.0f); Y
Vector3 worldCurrentUp; // base Vector3(0.0f, 0.0f, 1.0f); Z
Vector3 worldPosition;
myViewMatrix = MatrixLookAtRH(worldPosition, worldLook, worldUp); // RightHanded
viewProjMatrix = perspectiveProjMat * myViewMatrix * hmdModel;
@Karutoh I solved it thanks to you!! :smiley:
Glad I could be of help.
hi guys
I applied HMD TrackingMatrix to projectionMatrix.
Sadly the HMD rotates in the opposite direction.
I tried to multiply HMDMatrix by -1.0f, but the result was not good. T_T
current cam state CamUp = (0.0f, 0.0f, 1.0f); // Z CamLook =(0.0f, 1.0f, 0.0f); // Y
Here's my simple code.
Is there no way?
thanks for read...