0

我正在尝试将 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”,但并不真正了解如何使用它们以及它们是否适合我的情况。

知道我缺少什么吗?

4

1 回答 1

1

这里没有任何专业知识,但可以尝试一个想法。

ABI::Windows::Foundation::ActivateInstance(HStringReference(RuntimeClass_Windows_Perception_Spatial_Surfaces_SpatialSurfaceObserver).Get(), &observer);

你能试着打电话吗

::RoActivateInstance(HStringReference(RuntimeClass_Windows_Perception_Spatial_Surfaces_SpatialSurfaceObserver).Get(), &observer);

一些可能有用的参考资料:

于 2017-07-23T20:25:32.953 回答