如何从检测到的objectinstance中获得位置?
我一直在尝试按照 httpps:// Learn.microsoft.com/en-us/azure/object-anchors/concepts/sdk-overview 和一些 成功。我成功地检测到了objectInstance,但是如何使坐标将我的游戏对象放在匹配位置?在《空间格言》(PasialGraphaphaphaphaphinatesystem)等文档中,我对我有很多陌生的概念,而我对如何进一步采取行动感到不知所措。
Update
我终于通过首先将“空间” coordinateSystem转换为PatialCoordinatesystem,使其正常工作。
SpatialGraphCoordinateSystem coordinateSystem
[...]
//After getting an ObjectInstance instance
SpatialCoordinateSystem spatialCoordinateSystem = instance.TryGetCurrentState().Center.ToSpatialCoordinateSystem();
var instancePos = spatialCoordinateSystem.TryGetTransformTo(coordinateSystem.Value.ToSpatialCoordinateSystem()).Value.ToUnityLocation().Position;
var instanceOrientation = spatialCoordinateSystem.TryGetTransformTo(coordinateSystem.Value.ToSpatialCoordinateSystem()).Value.ToUnityLocation().Ori;
//Place my hologram on the detected position
mySphere.transform.SetPositionAndRotation(instancePos, instanceOri);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在阅读上面的问题时,我认为根据您的要求,您需要称呼:
这将返回具有中心属性的ObjectInstancestate
空间图表将具有您要寻找的姿势信息。
如果您对混合现实中的一般坐标系统有疑问,我建议您从这里开始了解更多信息:
坐标系统 - 混合现实
另一个好资源 在AOA上,如果您尚未查看样本,请在此处提供:
https://github.com/azure/azure/azure-azure-object-andors
也有在此处浏览此示例的教程:
In reading your question above, I think based on what you are asking, you are needing to call this:
ObjectInstance.TryGetCurrentState Method (Microsoft.Azure.ObjectAnchors) | Microsoft Docs
This will return an ObjectInstanceState with a center property that is a
SpatialGraphLocation Struct (Microsoft.Azure.ObjectAnchors.SpatialGraph) | Microsoft Docs
The SpatialGraphLocation will have the pose information that you are looking for.
If you have questions on Coordinate Systems in general in Mixed Reality, I'd suggest you start here to learn more:
Coordinate systems - Mixed Reality
Another good resources on AOA, if you haven't looked at the sample already, is available here:
https://github.com/Azure/azure-object-anchors
There is also a tutorial that walks through this sample here:
Quickstart: In-depth MRTK walkthrough - Azure Object Anchors | Microsoft Docs