【问题标题】:Using a MotionController Component in Unreal with C++ instead of Blueprint在 Unreal 中使用 C++ 而非蓝图的 MotionController 组件
【发布时间】:2019-12-07 00:27:25
【问题描述】:

在遍历 OculusInputDevice IMotionControllerFMotionControllerSource 数组后,我根据 ETrackingStatus 找到了连接的 Oculus 左右触摸控制器。使用左右控制器,我可以使用IMotionController API 获取位置和旋转,其中Returns the calibration-space orientation of the requested controller's hand

这是对 IMotionController API 的引用: https://docs.unrealengine.com/en-US/API/Runtime/HeadMountedDisplay/IMotionController/index.html

我想将位置/旋转应用到 PosableMesh,以便网格显示在 Oculus 控制器实际所在的位置。目前,使用下面的代码,3D模型是从相机向下显示的,因此映射比例是关闭的。我认为WorldToMetersScale可能会关闭。当我使用较小的数字时,控制器不会过多地移动 3D 模型,但这可能会搞砸。

            FVector position;
            FRotator rotation;
            int id = tracker.deviceIndex;
            FName srcName = tracker.motionControllerSource;
            bool success = tracker.motionController->GetControllerOrientationAndPosition(id, srcName, rotation, position, 250.0f);
            if (success)
            {
                poseMesh->SetWorldLocationAndRotation(position, rotation);
            }

【问题讨论】:

    标签: c++ virtual-reality unreal-engine4 oculus


    【解决方案1】:

    将相机位置添加到控制器位置似乎可以解决问题:

    // get camera reference during BeginPlay:
    camManager = GetWorld()->GetFirstPlayerController()->PlayerCameraManager;
    
    // TickComponent
    poseMesh->SetWorldLocationAndRotation(camManager->GetCameraLocation() + position, rotation);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-03-02
      • 2020-03-02
      • 2017-05-23
      • 2021-10-29
      • 2020-09-29
      • 2021-11-23
      • 2022-12-13
      相关资源
      最近更新 更多