首页 > 解决方案 > 为什么我的固定全息图不随头部移动而缩放?

问题描述

我正在使用固定的参考系放置 Direct X 球体。当我移动我的头时,球体全息图保持在原位。但它不能扩展。当我第一次使用 PositionHologramAtGaze()(基于示例代码)放置它时,它确实会缩放。

在 C++/Direct X 中我是否必须处理缩放?

// 下面的代码基于或与示例代码相同...

SpatialPointerPose^ pointerPoseStationary = 
SpatialPointerPose::TryGetAtTimestamp(m_stationaryReferenceFrame- 
>CoordinateSystem, prediction->Timestamp);

m_Sphere->PositionHologramAtGaze(pointerPoseStationary, 2.5f);

球体绘制良好,并保持在固定的世界位置,但当我将头部/全息透镜移得更远时不会缩放。

例如,在这张图片中,我们有一个人在看全息球体戴着全息透镜的人在看全息球体

他们看到的是 佩戴者看到的全息球体

现在佩戴 hololens 硬件的用户向后退了几米:

人后退几步

他们应该看到的是一个更小的球体: Smaller sphere

我也在微软的例子中观察到这一点:

https://github.com/microsoft/Windows-universal-samples/tree/master/Samples/BasicHologram

当我向后移动时,立方体旋转但大小不变。

标签: directxc++-cxhololens

解决方案


我找到了自己的答案。

HolographicFaceTracking 示例使用相对于眼镜的坐标系。第 281 行 SpatialCoordinateSystem^ currentCoordinateSystem = m_referenceFrame-

GetStationaryCoordinateSystemAtTimestamp(prediction->Timestamp);

我将此方法误解为获取“固定”,即“世界”坐标系。但是“固定”在这种情况下没有这个含义。

它并不能完全解释为什么立方体不会改变大小或具有反向缩放,但是,一旦我切换到使用 BasicHologram 示例中的此代码:

// The simplest way to render world-locked holograms is to create a 
stationary reference frame
// based on a SpatialLocator. This is roughly analogous to creating a "world" 
coordinate system
// with the origin placed at the device's position as the app is launched.
m_stationaryReferenceFrame = m_spatialLocator- 
>CreateStationaryFrameOfReferenceAtCurrentLocation();

接着

pose = SpatialPointerPose::TryGetAtTimestamp(m_stationaryReferenceFrame- 
>CoordinateSystem, prediction->Timestamp);

切换到使用 CreateStationaryFrameOfReferenceAtCurrentLocation()

给了我“世界锁定”的坐标系。

我认为,在我的辩护中,;>) 到处都是“固定”这个词有点令人困惑,需要小心。我正在更改自己的代码以确保使用“世界”和“耳机”来引用坐标系以帮助消除混淆......

希望我在这里的回答对其他人有所帮助....


推荐阅读