#pragma warning restore

        IEnumerator Start()
        {
            var boundaryPoints = new Vector2[4];

            boundaryPoints[0] = new Vector2(-.5f, -.5f);
            boundaryPoints[1] = new Vector2(-.5f, +.5f);
            boundaryPoints[2] = new Vector2(+.5f, +.5f);
            boundaryPoints[3] = new Vector2(+.5f, -.5f);

            var planeId = PlaneApi.Add(pose, boundaryPoints);

            float angle = 0f;

            while (enabled)
            {
                if (m_Rotate)
                {
                    transform.localRotation = Quaternion.AngleAxis(angle, Vector3.up);
                    angle += Time.deltaTime * 10f;
                }

                PlaneApi.Update(planeId, pose, boundaryPoints);

                if (Random.value < m_TrackingLostProbability)
                {
                    PlaneApi.SetTrackingState(planeId, TrackingState.None);
                    yield return(new WaitForSeconds(1f));

                    PlaneApi.SetTrackingState(planeId, TrackingState.Tracking);
                }

                yield return(null);
            }
        }
Esempio n. 2
0
#pragma warning restore

        IEnumerator Start()
        {
            var boundaryPoints = new Vector2[4];

            boundaryPoints[0] = new Vector2(-.5f, -.5f);
            boundaryPoints[1] = new Vector2(-.5f, +.5f);
            boundaryPoints[2] = new Vector2(+.5f, +.5f);
            boundaryPoints[3] = new Vector2(+.5f, -.5f);

            var planeId = PlaneApi.Add(pose, boundaryPoints, TrackingState.Tracking, default, default, default, default);
        IEnumerator Start()
        {
            var points     = new Vector2[m_NumPoints];
            var velocities = new Vector2[m_NumPoints];

            for (int i = 0; i < points.Length; ++i)
            {
                points[i]     = Random.insideUnitCircle * m_Radius;
                velocities[i] = Random.insideUnitCircle * m_Speed;
            }

            var planeId = PlaneApi.Add(pose, GenerateConvexHull(points), TrackingState.Tracking, default, default, default, default);
Esempio n. 4
0
        IEnumerator Start()
        {
            var points     = new Vector2[m_NumPoints];
            var velocities = new Vector2[m_NumPoints];

            for (int i = 0; i < points.Length; ++i)
            {
                points[i]     = Random.insideUnitCircle * m_Radius;
                velocities[i] = Random.insideUnitCircle * m_Speed;
            }

            var planeId = PlaneApi.Add(pose, GenerateConvexHull(points));

            while (enabled)
            {
                var hullChanged = false;
                if (Random.value < m_HullChangeProbability)
                {
                    for (int i = 0; i < points.Length; ++i)
                    {
                        if (points[i].magnitude > m_Radius && Vector3.Dot(points[i], velocities[i]) > 0)
                        {
                            velocities[i] = -velocities[i];
                        }

                        points[i] += velocities[i] * Time.deltaTime;
                    }

                    hullChanged = true;
                }

                if (hullChanged || transform.hasChanged)
                {
                    PlaneApi.Update(planeId, pose, GenerateConvexHull(points));
                }

                transform.hasChanged = false;

                if (Random.value < m_TrackingLostProbability)
                {
                    PlaneApi.SetTrackingState(planeId, TrackingState.Unavailable);
                    yield return(new WaitForSeconds(1f));

                    PlaneApi.SetTrackingState(planeId, TrackingState.Tracking);
                }

                yield return(null);
            }
        }