我正在尝试将 SpatialSurfaceObserver 类用于 Windows Mixed Reality。我在关注这个:https ://developer.microsoft.com/en-us/windows/mixed-reality/spatial_mapping_in_directx
然而,我遇到了障碍。示例状态我应该像这样简单地创建一个实例: m_surfaceObserver = ref new SpatialSurfaceObserver();
但是,我使用的是纯 C++,没有 C#,没有 C++/CX 等。到目前为止这没问题,我期待使用激活工厂来创建一个实例,但据我所知,这个类不包含任何创建实例的函数。
基本上我想用这个:
using namespace ABI::Windows::Perception::Spatial;
ComPtr<Surfaces::ISpatialSurfaceObserverStatics> observerFactory;
ABI::Windows::Foundation::GetActivationFactory(HStringReference(RuntimeClass_Windows_Perception_Spatial_Surfaces_SpatialSurfaceObserver).Get(), &observerFactory);
observerFactory->someCreatorFunction(...);
但是没有我可以使用的功能。
然后我找到了 ActivateInstance,并认为应该可以:
ComPtr<Surfaces::ISpatialSurfaceObserver> observer;
ABI::Windows::Foundation::ActivateInstance(HStringReference(RuntimeClass_Windows_Perception_Spatial_Surfaces_SpatialSurfaceObserver).Get(), &observer);
但这也不能编译,它总是抱怨 ISpatialSurfaceObserver 不包含“InterfaceType”成员。
我也遇到了“Make”和“MakeAndActivate”,但并不真正了解如何使用它们以及它们是否适合我的情况。
知道我缺少什么吗?