Beispiel #1
0
 public UnityARCamera(UnityARMatrix4x4 wt, UnityARMatrix4x4 pm, ARTrackingState ats, ARTrackingStateReason atsr, UnityVideoParams uvp, Vector3[] pointCloud)
 {
     worldTransform   = wt;
     projectionMatrix = pm;
     trackingState    = ats;
     trackingReason   = atsr;
     videoParams      = uvp;
     pointCloudData   = pointCloud;
 }
Beispiel #2
0
 public serializableUnityARCamera(serializableUnityARMatrix4x4 wt, serializableUnityARMatrix4x4 pm, ARTrackingState ats, ARTrackingStateReason atsr, UnityVideoParams uvp, serializablePointCloud spc)
 {
     worldTransform   = wt;
     projectionMatrix = pm;
     trackingState    = ats;
     trackingReason   = atsr;
     videoParams      = uvp;
     pointCloud       = spc;
 }
Beispiel #3
0
        public void SessionTrackingChanged(UnityARCamera unityARCamera)
        {
            //Debug.Log("ARKitBridge: SessionTrackingChanged: unityARCamera: " + unityARCamera + " trackingState: " + unityARCamera.trackingState + " trackingReason: " + unityARCamera.trackingReason);

            trackingState  = unityARCamera.trackingState;
            trackingReason = unityARCamera.trackingReason;

            SendEventData("SessionTrackingStateChanged");
        }
Beispiel #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ARMobileService"/> class.
 /// </summary>
 protected ARMobileService()
 {
     this.trackPosition          = true;
     this.planeDetection         = PlaneDetectionType.None;
     this.lightEstimationEnabled = false;
     this.pointCloudEnabled      = false;
     this.TrackingState          = ARTrackingState.NotAvailable;
     this.anchorsById            = new ConcurrentDictionary <Guid, ARMobileAnchor>();
 }
 public UnityARCamera(UnityARMatrix4x4 wt, UnityARMatrix4x4 pm, ARTrackingState ats, ARTrackingStateReason atsr, UnityVideoParams uvp, UnityARLightData lightDat, UnityARMatrix4x4 dt, Vector3[] pointCloud, ARWorldMappingStatus awms)
 {
     worldTransform     = wt;
     projectionMatrix   = pm;
     trackingState      = ats;
     trackingReason     = atsr;
     videoParams        = uvp;
     lightData          = lightDat;
     displayTransform   = dt;
     pointCloudData     = pointCloud;
     worldMappingStatus = awms;
 }
        private void UpdateSessionInfoLabel(ARFrame currentFrame, ARTrackingState trackingState, ARTrackingStateReason trackingStateReason)
        {
            string message = "";

            _snapShotThumbnail.Hidden = true;

            switch (trackingState)
            {
            case ARTrackingState.Normal:
                switch (currentFrame.WorldMappingStatus)
                {
                case ARWorldMappingStatus.Mapped:
                case ARWorldMappingStatus.Extending:
                    if (currentFrame.Anchors.Any(anchor => anchor.Name == virtualObjectAnchorName))
                    {
                        message = "Tap 'Save Experience' to save the current map.";
                    }
                    else
                    {
                        message = "Tap on the screen to place an object.";
                    }
                    break;

                default:
                    if (DataFromFile == null)
                    {
                        message = "Move around to map the environment.";
                    }
                    else if (isRelocalizingMap == false)
                    {
                        message = "Move around to map the environment or tap 'Load Experience' to load a saved experience.";
                    }
                    break;
                }
                break;

            case ARTrackingState.Limited:
                if (trackingStateReason == ARTrackingStateReason.Relocalizing && isRelocalizingMap)
                {
                    message = "Move your device to the location shown in the image.";
                    _snapShotThumbnail.Hidden = false;
                }
                break;

            default:
                message = currentFrame.Camera.GetLocalisedFeedback();
                break;
            }

            _sessionInfoLabel.Text  = message;
            _sessionInfoView.Hidden = message == string.Empty;
        }
Beispiel #7
0
 public serializableUnityARCamera(serializableUnityARMatrix4x4 wt, serializableUnityARMatrix4x4 pm, ARTrackingState ats, ARTrackingStateReason atsr, UnityVideoParams uvp, UnityARLightData lightDat, serializableUnityARMatrix4x4 dt, serializablePointCloud spc,
                                  ARWorldMappingStatus awms)
 {
     worldTransform     = wt;
     projectionMatrix   = pm;
     trackingState      = ats;
     trackingReason     = atsr;
     videoParams        = uvp;
     lightData          = lightDat;
     displayTransform   = dt;
     pointCloud         = spc;
     worldMappingStatus = awms;
 }
Beispiel #8
0
    //----------------------
    //MARK: - Status Updates
    //----------------------

    /// <summary>
    /// Informs The User About The Current Tracking State
    /// </summary>
    /// <param name="trackingState">Tracking state.</param>
    public void logTrackingState(ARTrackingState trackingState)
    {
        switch (trackingState)
        {
        case ARTrackingState.ARTrackingStateNormal:
            arTrackingStatus = "Tracking Ready";

            break;

        case ARTrackingState.ARTrackingStateNotAvailable:
            arTrackingStatus = "Tracking Unavailable";
            break;
        }
    }
Beispiel #9
0
        public void ShowTrackingQualityInfo(ARTrackingState trackingState, ARTrackingStateReason reason, bool autoHide)
        {
            var title   = "";
            var message = "";

            switch (trackingState)
            {
            case ARTrackingState.NotAvailable:
                title = "Tracking Not Available";
                break;

            case ARTrackingState.Normal:
                title = "Tracking Normal";
                break;

            case ARTrackingState.Limited:
                title = "Tracking Limited";
                switch (reason)
                {
                case ARTrackingStateReason.ExcessiveMotion:
                    message = "because of excessive motion";
                    break;

                case ARTrackingStateReason.Initializing:
                    message = "because tracking is initializing";
                    break;

                case ARTrackingStateReason.InsufficientFeatures:
                    message = "because of insufficient features in the environment";
                    break;

                case ARTrackingStateReason.None:
                    message = "because of an unknown reason";
                    break;
                }
                break;
            }

            ShowMessage($"{title} {message}", autoHide);
        }
 // invoked by TrackingChanged-event
 private void ARSessionTrackingChanged(UnityARCamera camera)
 {
     cameraTrackingState  = camera.trackingState;
     cameraTrackingReason = camera.trackingReason;
 }
Beispiel #11
0
 void TrackingChanged(UnityARCamera cam)
 {
     _arTrackingState       = cam.trackingState;
     _arTrackingStateReason = cam.trackingReason;
 }
Beispiel #12
0
        public void EscalateFeedback(ARTrackingState trackingState, ARTrackingStateReason reason, double displayDuration)
        {
            InvokeOnMainThread(() =>
            {
                var title   = "Tracking status: Limited.";
                var message = "Tracking status has been limited for an extended time. ";

                // Stop any running timer
                TrackingStateFeedbackMessageTimer?.Invalidate();

                // Create new timer
                TrackingStateFeedbackMessageTimer = NSTimer.CreateScheduledTimer(displayDuration, false, (timer) =>
                {
                    TrackingStateFeedbackMessageTimer?.Invalidate();
                    SchedulingMessageBlocked = true;

                    // Take action based on th tracking state
                    switch (trackingState)
                    {
                    case ARTrackingState.NotAvailable:
                        title = "Tracking Not Available";
                        break;

                    case ARTrackingState.Normal:
                        title = "Tracking Normal";
                        break;

                    case ARTrackingState.Limited:
                        title = "Tracking Limited";
                        switch (reason)
                        {
                        case ARTrackingStateReason.ExcessiveMotion:
                            message = "because of excessive motion";
                            break;

                        case ARTrackingStateReason.Initializing:
                            message = "because tracking is initializing";
                            break;

                        case ARTrackingStateReason.InsufficientFeatures:
                            message = "because of insufficient features in the environment";
                            break;

                        case ARTrackingStateReason.None:
                            message = "because of an unknown reason";
                            break;
                        }
                        break;
                    }

                    // Create and display an Alert Message
                    var restartAction = UIAlertAction.Create("Reset", UIAlertActionStyle.Destructive, (obj) =>
                    {
                        Controller.RestartExperience(this);
                        SchedulingMessageBlocked = false;
                    });

                    var okAction = UIAlertAction.Create("OK", UIAlertActionStyle.Default, (obj) =>
                    {
                        SchedulingMessageBlocked = false;
                    });

                    ShowAlert(title, message, new UIAlertAction[] { restartAction, okAction });
                });
            });
        }
        private void UpdateSessionInfoLabel(ARFrame frame, ARTrackingState trackingState, ARTrackingStateReason trackingStateReason)
        {
            // Update the UI to provide feedback on the state of the AR experience.
            string message = null;

            switch (trackingState)
            {
            case ARTrackingState.Normal:
                if (!frame.Anchors.Any() && !this.multipeerSession.ConnectedPeers.Any())
                {
                    // No planes detected; provide instructions for this app's AR interactions.
                    message = "Move around to map the environment, or wait to join a shared session.";
                }
                else if (this.multipeerSession.ConnectedPeers.Any() && this.mapProvider == null)
                {
                    var peerNames = this.multipeerSession.ConnectedPeers.Select(peer => peer.DisplayName);
                    message = $"Connected with {string.Join(", ", peerNames)}.";
                }
                break;

            case ARTrackingState.NotAvailable:
                message = "Tracking unavailable.";
                break;

            case ARTrackingState.Limited:
                switch (trackingStateReason)
                {
                case ARTrackingStateReason.ExcessiveMotion:
                    message = "Tracking limited - Move the device more slowly.";
                    break;

                case ARTrackingStateReason.InsufficientFeatures:
                    message = "Tracking limited - Point the device at an area with visible surface detail, or improve lighting conditions.";
                    break;

                case ARTrackingStateReason.Initializing:
                    if (this.mapProvider != null)
                    {
                        message = $"Received map from {this.mapProvider.DisplayName}.";
                    }
                    else
                    {
                        message = "Initializing AR session.";
                    }
                    break;

                case ARTrackingStateReason.Relocalizing:

                    if (this.mapProvider != null)
                    {
                        message = $"Received map from {this.mapProvider.DisplayName}.";
                    }
                    else
                    {
                        message = "Resuming session — move to where you were when the session was interrupted.";
                    }
                    break;

                default:
                    break;
                }

                break;

            default:
                // No feedback needed when tracking is normal and planes are visible.
                // (Nor when in unreachable limited-tracking states.)
                message = "";
                break;
            }

            this.sessionInfoLabel.Text  = message;
            this.sessionInfoView.Hidden = string.IsNullOrEmpty(message);
        }