Skip to content

Lemur GUI Integration

richardTingle edited this page Dec 21, 2023 · 2 revisions

Tamarin provides an optional integration with Lemur so that you can interact with UI elements created with lemur using either finger tip touch interaction or point and click pick line based interaction.

These UI elements should always be in the 3D world, not layered over the viewport as a traditional 2D GUI as that does not map well to a VR interface.

Create a (3D) lemur UI in the normal way

Container lemurWindow = new Container();
lemurWindow.setLocalScale(0.005f); //lemur defaults to 1 meter == 1 pixel (because that make sense for 2D, scale it down, so it's not huge in 3d)
Label label = new Label("Example application using Tamarin & Lemur");
lemurWindow.addChild(new Button("Block moving example")).addClickCommands(source -> {
    System.out.println("touch!");
});
rootNode.attachChild(lemurWindow);

Register the node to be touch interactable

Tamarin can handle touches with the finger tip

vrHands.getHandControls().forEach(h -> {
     h.setFingerTipPressDetection(rootNode, false, ActionHandles.HAPTIC, 0.1);
});   

When registered like this any finger tip touches on buttons (on thing with click listeners) will trigger them as if they were clicked and a haptic vibration will be triggered

The setFingerTipPressDetection returns a FunctionRegistration which can be used to later remove the behaviour if desired.

Register the node to be point and click interactable

Tamarin can also be set up to click on lemur UIs using a more traditional point and click. In this mode the bulk pointing direction of the hand and a button click is used to direct the clicks.

When in this mode it is normal to attach a pick line and have a pick marker to show where on the UI you are currently pointing

vrHands.getHandControls().forEach(h -> {
     h.attachPickLine(pickLine());
     h.setPickMarkerContinuous(rootNodeDelegate);
     h.setClickAction_lemurSupport(ActionHandles.TRIGGER, rootNodeDelegate);
});

Just like setFingerTipPressDetection these methods all return a FunctionRegistration which can be used to later remove the behaviour if desired.

FingerTipPressDetection and point and click interaction can be used together without issue; allowing the end user to decide how best they want to interact with your UI.

A simple example of this can be seen in the MenuExampleState and a more complicated example in AdvancedLemurTestState

Clone this wiki locally