Scripting Interaction Objects - VRTRIX/VRTRIXGlove_Unity3D_SDK GitHub Wiki

Core Interaction Engine is built-in and generally don't require further second development. But developers can modify the event handling script when a certain interaction is triggered. Following are some example event handling code snippet for interaction objects.

VRTRIXGloveInterationObject

This is the event handling script for a basic grabbable object.

OnHandHoverBegin is an event that will be triggered when a Hand starts hovering over this object.

using VRTRIX;
using UnityEngine;

private void OnHandHoverBegin(VRTRIXGloveGrab hand)
{
   if (textMesh != null)
   {
       textMesh.text = "Hovering hand: " + hand.name;
   }
}

OnHandHoverEnd is an event that will be triggered when a Hand stops hovering over this object.

private void OnHandHoverEnd(VRTRIXGloveGrab hand)
{
   if (textMesh != null)
   {
     textMesh.text = "No Hand Hovering";
   }
}

OnAttachedToHand is an event that will be triggered when this GameObject becomes attached to the hand.

private void OnAttachedToHand(VRTRIXGloveGrab hand)
{
   if (textMesh != null)
   {
      textMesh.text = "Attached to hand: " + hand.name;
   }
   attachTime = Time.time;
}

OnDetachedFromHand is an event that will be triggered when this GameObject is detached from the hand.

private void OnDetachedFromHand(VRTRIXGloveGrab hand)
{
  if (textMesh != null)
  {
     textMesh.text = "Detached from hand: " + hand.name;
  }
}

HandAttachedUpdate is called every Update() while this GameObject is attached to the hand.

private void HandAttachedUpdate(VRTRIXGloveGrab hand)
{
   if(textMesh != null)
   {
     textMesh.text = "Attached to hand: " + hand.name + "\nAttached time: " + (Time.time - attachTime).ToString("F2");
   }
   if (!hand.GetStandardInteractionButton())
   {
     StartCoroutine(LateDetach(hand));
   }
}

VRTRIXGloveHoverEvents

You can also use this script to customize all behaviors you want when hovering events occurs when grabbing, throwing interactive objects.

using UnityEngine.Events
using VRTRIX

public UnityEvent onHandHoverBegin;
public UnityEvent onHandHoverEnd;
public UnityEvent onAttachedToHand;
public UnityEvent onDetachedFromHand;

VRTRIXGloveButtons

You can use this script to customize/add functionality to buttons. Currently there are four basic buttons for demonstration in the example scene (Reset Scene, Vibrate, Hide Logo, Show Logo). You can add more features to varieties of buttons/UI.

using UnityEngine
using VRTRIX

public void ResetScene(){}
public void Vibrate(VRTRIXGloveGrab hand){}
public void HideLogo(){}
public void ShowLogo(){}

VRTRIXGloveGestureRecognition

You can use this script to customize/add gestures. Currently there are four basic gesture for demonstration in the example scene (BUTTONCLICK, BUTTONOK, BUTTONGRAB, BUTTONTELEPORT). You can add more features to varieties of hand gestures.

using VRTRIX

public enum VRTRIXGloveGesture
{
   BUTTONCLICK,
   BUTTONOK,
   BUTTONGRAB,
   BUTTONTELEPORT,
   BUTTONNONE
};

Example for implementation of button click gesture:

if (ThumbCurve && MiddleCurve && RingCurve && PinkyCurve && !IndexCurve)
{
   return VRTRIXGloveGesture.BUTTONCLICK;
}

Example for implementation of OK gesture:

if (ThumbCurve && IndexCurve && !MiddleCurve && !RingCurve && !PinkyCurve)
{
   return VRTRIXGloveGesture.BUTTONOK;
}

Example for implementation of grab gesture:

if (ThumbCurve && MiddleCurve && RingCurve && PinkyCurve && IndexCurve)
{
   return VRTRIXGloveGesture.BUTTONGRAB;
}