Hand Interaction

Back to Tutorials

10. Composed Gestures 12. Multiple Hands Gestures 1 2  3  4  5  6  7  8  9  10  11  12  13  14  15  16



The simple gestures tutorial introduces you to the gesture unit and teaches the basics to run the unit with simple gestures. The composed gesture tutorial adds information about the composed gestures. This third tutorial of the gesture unit gathers everything from the other two, adds the progress events and graphical elements so this becomes a more interactive experience.

Let's see what's new (everything regarding the .cpp):

Again we register event listeners for our events, but this time we add the progress events. There are three of these: STEADY, ENTER and BACKSPACE always preceded by ViiMProgressEvent::. These events are either time or distance related and to understand them let's go back a little back to the gesture events. When the unit detects a hand not moving outside its dead zone (imagine that the hand is considered steady if its position doesn't change more than a few millimeters), after 5 frames the STEADY progress event starts to be continuously fired with the information of the number of frames that have passed since the first event. This will happen until it reaches the 60th frame, when a STEADY gesture event is fired and it restarts the frame count until the hand moves outside the dead zone. When this happens, the STEADY progress event stops. The ENTER and BACKSPACE progress events happen at the same time when the hand goes from open to close and are triggered continuously with the information of the remaining distance for detection of an ENTER or BACKSPACE gesture event.

In the update function we load the graphics we're going to show in the application, such as an open hand, close hand, active close hand and arrows for the active and inactive swipes.

The implementation of the event handler for the progressive events is just the same as the hand and gesture event handlers. The BACKSPACE progressive example is as follows:

Here we have commented the cout which you can uncomment for demonstration purpose. We also do the same as in simple gestures example, to refer to our class variable _handSizeIncrement by getting a pointer to our class. In this case we update the size of the hand graphic.

Next we have some new functions that draw the graphics on the scene according to the detected gestures.

In line 244 we have a function that decides which graphic to show on top of the user's hand. If an opened hand is detected, a blue open hand graphic will appear and if close, depending on the enter/backspace progress event, will show a closed hand that can be green (_handCloseGraphics) if the hand still hasn't reached the minimum distance for an enter/backspace event or blue (_handCloseGraphicsActive) if the hand has reached the minimum distance and is ready to be opened to create an enter/backspace event.

In line 288 the function drawSwipes is responsible for drawing the arrows of the swipes. If none is detected all four arrows will be faded green. If one is active it will show a live green one.

From here to the update function it's the same as in the other two examples. In the update function the only difference is the call of the new drawing functions described above.

10. Composed Gestures 12. Multiple Hands Gestures 1 2  3  4  5  6  7  8  9  10  11  12  13  14  15  16

Back to Tutorials