有人知道如何在Urho中使用Spatial Anchors吗?我看了所有样品,没找到任何东西。文档中也没有任何内容。我尝试使用常规的Holographic API:
var store = await SpatialAnchorManager.RequestStoreAsync();
var anchors = store.GetAllSavedAnchors();
store.TrySave("myanchor", SpatialAnchor.TryCreateRelativeTo(???SpatialCoordinateSystem???));
但我不知道从哪里获得空间坐标系。
答案 0 :(得分:2)
您可以像这样创建空间锚
var anchor = SpatialAnchor.TryCreateRelativeTo(UrhoAppView.Current.ReferenceFrame.CoordinateSystem, new System.Numerics.Vector3(x, y, -z));
store.TrySave("anchorname", anchor);
请注意,Urho有一个左手坐标系,而HoloLens API有一个右手坐标系,因此是负z。
您可以将锚点映射到当前系统,如下所示:
var matrix = store["anchorname"].CoordinateSystem.TryGetTransformTo(UrhoAppView.Current.ReferenceFrame.CoordinateSystem);
if (matrix.HasValue)
{
System.Numerics.Vector3 scale;
System.Numerics.Quaternion rotation;
System.Numerics.Vector3 translation;
System.Numerics.Matrix4x4.Decompose(matrix.Value, out scale, out rotation, out translation);
var q = new Quaternion(rotation.X, rotation.Y, rotation.Z, rotation.W);
var v = new Vector3(translation.X, translation.Y, -translation.Z);// -Z Right-handed to left-handed
}