C++ 使用WRL实例化SpatialSurfaceObserver

C++ 使用WRL实例化SpatialSurfaceObserver,c++,uwp,hololens,wrl,C++,Uwp,Hololens,Wrl,我正在尝试将SpatialSurfaceObserver类用于Windows混合现实。我是这样说的: 然而,我遇到了一个障碍。示例说明我应该简单地创建这样一个实例: m_surfaceObserver=ref新的空间表面观察者() 不过,我使用纯C++,没有C,没有C++ +CX等。到目前为止,这没有问题,我希望使用一个激活工厂来创建一个实例,但据我所知,这个类的一个不包含任何函数来创建一个实例。 基本上我想用这个: using namespace ABI::Windows::Perceptio

我正在尝试将SpatialSurfaceObserver类用于Windows混合现实。我是这样说的:

然而,我遇到了一个障碍。示例说明我应该简单地创建这样一个实例: m_surfaceObserver=ref新的空间表面观察者()

不过,我使用纯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(...);
使用名称空间ABI::Windows::Perception::Spatial;
ComPtr观察者工厂;
ABI::Windows::Foundation::GetActivationFactory(HStringReference(RuntimeClass\u Windows\u Perception\u Spatial\u Surfaces\u SpatialSurfaceObserver).Get(),&observer工厂);
observerFactory->someCreatorFunction(…);
但是没有我可以使用的功能

然后我找到了ActivateInstance,并认为它应该可以工作:

ComPtr<Surfaces::ISpatialSurfaceObserver> observer;
ABI::Windows::Foundation::ActivateInstance(HStringReference(RuntimeClass_Windows_Perception_Spatial_Surfaces_SpatialSurfaceObserver).Get(), &observer);
ComPtr观察员;
ABI::Windows::Foundation::ActivateInstance(HStringReference(运行时类\u Windows\u Perception\u Spatial\u曲面\u SpatialSurfaceObserver).Get(),&observer);
但这也不能编译,它总是抱怨ISpatialSurfaceObserver不包含“InterfaceType”成员

我也遇到了“Make”和“MakeAndActivate”,但我真的不知道如何使用它们,以及它们是否适合我的情况


知道我缺少什么吗?

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

你能给我打个电话吗

::RoActivateInstance(HStringReference(RuntimeClass_Windows_Perception_Spatial_Surfaces_SpatialSurfaceObserver).Get(), &observer);
一些可能有用的参考资料:


哇,这实际上非常有效!非常感谢,你救了我一天:)
::RoActivateInstance(HStringReference(RuntimeClass_Windows_Perception_Spatial_Surfaces_SpatialSurfaceObserver).Get(), &observer);