-
Notifications
You must be signed in to change notification settings - Fork 2
Hand Ring Menus
Hand Ring Menus are a menu system that surrounds the hands (and are brought into existence by a button press). As these can be brought into existence by the player at any time they are ideal for general in-game menus like weapon or tool selection. As long as the button is held the menu remains open and on releasing the button the players hand position is used to select the item in the menu
As a less common hand function they do not have a convenience method on the BoundHand itself but can be registered as a Function.
vrHandsAppState.getHandControls().forEach(hand -> {
List<MenuItem<String>> topMenuItems = new ArrayList<>();
topMenuItems.add(new MenuLeaf<>(colouredBox1, "Red Box"));
topMenuItems.add(new MenuLeaf<>(colouredBox2, "Cyan Box"));
HandRingMenuFunction<String> handRingMenuFunction = new HandRingMenuFunction<>(topMenuItems, this::acceptSelection, "/actions/main/in/openHandMenu");
FunctionRegistration functionRegistration = hand.addFunction(handRingMenuFunction);
activeFunctionRegistrations.add(functionRegistration); //<-- Remembering the functionRegistration so it can be deregistered on appState removal
});
The spatials passed to the menu (To be used as menu icons) should not be attached to anything, should be around 10cm in size, and should be zero centred.
It is possible to nest menu items, when the hand is brought to that branch in the menu the next child set of menus are opened
topMenuItems.add(
new MenuBranch<>(someSpatialForSphereCategory, List.of(
new MenuBranch<>(sphereCategory(), List.of(
new MenuLeaf<>(sphere1, "Red Sphere"),
new MenuLeaf<>(sphere2, "Blue Sphere"),
new MenuLeaf<>(sphere3, "Gray Sphere"),
new MenuLeaf<>(sphere4, "White Sphere")
)),
new MenuBranch<>(someSpatialForTorusCategory, List.of(
new MenuLeaf<>(torus1, "Red Torus"),
new MenuLeaf<>(torus2, "Blue Torus"),
new MenuLeaf<>(torus3, "Gray Torus"),
new MenuLeaf<>(torus4, "White Torus")
))
))
);
Technically any depth of menu is supported, but it may become uncomfortable for the player to reach with more than 3 layers
See https://github.com/oneMillionWorlds/TamarinTestBed/blob/main/src/main/java/example/HandMenuExampleState.java for a full example of using hand menus