GART增强现实 - 没有考虑海拔高度

时间:2016-11-08 07:47:00

标签: c# windows-phone-7 windows-phone-8 windows-phone augmented-reality

我正在使用开源AR库GART获取Windows Phone上的小型增强现实应用。我已经关注the documentationa tutorial如何使用它,整体效果非常好,只有一个问题:它没有采取这些项目'考虑到海拔高度,无论我设定的高度如何,都可以看到同一水平面(即地平线)上的所有物品。

我觉得我只是忘了什么而且有一个快速修复... 在GART Tutorial (BingAR and SimpleAR)我看到他们设置了ARItem的高度,并且这样做,但它似乎没有效果。将海拔高度值更改为double.Nan,0或任何其他值不会更改世界视图中的位置:

// create and add ARItem
var altitudeDiff = (m.GPSInformation.Elevation - _currentCoordinate.Altitude);
    m.GeoLocation = new GeoCoordinate
    {
            Latitude = m.GPSInformation.Coordinate.Latitude,
            Longitude = m.GPSInformation.Coordinate.Longitude,
            Altitude = altitudeDiff // or just height, or double.NaN or 0, or 10000 -> no effect
    };
    _arDisplay.ARItems.Add(m);

在某些时候我认为,它不考虑GeoLocation属性,但当我完全删除它时,它缺少Lat&长期价值。 在Method DistanceTo3D(这个位置a,位置b)(in ARHelper.cs in the WP8-project)查看库时,我看到他们也计算了高度差,但前提是设备是WP7。在其他情况下,他们只需将0m作为Vector3的高度。这可能与我的问题有关吗?

static public Vector3 DistanceTo3D(this Location a, Location b)
    {
        // Use GeoCoordinate provided methods to calculate distance. Use 
        // same longitude on both points to calculate latitude distance and 
        // use same latitude on both points to calculate longitude distance.
        float latitudeMeters = (float)a.DistanceTo(new Location() { Latitude = b.Latitude, Longitude = a.Longitude });
        float longitudeMeters = (float)a.DistanceTo(new Location() { Latitude = a.Latitude, Longitude = b.Longitude });

        // Invert the distance sign if necessary to account for direction 
        if (a.Latitude < b.Latitude)
        {
            latitudeMeters *= -1;
        }
        if (a.Longitude > b.Longitude)
        {
            longitudeMeters *= -1;
        }

        float altitudeMeters = 0f;
        #if WP7
        // Now calculate the altitude difference, but only if both sides of the equation have altitudes
        if ((!double.IsNaN(a.Altitude)) && (!double.IsNaN(b.Altitude)))
        {
            // Calculate
            altitudeMeters = (float)(b.Altitude - a.Altitude);

            // Deal with really small double values getting converted to floats
            if (float.IsInfinity(altitudeMeters)) { altitudeMeters = 0; }
        }
        #endif

        // Return the new point
        return new Vector3(longitudeMeters, altitudeMeters, latitudeMeters);
    }

由于我认为这是问题(即Vector3没有返回高度),我改变了库以使用高度,但是一旦我添加一个(例如20米或1000米等),项目在WorldView中不再显示。

或者它与我如何设置ARDisplay的属性有关(请注意,FarClippingPlane相对较大,因为项目距离最远可达100公里)?:

<ARControls:ARDisplay x:Name="ARDisplay" AttitudeRefreshRate="500" MovementThreshold="500" ServiceErrors="ARDisplay_ServiceErrors">
    <ARControls:VideoPreview x:Name="VideoPreview" Canvas.ZIndex="1" />
    <ARControls:WorldView x:Name="WorldView" ItemTemplate="{StaticResource ARMountainControl}" Canvas.ZIndex="3" MinItemScale="0.1" MaxItemScale="1.0" FarClippingPlane="100000.0" NearClippingPlane="50.0" />
</ARControls:ARDisplay>

现在我几乎没有想法,感谢所有想法和建议!

0 个答案:

没有答案