Ejemplo n.º 1
0
    /// <summary>
    /// Gets the lowest plane.
    /// </summary>
    /// <param name="whichQuery">Type of queried plane.</param>
    /// <returns>Returns the lowest detected plane.</returns>
    public DetectedPlane GetLowestPlane(ARCorePlaneUtilQuery whichQuery)
    {
        List <DetectedPlane> planes = GetPlanes(whichQuery);

        var result = planes.OrderBy(a => a.CenterPose.position.y).ToArray();

        return(result.Length > 0 ? result[0] : null);
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Gets the Y value of the lowest plane.
    /// </summary>
    /// <param name="whichQuery">Type of queried plane.</param>
    /// <returns>Returns the Y value of the lowest plane.</returns>
    public float GetLowestPlaneY(ARCorePlaneUtilQuery whichQuery)
    {
        DetectedPlane lowestPlane = GetLowestPlane(whichQuery);

        float lowestY = lowestPlane != null ? lowestPlane.CenterPose.position.y : float.MaxValue;

        return(lowestY);
    }
    //private bool GetSessionPlanes()
    //{
    //    bool foundPlanes = false;

    //    if (Mathf.Abs(m_LastTimestamp - Time.time) > float.Epsilon)
    //    {
    //        // Checks if the ARCore session is valid and running.
    //        if (Session.Status == SessionStatus.Tracking && Session.Status.IsValid())
    //        {
    //            // Gets new planes for this update.
    //            m_AllPlanes.Clear();
    //            m_UpdatedPlanes.Clear();
    //            m_NewPlanes.Clear();

    //            Session.GetTrackables<DetectedPlane>(m_AllPlanes);
    //            Session.GetTrackables<DetectedPlane>(m_NewPlanes, TrackableQueryFilter.New);
    //            Session.GetTrackables<DetectedPlane>(m_UpdatedPlanes, TrackableQueryFilter.Updated);
    //        }

    //        m_LastTimestamp = Time.time;
    //    }

    //    foundPlanes = m_UpdatedPlanes.Count > 0 ? true : false;
    //    return foundPlanes;
    //}

    public List <DetectedPlane> GetPlanes(ARCorePlaneUtilQuery whichQuery)
    {
        // Conditionally collects new planes from ARCore.
        //GetSessionPlanes();

        List <DetectedPlane> planes = new List <DetectedPlane>();

        switch (whichQuery)
        {
        case ARCorePlaneUtilQuery.All:
            planes = m_NewPlanes;
            break;
            //case ARCorePlaneUtilQuery.New:
            //    planes = m_NewPlanes;
            //    break;
            //case ARCorePlaneUtilQuery.Updated:
            //    planes = m_UpdatedPlanes;
            //    break;
        }

        return(planes);
    }