首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >将虚幻中的MotionController组件与C++一起使用,而不是蓝图

将虚幻中的MotionController组件与C++一起使用,而不是蓝图
EN

Stack Overflow用户
提问于 2019-12-07 08:27:25
回答 1查看 292关注 0票数 0

在迭代OculusInputDevice IMotionControllerFMotionControllerSource数组后,我发现了一个基于它的ETrackingStatus的连接的Oculus左右触摸控制器。使用左控制器和右控制器,我可以使用Returns the calibration-space orientation of the requested controller's handIMotionController API获取位置和旋转。

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

我想将位置/旋转应用于PosableMesh,这样网格就会显示在眼球控制器实际所在的位置。目前,使用下面的代码,3D模型从相机向下显示,因此贴图比例是关闭的。我想WorldToMetersScale可能已经关机了。当我使用一个较小的数字时,控制器不会移动3D模型太多,但这可能会搞乱它。

代码语言:javascript
运行
复制
            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);
            }
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-12-07 09:21:10

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

代码语言:javascript
运行
复制
// get camera reference during BeginPlay:
camManager = GetWorld()->GetFirstPlayerController()->PlayerCameraManager;

// TickComponent
poseMesh->SetWorldLocationAndRotation(camManager->GetCameraLocation() + position, rotation);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59221945

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档