在虚幻引擎中使用运动控制器组件,C++而不是蓝图
Using a MotionController Component in Unreal with C++ instead of Blueprint
在遍历了OculusInputDeviceIMotionController
的FMotionControllerSource
数组后,我发现了一个基于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);
}
将相机位置添加到控制器位置似乎可以解决此问题:
// get camera reference during BeginPlay:
camManager = GetWorld()->GetFirstPlayerController()->PlayerCameraManager;
// TickComponent
poseMesh->SetWorldLocationAndRotation(camManager->GetCameraLocation() + position, rotation);
相关文章:
- 如何将 txt 文件中的行分隔为组件C++
- 使用不同的CRT将新的C++代码与旧的(二进制)组件隔离开来的最佳方法是什么
- 到连接组件算法的问题(递归)
- 两个 COM 组件中 ENUM 的重复条目
- 为什么 gcc 会产生这种奇怪的组件与叮当声?
- 使用 bfs 解决连接组件问题时得到错误的答案
- 如何在ECS框架中更新组件数据和通知系统
- 如何从ECS中的模板方法获取组件?
- 使用蓝牙组件将数据从Android手机传输到串行设备时出现问题
- 组件上的虚幻引擎可蓝图UFUNCTION会导致构建错误
- 在C++中访问蓝图类组件的正确方法是什么?
- 有关纯 ECS(实体组件系统)和更新系统的问题
- 提高基于组件的游戏引擎的效率
- 从组件的 std::type_index 获取派生最多的类型
- 我们可以将阈值应用于色彩空间模型的单个组件(如 RGB 和 LAB)吗?
- 如何通过 UActor组件获取演员列表?
- 在Visual Studio 2017中使用c ++组件构建python解决方案时出现问题
- 如何访问基类向量中的子类变量?(对于实体组件系统)
- 根据组件 1、2(和 3)对空间 (2D/3D) 向量进行排序
- 从 WinRT C++组件访问 COM 对象