// Use this for initialization
 void Start()
 {
     // Set up a GestureRecognizer to detect Select gestures.
     gestureRecognizer = new GestureRecognizer();
     gestureRecognizer.TappedEvent += GestureRecognizer_TappedEvent;
     gestureRecognizer.StartCapturingGestures();
 }
Exemplo n.º 2
0
 void Start ()
 {
     recognizer = new GestureRecognizer();
     recognizer.SetRecognizableGestures(GestureSettings.Tap);
     recognizer.TappedEvent += Recognizer_TappedEvent;
     recognizer.StartCapturingGestures();
 }
Exemplo n.º 3
0
 private void Update()
 {
     if (kin == null) SetUpKinect();
     gRec = gestureObject.GetComponent<GestureRecognizer>();
     this.shift = ShiftCamera(this.shift);
     this.rotationAngle += this.shift;
     CameraRotate();
 }
Exemplo n.º 4
0
    // Use this for initialization
    void Start()
    {
        Instance = this;

        // Set up a GestureRecognizer to detect Select gestures.
        recognizer = new GestureRecognizer();
        recognizer.TappedEvent += Recognizer_TappedEvent;

        recognizer.StartCapturingGestures();
    }
Exemplo n.º 5
0
 private void TapGestureCallback(GestureRecognizer gesture, ICollection<GestureTouch> touches)
 {
     if (gesture.State == GestureRecognizerState.Ended)
     {
         GestureTouch t = FirstTouch (touches);
         if (t.IsValid())
         {
             OnTap();
         }
     }
 }
Exemplo n.º 6
0
 private ICollection<GestureTouch> FilterTouches(ICollection<GestureTouch> touches, GestureRecognizer r)
 {
     filteredTouches.Clear ();
     foreach (GestureTouch t in touches)
     {
         if (gameObjectsForTouch[t.Id] == r.PlatformSpecificView as GameObject)
         {
             filteredTouches.Add (t);
         }
     }
     return filteredTouches;
 }
Exemplo n.º 7
0
	void Start () 
	{
		end.SetActive(false);
		gestureRecognizer = FindObjectOfType(typeof(GestureRecognizer)) as GestureRecognizer;
		splashNFade = FindObjectOfType(typeof(SplashNFade)) as SplashNFade;
		newFigure = true;
		lineRenderer = Instantiate(lineRenderer);
		timer = startTimer;
		timeText = gameObject.GetComponentsInChildren<Text>()[0];
		scoreText = gameObject.GetComponentsInChildren<Text>()[1];
		totalScore = 0;
		scoreText.text = "score 0";
	}
    void Gesture_OnStateChanged( GestureRecognizer source )
    {
        if( source.PreviousState == GestureRecognizer.GestureState.Ready && source.State == GestureRecognizer.GestureState.InProgress )
            UI.StatusText = source + " gesture started";
        else if( source.PreviousState == GestureRecognizer.GestureState.InProgress )
        {
            if( source.State == GestureRecognizer.GestureState.Failed )
                UI.StatusText = source + " gesture failed";
            else if( source.State == GestureRecognizer.GestureState.Recognized )
                UI.StatusText = source + " gesture ended";
        }

        UpdateTargetMaterial();
    }
        public KeyboardSkeletonUpdater()
        {
            _gestureIndex = -1;

            _gestureRecognizer = new GestureRecognizer();
            _gestureRecognizer.OnGesture += (sender, args) =>
                {
                    if (_currentAppState != null)
                        _currentAppState.OnGesture(args.GestureType);
                };

            _currentJoints = new List<JointType>() { JointType.HandLeft };
            _currentSkeleton = new KeyboardSkeletonFactory().CreateInitialSkeleton();
        }
    // Use this for initialization
    void Start()
    {
        Instance = this;

        this.recognizer = new GestureRecognizer();
        recognizer.TappedEvent += (source, tapCount, ray) =>
        {
            if (FocusedObject != null)
            {
                FocusedObject.SendMessageUpwards("OnSelect");
            }
        };

        recognizer.StartCapturingGestures();
    }
    // Use this for initialization
    void Start()
    {
        Instance = this;

        // Set up a GestureRecognizer to detect Select gestures.
        recognizer = new GestureRecognizer();
        recognizer.TappedEvent += (source, tapCount, ray) =>
        {
            // Send an OnSelect message to the focused object and its ancestors.
            if (FocusedObject != null)
            {
                FocusedObject.SendMessageUpwards("OnSelect");
            }
        };
        recognizer.StartCapturingGestures();
    }
Exemplo n.º 12
0
    private void DismissFitbox()
    {
        // Destroy the GestureRecognizer ...
        recognizer.CancelGestures();
        recognizer.StopCapturingGestures();
        recognizer.Dispose();
        recognizer = null;

        // ... show the hologram collection ...
        if (HologramCollection)
        {
            HologramCollection.SetActive(true);

            if (MoveCollectionOnDismiss)
            {
                // Update the Hologram Collection's position so it shows up
                // where the Fitbox left off. Start with the camera's localRotation...
                Quaternion camQuat = Camera.main.transform.localRotation;

                // ... ignore pitch by disabling rotation around the x axis
                camQuat.x = 0;

                // Rotate the vector and factor y back into the position
                Vector3 newPosition = camQuat * collectionStartingOffsetFromCamera;
                newPosition.y = collectionStartingOffsetFromCamera.y;

                // Position was "Local Position" so add that to where the camera is now
                HologramCollection.transform.position = Camera.main.transform.position + newPosition;

                // Rotate the Hologram Collection to face the user.
                Quaternion toQuat = Camera.main.transform.localRotation * HologramCollection.transform.rotation;
                toQuat.x = 0;
                toQuat.z = 0;
                HologramCollection.transform.rotation = toQuat;
            }
        }

        // ... and Destroy the Fitbox
        Destroy(gameObject);
    }
Exemplo n.º 13
0
    private void Awake()
    {
        #if UNITY_EDITOR
        // If we are running inside Unity's Editor, disable the Fitbox script
        // as there is no easy way to dismiss it to see our actual holograms.
        enabled = false;
        #else // UNITY_EDITOR

        // These are the holograms to show when the Fitbox is dismissed
        if (HologramCollection)
        {
            collectionStartingOffsetFromCamera = HologramCollection.transform.localPosition;
            HologramCollection.SetActive(false);
        }

        // Set up our GestureRecognizer to listen for the SelectEvent
        recognizer = new GestureRecognizer();
        recognizer.TappedEvent += (source, tapCount, ray) =>
        {
            DismissFitbox();
        };
        recognizer.StartCapturingGestures();
        #endif
    }
		private void LongPressGestureCallback(GestureRecognizer gesture, ICollection<GestureTouch> touches)
		{
			GestureTouch t = FirstTouch (touches);
			if (gesture.State == GestureRecognizerState.Began)
			{
				DebugText("Long press began: {0}, {1}", t.X, t.Y);
				BeginDrag(t.X, t.Y);
			}
			else if (gesture.State == GestureRecognizerState.Executing)
			{
				DebugText("Long press moved: {0}, {1}", t.X, t.Y);
				DragTo(t.X, t.Y);
			}
			else if (gesture.State == GestureRecognizerState.Ended)
			{
				DebugText("Long press end: {0}, {1}, delta: {2}, {3}", t.X, t.Y, t.DeltaX, t.DeltaY);
				EndDrag(longPressGesture.VelocityX, longPressGesture.VelocityY);
			}
		}
		private void RotateGestureCallback(GestureRecognizer gesture, ICollection<GestureTouch> touches)
		{
			if (gesture.State == GestureRecognizerState.Executing)
			{
				Earth.transform.Rotate(0.0f, 0.0f, rotateGesture.RotationRadiansDelta * Mathf.Rad2Deg);
			}
		}
		private void ScaleGestureCallback(GestureRecognizer gesture, ICollection<GestureTouch> touches)
		{
			if (gesture.State == GestureRecognizerState.Executing)
			{
				DebugText("Scaled: {0}, Focus: {1}, {2}", scaleGesture.ScaleMultiplier, scaleGesture.FocusX, scaleGesture.FocusY);
				Earth.transform.localScale *= scaleGesture.ScaleMultiplier;
			}
		}
		private void PanGestureCallback(GestureRecognizer gesture, ICollection<GestureTouch> touches)
		{
			if (gesture.State == GestureRecognizerState.Executing)
			{
				GestureTouch t = FirstTouch (touches);
				if (t.IsValid())
				{
					DebugText("Panned, {0}, {1}", t.X, t.Y);
					
					float deltaX = panGesture.DeltaX / 25.0f;
					float deltaY = panGesture.DeltaY / 25.0f;
					Vector3 pos = Earth.transform.position;
					pos.x += deltaX;
					pos.y += deltaY;
					Earth.transform.position = pos;
				}
			}
		}
		private void SwipeGestureCallback(GestureRecognizer gesture, ICollection<GestureTouch> touches)
		{
			if (gesture.State == GestureRecognizerState.Ended)
			{
				GestureTouch t = FirstTouch (touches);
				if (t.IsValid())
				{
					HandleSwipe(t.X, t.Y);
					DebugText("Swiped at {0}, {1}; velocity: {2}, {3}", t.X, t.Y, swipeGesture.VelocityX, swipeGesture.VelocityY);
				}
			}
		}
 private void startGestureTracking(BlobTracker blobTracker, GestureRecognizer gestureRecognizer)
 {
     if (blobTracker != null && gestureRecognizer != null)
     {
         blobTracker.InitiateTracking();
         gestureRecognizer.StartEvaluation();
     }
 }
Exemplo n.º 20
0
 void gesture_OnStateChanged( GestureRecognizer source )
 {
     Debug.Log( "Gesture " + source + " changed from " + source.PreviousState + " to " + source.State );
 }
Exemplo n.º 21
0
 void Awake()
 {
     if( !gesture )
         gesture = GetComponent<GestureRecognizer>();
 }
        private void initalizeGestureRecognition(BrailleIODevice device)
        {
            // gesture recognizer registration for the device
            var blobTracker = new BlobTracker();
            var gestureRecognizer = new GestureRecognizer(blobTracker);

            //int c = 0;

            // try to register blob tracker
            blobTrackers.AddOrUpdate(device, blobTracker,
                (key, existingBlobTracker) =>
                {
                    // If this delegate is invoked, then the key already exists.
                    return blobTracker;
                }
            );

            //while (!blobTrackers.TryAdd(device, blobTracker) && c++ < 20) { Thread.Sleep(5); };
            //if (c > 19) throw new AccessViolationException("Cannot add blob tracker to dictionary - access denied");

            // try to register gesture recognizer
            gestureRecognizers.AddOrUpdate(device, gestureRecognizer,
                (key, existingGestureRecognizer) =>
                {
                    // If this delegate is invoked, then the key already exists.
                    if (existingGestureRecognizer != null)
                    {
                        existingGestureRecognizer.FinishEvaluation();
                    }
                    return gestureRecognizer;
                }
            );

            //while (!gestureRecognizers.TryAdd(device, gestureRecognizer) && c++ < 40) { Thread.Sleep(5); };
            //if (c > 39) throw new AccessViolationException("Cannot add gesture recognizer to dictionary - access denied");

            var multitouchClassifier = new MultitouchClassifier();
            var tabClassifier = new TapClassifier();

            gestureRecognizer.AddClassifier(tabClassifier);
            gestureRecognizer.AddClassifier(multitouchClassifier);

            blobTracker.InitiateTracking();
        }
Exemplo n.º 23
0
		public void RemoveGesture(GestureRecognizer gesture)
		{
			gestures.Remove(gesture);
		}
Exemplo n.º 24
0
		public void AddGesture(GestureRecognizer gesture)
		{
			gestures.Add(gesture);
		}
 bool CanBeginRotation( GestureRecognizer gr, FingerGestures.IFingerList touches )
 {
     return !pinchGesture.IsActive;
 }
Exemplo n.º 26
0
		private void TapGestureCallback(GestureRecognizer gesture, ICollection<GestureTouch> touches)
		{
			if (gesture.State == GestureRecognizerState.Ended)
			{
				GestureTouch t = FirstTouch (touches);
				if (t.IsValid())
				{
					DebugText("Tapped at {0}, {1}", t.X, t.Y);
					CreateAsteroid(t.X, t.Y);
				}
			}
		}
 bool CanBeginPinch( GestureRecognizer gr, FingerGestures.IFingerList touches )
 {
     return !rotationGesture.IsActive;
 }
		private void DoubleTapGestureCallback(GestureRecognizer gesture, ICollection<GestureTouch> touches)
		{
			if (gesture.State == GestureRecognizerState.Ended)
			{
				GestureTouch t = FirstTouch (touches);
				if (t.IsValid())
				{
					DebugText("Double tapped at {0}, {1}", t.X, t.Y);
					RemoveAsteroids (t.X, t.Y, 0.5f, EnemyType.DOUBLE);
				}
			}
		}
Exemplo n.º 29
0
 void gesture_OnStateChanged( GestureRecognizer source )
 {
     ScreenLog.AddMessage( "Gesture " + source + " changed from " + source.PreviousState + " to " + source.State );
 }
        /// <summary>
        /// Event Handler from Form Load Event
        /// Setup the real time stylus for collection.
        /// </summary>
        /// <param name="sender">The control that raised the event.</param>
        /// <param name="e">The event arguments.</param>
        private void RealTimeStylusPlugin_Load(object sender, System.EventArgs e)
        {
            // Create the real time stylus used to receive stylus notifications
            myRealTimeStylus = new RealTimeStylus(gbTestArea, true);

            // Store the Graphics object associated with the drawing area.
            customDynamicRendererGraphics = gbTestArea.CreateGraphics();

            // Create the plugins.  Note that since these are
            // synchronous plugins, notification will occur on the
            // pen thread.
            //
            // -PacketFilterPlugin: demonstrates packet modification by
            //  constraining all x,y packet data within a rectangular area.
            // -CustomDynamicRendererPlugin:  demonstrates custom dynamic
            //  rendering by drawing a small circle around each x,y.
            // -GestureRecognizer:  plugin provided by the Tablet PC Platform
            //  API, which recognizes application gestures.
            // -DynamicRenderer:  plugin provided by Tablet PC Platform API,
            // which renders packet data as it is collected.

            // Create the PacketFilterPlugin
            // Note that this custom plugin takes a rectangle in
            // ink space coordinates (.01mm = 1 ink space unit), which
            // specifies the filter region.  This sample uses a rectangle
            // that is centered over the drawing area.
            float right  = ((float)gbTestArea.Width*2540.0F)/(float)customDynamicRendererGraphics.DpiX;
            float bottom = ((float)gbTestArea.Height*2540.0F)/(float)customDynamicRendererGraphics.DpiY;
            Rectangle filterRect = new Rectangle((int)Math.Round(.15F*right),
                                                 (int)Math.Round(.15F*bottom),
                                                 (int)Math.Round(.7F*right),
                                                 (int)Math.Round(.7F*bottom));
            IStylusSyncPlugin filterPlugin = new PacketFilterPlugin(filterRect);
            chklbPlugins.Items.Add(new PluginListItem(filterPlugin,"PacketFilter"));

            // Create the CustomDynamicRendererPlugin
            IStylusSyncPlugin rendererPlugin = new CustomDynamicRendererPlugin(customDynamicRendererGraphics);
            chklbPlugins.Items.Add(new PluginListItem(rendererPlugin,"CustomDynamicRenderer"));

            // Attempt to create the GestureRecognizer plugin.
            // An exception will occur if no recognizers are available.
            // In this case, the sample proceeds, but does not add the
            // gesture recognizer into the list of available plugins.
            GestureRecognizer gr = null;
            try
            {
                gr = new GestureRecognizer();
                ApplicationGesture [] gestures = { ApplicationGesture.AllGestures };
                gr.EnableGestures(gestures);
                chklbPlugins.Items.Add(new PluginListItem(gr,"GestureRecognizer"));
            }
            catch
            {
            }

            // Create the dynamic renderer used to render the stroke that is
            //  currently being collected
            DynamicRenderer dr = new DynamicRenderer(gbTestArea);
            chklbPlugins.Items.Add(new PluginListItem(dr,"DynamicRenderer"));

            // Enable all plugins
            for(int i = 0; i < chklbPlugins.Items.Count; i++)
            {
                chklbPlugins.SetItemChecked(i,true);
            }

            // Add this form to the collection of asynchronous plugins.
            // The CustomStylusDataAdded notification will be used to
            // update the form's UI when an application gesture occurs.
            // Since this is an asynchronous plugin, notification will
            // occur on the UI thread.
            myRealTimeStylus.AsyncPluginCollection.Add(this);

            // Enable the RealTimeStylus, GestureRecognizer, and DynamicRenderer
            myRealTimeStylus.Enabled = true;
            if (gr != null)
            {
                gr.Enabled = true;
            }
            dr.Enabled = true;
        }