예제 #1
0
 public serializableUnityARCamera(serializableUnityARMatrix4x4 wt, serializableUnityARMatrix4x4 pm, ARTrackingState ats, ARTrackingStateReason atsr, UnityVideoParams uvp, UnityARLightData lightDat, serializableUnityARMatrix4x4 dt, serializablePointCloud spc)
 {
     worldTransform   = wt;
     projectionMatrix = pm;
     trackingState    = ats;
     trackingReason   = atsr;
     videoParams      = uvp;
     lightData        = lightDat;
     displayTransform = dt;
     pointCloud       = spc;
 }
예제 #2
0
 public UnityARCamera(UnityARMatrix4x4 wt, UnityARMatrix4x4 pm, ARTrackingState ats, ARTrackingStateReason atsr, UnityVideoParams uvp, UnityARLightData lightDat, UnityARMatrix4x4 dt, Vector3[] pointCloud)
 {
     worldTransform   = wt;
     projectionMatrix = pm;
     trackingState    = ats;
     trackingReason   = atsr;
     videoParams      = uvp;
     lightData        = lightDat;
     displayTransform = dt;
     pointCloudData   = pointCloud;
 }
예제 #3
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 });
                });
            });
        }
예제 #4
0
 public UnityARCamera(UnityARMatrix4x4 wt, UnityARMatrix4x4 pm, ARTrackingState ats, ARTrackingStateReason atsr, UnityVideoParams uvp, UnityARLightData lightDat, UnityARMatrix4x4 dt, ARPointCloud ptCloud, ARWorldMappingStatus awms)
 {
     worldTransform     = wt;
     projectionMatrix   = pm;
     trackingState      = ats;
     trackingReason     = atsr;
     videoParams        = uvp;
     lightData          = lightDat;
     displayTransform   = dt;
     pointCloud         = ptCloud;
     worldMappingStatus = awms;
 }
 void TrackingChanged(UnityARCamera cam)
 {
     _arTrackingState       = cam.trackingState;
     _arTrackingStateReason = cam.trackingReason;
 }
예제 #6
0
        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);
        }