O'Reilly logo

Mastering Leap Motion by Brandon Sanders

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Interpreting Leap data to render on the graphical frontend

At long last, we can begin writing the Leap code! The only code we'll be editing from this point forward is the LeapaintListener class.

Go ahead and open up LeapaintListener.java now and scroll down to the onFrame method. Replace its content with the lines of code I've written here:

//Get the most recent frame. frame = controller.frame(); //Detect if fingers are present. if (!frame.fingers().isEmpty()) { //Retrieve the front-most finger. Finger frontMost = frame.fingers().frontmost(); //Set up its position. Vector position = new Vector(-1, -1, -1); //Retrieve an interaction box so we can normalize the Leap's coordinates to match screen size. normalizedBox = frame.interactionBox(); //Retrieve ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required