因此,我正在尝试在我的VR应用程序中实现隐形传送(不是在Unity中)。中获得每个控制器的姿态矩阵。
if (auto error = vr::VRInput()->GetPoseActionDataForNextFrame(hand[eHand].pose_handle, vr::TrackingUniverseStanding, &poseData, sizeof(poseData), vr::k_ulInvalidInputValueHandle) != vr::VRInputError_None
|| !poseData.bActive || !poseData.pose.bPoseIsValid)
{
std::cerr << "pose invalid " << error << std::endl;
}
else
{
hand[eHand].pose = ConvertSteamVRMatrixToMatrix4(poseData.pose.mDeviceToAbsoluteTracking);
}然后我使用glm::decompose()来获取位置和方向(方向必须是共轭的)。然后,我尝试通过将方向矩阵乘以vec4(0,0,1,0)来获得正向方向,但结果向量是不正确的。我的逻辑有缺陷吗?
发布于 2021-01-07 03:10:06
所以,事实证明,我的方法有一些问题。首先,OpenVR将控制器的前向定义为vec4(0,0,-1,0),其次,它是相对于头盔显示器摄像头定义的。为了在场景中移动,我使用第二个相机矩阵进行平移和旋转。因此,必须考虑到这一点。
我的最终计算如下
auto forward = glm::normalize(glm::inverse(nonHMDViewMat) *
vr.GetControllerPose(Right) * glm::vec4(0,0,-1,0));其中,vr.GetControllerPose(右)返回右手的handeHand.pose中的矩阵。
https://stackoverflow.com/questions/65568552
复制相似问题