2017-07-23 33 views
0

我正在尝试为Windows混合现实使用SpatialSurfaceObserver类。我是这样的:https://developer.microsoft.com/en-us/windows/mixed-reality/spatial_mapping_in_directx使用WRL实例化SpatialSurfaceObserver

但是,我遇到了障碍。示例状态我应该简单地创建一个实例,如下所示: 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”,但并没有真正理解如何使用它们,以及它们是否适合我的情况。

任何想法我失踪?

回答

1

这里没有任何专业知识,只有一个想法。

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

你能尝试调用

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

一些参考文献可能会有所帮助:

+0

哇,这实际上是完美的作品!非常感谢,你救了我的一天:) – Jan