Beispiel #1
0
 void PauseMarkerTracking()
 {
     if (isTracking)
     {
         print("Turning tracking off");
         markerTracker.Pause();
         isTracking = false;
     }
 }
    /// <summary>
    /// Unity Monobehavior function: update tracking information of the current marker.
    /// If magic function is enabled, then a distortion transformation is applied on top
    /// of the tracking result. [internal use]
    /// </summary>
    private void LateUpdate()
    {
        if (signalTrackingUpdated && id != -1)
        {
            Interlocked.Exchange(ref latestTrackingInfo, _info);
            if (latestTrackingInfo.visible)
            {
                latestTransMatrix = ARUWPUtils.ConvertARUWPFloatArrayToMatrix4x4(latestTrackingInfo.trans);

                // apply the calibration matrix on top of the tracking results
                latestTransMatrix = calibrationMatrix * latestTransMatrix;

                if (target != null)
                {
                    target.SetMatrix4x4(latestTrackingInfo.locatableCameraToWorld * latestTransMatrix);
                }
            }

            float distance = (target.transform.localPosition - lastPosition).magnitude;
            if (controller.autoLock && distance < controller.threshold)
            {
                Debug.Log("ARUWPMarker: Locked marker at position " + lastPosition + " at threshold " + distance.ToString("F4"));
                controller.Pause();
                locked = true;
                //Reset last tracked position for future realignment to avoid immediate locking if tracking is reinitialized
                lastPosition = Vector3.zero;
            }
            else
            {
                Debug.Log("ARUWPMarker: Found marker but tracking error exceeds threshold)" + controller.threshold.ToString("F4") + "): " + distance.ToString("F4"));
                lastPosition = target.transform.localPosition;
            }
        }

        signalTrackingUpdated = false;
    }