public void DidLoad(VirtualObjectManager manager, VirtualObject virtualObject)
        {
            IsLoadingObject = false;

            //Remove progress indicator
            Spinner.RemoveFromSuperview();
            AddObjectButton.SetImage(UIImage.FromBundle("add"), UIControlState.Normal);
            AddObjectButton.SetImage(UIImage.FromBundle("addPressed"), UIControlState.Highlighted);
        }
Esempio n. 2
0
        public Gesture(NSSet currentTouches, ARSCNView sceneView, VirtualObject lastUsedObject, VirtualObjectManager manager)
        {
            this.currentTouches = currentTouches;
            this.SceneView      = sceneView;
            this.LastUsedObject = lastUsedObject;
            this.manager        = manager;

            // Refresh the current gesture at 60 Hz - This ensures smooth updates even when no
            // new touch events are incoming (but the camera might have moved).
            this.refreshTimer = new System.Threading.Timer(CheckedUpdateGesture, null, 0, 17);
        }
 public void WillLoad(VirtualObjectManager manager, VirtualObject virtualObject)
 {
     // Show progress indicator
     Spinner        = new UIActivityIndicatorView();
     Spinner.Center = AddObjectButton.Center;
     Spinner.Bounds = new CGRect(0, 0, AddObjectButton.Bounds.Width - 5, AddObjectButton.Bounds.Height - 5);
     AddObjectButton.SetImage(UIImage.FromBundle("buttonring"), UIControlState.Normal);
     SceneView.AddSubview(Spinner);
     Spinner.StartAnimating();
     IsLoadingObject = true;
 }
Esempio n. 4
0
        // Static factory method
        public static Gesture StartGestureFromTouches(NSSet currentTouches, ARSCNView sceneView, VirtualObject lastUsedObject, VirtualObjectManager manager)
        {
            switch (currentTouches.Count)
            {
            case 1: return(new SingleFingerGesture(currentTouches, sceneView, lastUsedObject, manager));

            case 2: return(new TwoFingerGesture(currentTouches, sceneView, lastUsedObject, manager));

            default:
                return(null);
            }
        }
Esempio n. 5
0
        public TwoFingerGesture(NSSet touches, ARSCNView view, VirtualObject parentObject, VirtualObjectManager manager) : base(touches, view, parentObject, manager)
        {
            var tArray = touches.ToArray <UITouch>();

            FirstTouch  = tArray[0];
            SecondTouch = tArray[1];

            var firstTouchPoint  = FirstTouch.LocationInView(SceneView);
            var secondTouchPoint = SecondTouch.LocationInView(SceneView);

            InitialMidpoint = firstTouchPoint.Add(secondTouchPoint).Divide(2f);

            // Compute the two other corners of the rectangle defined by the two fingers
            // and compute the points in between.
            var thirdCorner  = new CGPoint(firstTouchPoint.X, secondTouchPoint.Y);
            var fourthCorner = new CGPoint(secondTouchPoint.X, firstTouchPoint.Y);

            //  Compute points in between.
            var midpoints = new[]
            {
                thirdCorner.Add(firstTouchPoint).Divide(2f),
                thirdCorner.Add(secondTouchPoint).Divide(2f),
                fourthCorner.Add(firstTouchPoint).Divide(2f),
                fourthCorner.Add(secondTouchPoint).Divide(2f),
                InitialMidpoint.Add(firstTouchPoint).Divide(2f),
                InitialMidpoint.Add(secondTouchPoint).Divide(2f),
                InitialMidpoint.Add(thirdCorner).Divide(2f),
                InitialMidpoint.Add(fourthCorner).Divide(2f)
            };

            // Check if any of the two fingers or their midpoint is touching the object.
            // Based on that, translation, rotation and scale will be enabled or disabled.
            var allPoints = new List <CGPoint>(new[] { firstTouchPoint, secondTouchPoint, thirdCorner, fourthCorner, InitialMidpoint });

            allPoints.AddRange(midpoints);
            FirstTouchedObject = allPoints.Select(pt => this.VirtualObjectAt(pt)).Where(vo => vo != null).FirstOrDefault();

            if (FirstTouchedObject != null)
            {
                ObjectBaseScale  = FirstTouchedObject.Scale.X;
                AllowTranslation = true;
                AllowRotation    = true;
                InitialDistanceBetweenFingers = (firstTouchPoint.Subtract(secondTouchPoint)).Length();
                InitialFingerAngle            = Math.Atan2(InitialMidpoint.X, InitialMidpoint.Y);
                InitialObjectAngle            = FirstTouchedObject.EulerAngles.Y;
            }
            else
            {
                AllowTranslation = false;
                AllowRotation    = false;
            }
        }
Esempio n. 6
0
        public SingleFingerGesture(NSSet touches, ARSCNView scnView, VirtualObject lastUsedObject, VirtualObjectManager vom)
            : base(touches, scnView, lastUsedObject, vom)
        {
            var firstTouch = (UITouch)touches.First();

            initialTouchPosition = firstTouch.LocationInView(scnView);
            latestTouchPosition  = initialTouchPosition;

            firstTouchedObject = this.VirtualObjectAt(initialTouchPosition);
        }
 public void CouldNotPlace(VirtualObjectManager manager, VirtualObject virtualObject)
 {
     UserFeedback.ShowMessage("Cannot place object\nTry moving left or right.");
 }