Skip to content

Gesture Store

David Jake Morfe edited this page Dec 3, 2023 · 2 revisions
  "GESTURE 1": {
     "RIGHT_CONTROLLER|LEFT_CONTROLLER": [
       {
         "vrDevice": "RIGHT_CONTROLLER|LEFT_CONTROLLER",
         "movement": "forward",
         "elapsedTime": 0,
         "speed": 0.0,
         "direction": {
           "x": 0.0,
           "y": 0.0,
           "z": 0.0
         },
         "devicesInProximity": {}
       }
     ]
   },
  ...

What the fields mean:

  • Consider each object within the square brackets [] a mere piece of the gesture in a point in time. You can add multiple of these GestureComponent objects. This API recognizes gestures as complex as you want! Just know the more conplex, the more difficult it is to perform a gesture correctly to match your stored gesture.
  • Different values for "movement" are forward, back, left, right, up, down
  • Different values for "vrDevice" are RIGHT_CONTROLLER, LEFT_CONTROLLER, HEAD_MOUNTED_DISPLAY and if you want a gesture recognized on multiple VR devices you can incorporate a logical or using a pipe | like so RIGHT_CONTROLLER|LEFT_CONTROLLER|HEAD_MOUNTED_DISPLAY
  • The "elapsedTime" is in milliseconds. So putting a value of 2000 would mean that part of the gesture lasts 2 seconds. This would be good for a charge up sort of move.
  • The "speed" field is a float value representing the velocity of that GestureComponent. A decent threshold to recognize the speed of a punch would be 1500.0-2000.0 and feel free to play around with the values as much as you want.
  • The "direction" field takes x,y,z float values that create a 3D normalized vector. Example usage of this would be having {0.0, 1.0, 0.0} to recognize when the player's brick hand is facing upwards. There's a certain threshold so it doesn't have to be exact.
  • Finally there's "devicesInProximity" which is formatted like so:
    "devicesInProximity": {
        "LEFT_CONTROLLER": 20
    }
    What this example means is that the vrDevice of this GestureComponent has to be within proximity of the left controller for 20 ticks.
  • Subscribe to the event bus to handle events triggered by a recognized gesture (Forge) or register to the event callback interface (Fabric).

Forge:

@SubscribeEvent
public void onGestureEvent(GestureEvent event) {
   // gesture handler code here -> event.getGestureName()
}

Fabric:

public static void init() {
   GestureEventCallback.EVENT.register((gestureEvent) -> {
      // gesture handler code here -> gestureEvent.getGestureName()
   });
}

Clone this wiki locally