2017-03-02 92 views
4

有谁知道如何在Urho上使用Spatial锚?我看过所有的样品,没有找到任何东西。文档中也没有。我试过使用普通的全息API:HoloLens上的Urho空间锚

var store = await SpatialAnchorManager.RequestStoreAsync(); 
    var anchors = store.GetAllSavedAnchors(); 
    store.TrySave("myanchor", SpatialAnchor.TryCreateRelativeTo(???SpatialCoordinateSystem???)); 

但我不知道从哪里得到空间坐标系。

回答

1

您可以创建空间锚这样

var anchor = SpatialAnchor.TryCreateRelativeTo(UrhoAppView.Current.ReferenceFrame.CoordinateSystem, new System.Numerics.Vector3(x, y, -z)); 
store.TrySave("anchorname", anchor); 

注意,乌尔禾有一个左手坐标系统,同时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 
    }