rotation - OpenVR Teleportation Problem(前向计算)
问题描述
所以我正在尝试在我的 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) 从中获得正向,但结果向量不正确。我的逻辑有问题吗?
解决方案
所以事实证明我的方法有一些问题。首先,OpenVR 将控制器的正向定义为 vec4(0,0,-1,0),其次,它是相对于 HMD 相机定义的。为了在场景中移动,我使用第二个相机矩阵进行平移和旋转。因此不得不考虑到这一点。
我的最终计算如下
auto forward = glm::normalize(glm::inverse(nonHMDViewMat) *
vr.GetControllerPose(Right) * glm::vec4(0,0,-1,0));
其中 vr.GetControllerPose(Right) 返回右手的矩阵 hand[eHand].pose 。
推荐阅读
- mongodb - Mongodb查询仅获取特定日期的文档
- python - 使用多个 python 列表时避免使用 `i` 进行索引
- python - ValueError: 操作数不能与形状 (0,) (784,) 一起广播
- python - 根据另一列(条件)的值替换缺失值 NAN
- oauth-2.0 - JHIpster KeyCloak OAuth,登录期间代理错误
- mongodb - 带有参数的axios获取请求不起作用
- c# - 验证字符串预防不起作用?
- javascript - 如何使用 JavaScript 中的 PATCH 请求将项目添加到数据库中的数组?
- c# - 如何检测函数指针类型?
- php - 折扣购物车项目价格不包括 WooCommerce 中的类别及其子项