Gestures

Note

  • The gesture feature is only supported in VIVE Wave™ SDK version 3.2.x or newer.

Introduction

The VIVE Wave™ SDK provides two gesture features: Hand Gesture and Hand Tracking.

Hand Gesture: A collection of predefined gesture. For example, Like (Thumb Up), OK and Five.

Hand Tracking: The position and rotation (wrist only) of every hand skeleton joint.

VIVE Wave™ SDK provides three ways to use the Hand Gesture and Hand Tracking features:

  • Script: Assets/WaveVR/Scripts/Gesture/
  • Prefab: Assets/WaveVR/Prefabs/WaveVRGesture
  • Events

The gesture interface is introduced in the following tutorials. The gesture sample is provided in VIVE Wave™ SDK.

Enable Or Disable Gesture

The Hand Gesture and Hand Tracking features need to be enabled before being used.

Drag the WaveVRGesture prefab into your scene to enable/disable the gesture feature.

_images/TheGestureUsage01.png _images/TheGestureUsage04.png

In the application runtime:

  • Enable/Disable the Hand Gesture by using this code:

WaveVR_GestureManager.Instance.EnableHandGesture = true; // or false

  • Restart the enabled Hand Gesture by using this API:

WaveVR_GestureManager.Instance.RestartHandGesture(Action<bool> callback_function);

  • Enable/Disable the Hand Tracking by using this code:

WaveVR_GestureManager.Instance.EnableHandTracking = true; // or false

  • Restart the enabled Hand Tracking by using this API:

WaveVR_GestureManager.Instance.RestartHandTracking(Action<bool> callback_function);

Get Static Gestures

VIVE Wave™ SDK defines these static gestures:

public enum EStaticGestures
{
        FIST = WVR_HandGestureType.WVR_HandGestureType_Fist,
        FIVE = WVR_HandGestureType.WVR_HandGestureType_Five,
        OK = WVR_HandGestureType.WVR_HandGestureType_OK,
        THUMBUP = WVR_HandGestureType.WVR_HandGestureType_ThumbUp,
        INDEXUP = WVR_HandGestureType.WVR_HandGestureType_IndexUp,
}

After the Hand Gesture feature is enabled, you can receive static gesture events by using the code:

private bool mEnabled = false;
void OnEnable()
{
        if (!mEnabled)
        {
                WaveVR_Utils.Event.Listen (WaveVR_Utils.Event.HAND_STATIC_GESTURE_LEFT, onStaticGestureHandle);
                WaveVR_Utils.Event.Listen (WaveVR_Utils.Event.HAND_STATIC_GESTURE_RIGHT, onStaticGestureHandle);
                mEnabled = true;
        }
}

void OnDisable()
{
        if (mEnabled)
        {
                WaveVR_Utils.Event.Remove (WaveVR_Utils.Event.HAND_STATIC_GESTURE_LEFT, onStaticGestureHandle);
                WaveVR_Utils.Event.Remove (WaveVR_Utils.Event.HAND_STATIC_GESTURE_RIGHT, onStaticGestureHandle);
                mEnabled = false;
        }
}

private void onStaticGestureHandle(params object[] args)
{
        WVR_HandGestureType static_gesture = (WVR_HandGestureType)args [0];
}

Besides receiving the events, you can query current static gesture proactively by using the code:

WVR_HandGestureType gesture_left = WaveVR_GestureManager.Instance.GetCurrentLeftHandStaticGesture ();
WVR_HandGestureType gesture_right = WaveVR_GestureManager.Instance.GetCurrentRightHandStaticGesture ();

Get Gesture Status

The Hand Gesture has the following status:

public enum HandGestureStatus
{
        // Initial, can call Start API in this state.
        NOT_START,
        START_FAILURE,

        // Processing, should NOT call API in this state.
        STARTING,
        STOPING,

        // Running, can call Stop API in this state.
        AVAILABLE,

        // Do nothing.
        UNSUPPORT
}
_images/TheGestureUsage05.png

The Hand Tracking has the following status:

public enum HandTrackingStatus
{
        // Initial, can call Start API in this state.
        NOT_START,
        START_FAILURE,

        // Processing, should NOT call API in this state.
        STARTING,
        STOPING,

        // Running, can call Stop API in this state.
        AVAILABLE,

        // Do nothing.
        UNSUPPORT
}
_images/TheGestureUsage06.png

You can receive the gesture status events passively by using the code:

void OnEnable()
{
        WaveVR_Utils.Event.Listen (WaveVR_Utils.Event.HAND_GESTURE_STATUS, OnGestureStatus);
        WaveVR_Utils.Event.Listen (WaveVR_Utils.Event.HAND_TRACKING_STATUS, OnTrackingStatus);
}

void OnDisable()
{
        WaveVR_Utils.Event.Remove (WaveVR_Utils.Event.HAND_GESTURE_STATUS, OnGestureStatus);
        WaveVR_Utils.Event.Remove (WaveVR_Utils.Event.HAND_TRACKING_STATUS, OnTrackingStatus);
}

private void OnGestureStatus(params object[] args)
{
        WaveVR_Utils.HandGestureStatus status = (WaveVR_Utils.HandGestureStatus)args [0];
}

private void OnTrackingStatus(params object[] args)
{
        WaveVR_Utils.HandTrackingStatus status = (WaveVR_Utils.HandTrackingStatus)args [0];
}

You can query the gesture status proactively by using the code:

WaveVR_Utils.HandGestureStatus status = WaveVR_GestureManager.Instance.GetHandGestureStatus ();
WaveVR_Utils.HandTrackingStatus status = WaveVR_GestureManager.Instance.GetHandTrackingStatus ();

Get The Bone Poses

The VIVE Wave™ SDK hand bones are defined as:

_images/TheGestureUsage02.png

Note

  • Only the Wrist has both position and rotation. The other bones only have the position.

To apply a bone pose to a GameObject, add the component WaveVR_BonePose and specify the Bone Type:

_images/TheGestureUsage03.png

You can get the bone pose by using this code:

WaveVR_Utils.RigidTransform rt = WaveVR_BonePose.Instance.GetBoneTransform (WaveVR_BonePoseImpl.Bones.LEFT_WRIST /* or another bone type */);

// Note: Only the **Wrist** has rotation. Do not use rt.rot on other bones.

You can check whether the bone pose is valid or not by using this code:

bool valid_bone = WaveVR_BonePose.Instance.IsBonePoseValid (WaveVR_BonePoseImpl.Bones.LEFT_WRIST /* or another bone type */);

You can check whether the hand pose is valid or not by using this code:

bool valid_hand = WaveVR_BonePose.Instance.IsHandPoseValid (WaveVR_GestureManager.EGestureHand.LEFT /* or another hand type */);

If you have the WaveVR_BonePose instance, you can get the bone information by using this code:

WaveVR_BonePose bonePose;
void OnEnable()
{
        bonePose = GetComponent<WaveVR_BonePose> ();

        // bonePose.Valid: Whether the bone pose is valid.
        // bonePose.Position: Get the bone position.
        // bonePose.Rotation: Get the bone rotation.
}

Gesture Input Module

VIVE Wave™ SDK provides an Unity Input Module named Gesture Input Module which uses Hand Gesture and Hand Tracking to interact with the objects in a scene.

To use the Gesture Input Module, follow below steps:

  1. Add WaveVR_GestureInputModule:

    Assume you already had an EventSystem in a scene. Add the component WaveVR_GestureInputModule into the EventSystem:

    _images/TheGestureUsage07.png
    • Enable Event: To enable or disable the event.
    • Select Gesture: Select a gesture used to trigger the events. VIVE Wave™ SDK defines these static gestures:
  2. Add WaveVR_GesturePointerTracker:

    Add an empty GameObject (can be renamed as GesturePointerTracker) under the WaveVR -> head.

    Add the component WaveVR_GesturePointerTracker into the empty GameObject.

    _images/TheGestureUsage08.png _images/TheGestureUsage09.png
  3. Add WaveVR_GesturePointer:

    The WaveVR_GesturePointer will draw a ring as the pointer when being added into a GameObject.

    _images/TheGestureUsage11.png
    • Hand: Which hand the pointer belongs to.
    • PointerRingWidth: Set the pointer ring’s width.
    • PointerCircleRadius: Set the pointer ring’s inner radius.
    • PointerDistance: Set the pointer distance in meter.
    • PointerColor: Set the pointer ring’s background color.
    • ProgressColor: Set the pointer ring’s foreground color.
    • PointerMaterial: Set the pointer ring’s material. Keep empty to use the default material is recommended.
    • PointerRenderQueue: Set the Material renderQueue.
    • PointerSortingOrder: Set the MeshRenderer sortingOrder.

    The WaveVR_GestureInputModule will send events to the object which the pointer is pointing to.

    There are two draw mode of the pointer:

    • UPWARD (default): The pointer will be drawed on the upward of the specified object.
    • FORWARD: The pointer will be drawed on the forward of the specified object.

    Note

    If you need to change the pointer’s draw mode, you will have to modify the drawMode value in WaveVR_GesturePointer.cs.

    _images/TheGestureUsage10.png

VIVE Wave™ SDK provides a Gesture sample Gesture_Test in the wvr_unity_samples.unitypackage. You can find the sample under Assets/Samples/Gesture_Test.