Skip to content

vimaxus/leap-ue4

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

leap-ue4

An event-driven Leap Motion plugin for the Unreal Engine 4.

Main method of use is by subscribing to events within your blueprint, but it also supports polling through functions called on the LeapController for up to the 60 past frames. You can extend functionality to any blueprint through adding the LeapInterfaceEvent interface then adding the LeapController component to that blueprint. This same architecture is available to C++ if you prefer, which also supports both event-driven and polling style use.

See unreal thread for version downloads and development updates.

##How to install it##

  1. Create new or open a project.
  2. Browse to your project root (typically found at Documents/Unreal Projects/{Your Project Root})
  3. Copy Plugins folder into your Project root.
  4. Copy Binaries folder into your Project root.
  5. (Optional) Copy Content folder into your Project root.
  6. Restart the Editor and open your project again.
  7. Select Window->Plugins. Click on Installed and you should see a category called Input and a plugin called Leap Motion now available. It should be automatically enabled, if not, Select Enabled. The Editor will warn you to restart, click restart.
  8. The plugin should be enabled and ready to use.

##How to use it - Convenience Rigged/Debug Character## Since 0.7.10 the plugin includes convenience content for easy reference of say a rigged setup. Simply drag the optional Content folder

####Rigged Character####

To try the rigged character, change your default pawn to LeapRiggedCharacter and change your PlayerController to VRPlayerController (if using hmd)

That's it! hit play to try it out!


####Debug Sphere Character####

To try out the debug character, simply change your default pawn to LeapDebugCharacter


####Note on HMD mode####

Both characters have two LeapDebugHand objects and swaps dynamically between them to display the hands in both default mode (leap on table facing up) and HMD mode

##How to use it - Blueprint Quick Setup##

  1. Open desired blueprint where you want to receive the leap events.
  2. Click on Blueprint Props and Scroll down in the details panel to Interfaces.
  3. Add the interface called LeapEventInterface
  4. Add Leap Controller Component through option A or B
  5. Option A: Add directly through components tab


    Option B: Place BeginPlay event on your event graph, drag out from the execute node typing 'Leap', select Add LeapController.
  6. Option B, (Optional, recommended) Drag from the return value, save this as a blueprint variable e.g. Leap.
  7. Both, (Optional) Drag from the return value or your Leap blueprint variable (get), type 'Opt' select the only node which is OptimizeForHMD. Select true for the boolean input (red input), this will optimize the leap for top-down use. Keep auto rotate and auto shift if you want the plugin to automatically shift the leap positions to account for HMD movement.
  8. You're ready to go.

##How to use it - Input Mapping for Joystick-like Input## The easiest way to use the Leap Motion is to use the input mapping system for simple, joystick-like maneuvers.

E.g. by adding the one input mapping key and 2 axis to the Rolling Template, you can roll the ball by the pitch and roll of your hand and jump by closing your fist or pinching.

##How to use it - Blueprint - Event Driven##

You can Right click anywhere on Event graph and type 'Leap Event' and you will see all the available events you can receive.

###Example 'Debug Hand' graph###

with

###Result###

###Example Leap Image API### Supports memory efficient event driven api and leap api style polling

For both cases you need to inform the plugin that you want to receive images.

Note that you can control whether events are being emitted by toggling Emit Image events. It is recommended to disable both when not in use for performance and bandwidth reasons.

Example of a toggle

####Event Driven Example####

Which gives the following billboard results (note the finger and palm debug visualization is a result of a separate graph)

Distortion texture maps and other image parameters can be obtained by branching the LeapImage node (branched in the example graph to obtain the image id).

##Leap API Reference##

All the Blueprint nodes and functions keep the same name as specified in the documentation of leapmotion, refer to this documentation for help with the API. Events are custom named, but follow action oriented naming. Type 'Leap Event' in your blueprint event graph to see all possible events after adding the LeapEventInterface to your blueprint interfaces.

###Blueprint API Examples###

Not an exhaustive list, but common use list. See the leap motion documentation for full list.

####Events####

####Frame Functions####

####Hand Functions and Properties####

####Arm Functions and Properties####

####Finger Functions and Properties####

####Pointable Functions and Properties####



####Leap API Style Polling#### The same above result can be achieve by using Leap API style polling like this

Note that a difference between the two forms occurs when image event toggle is off. The plugin reclaims memory and uses no extra performance in the case of events, whereas polling based example will continue attempting to get a texture even if the allow images is off and will cause the plugin to warn the user to enable images every tick. To get the same functionality as the event driven format a separate boolean would need to be used to branch the execution to stop the log warning spam.

###Gestures### Require enabling before receiving events, below is an example of how to get the Circle gesture to emit and how to filter it.

With 0.7.2 the plugin supports the gesture sub-classes directly, here is an example of showing a debug sphere around the circle you are gesturing. Note that you can use the generic gesture detection event and cast the gesture to your sub-gesture or use the sub-gesture specific event. Both are equivalent.

##How to use it - Blueprint - Polling##

When you create a class blueprint you can add a component called LeapController, this contains all the functionality that the LeapController has specified in their API. From the controller you can get the frame and do what you want with features currently available.

Available blueprint classes branching from LeapController:

  • Arm
  • Bone
  • CircleGesture
  • Finger
  • FingerList
  • Frame
  • Gesture
  • GestureList
  • Hand
  • HandList
  • InteractionBox
  • KeyTapGesture
  • LeapImage
  • LeapImageList
  • Pointable
  • PointableList
  • ScreenTapGesture
  • SwipeGesture
  • Tool
  • ToolList

##Shipping/Packaged Builds##

  1. Projects require code, if you are using a blueprint only project, add an empty class and compile your project module. You simply do File->Add Code to Project and it can be anything so I usually just pick None->Create Class and then it will ask you to open visual studio where you just hit compile (Build solution). If you haven't added code before follow the unreal engine programming Quick Start guide. Essentially it boils down to downloading the free Visual Studio Community and changing a few small configs.
  2. Add the following line to your DefaultEngine.ini
  3. EnabledPlugins=LeapMotion

    under [Plugins], create this category if missing.

  4. Package your content
  5. In your packaged directory drag the Binaries folder from this plugin into your packaged project folder. E.g. if I have a packaged folder called LeapPluginTest find WindowsNoEditor/LeapPluginTest, this is your packaged project root. Add the binaries folder there.

###Shipping Troubleshooting###

  • If you get errors complaining 'Leap Motion' plugin cannot be found, you do not have code in your project.
  • If you get errors complaining the 'Leap.dll' is missing, you did not drag binaries to the correct location.

##Todo##

  • Convenience content (e.g. fully rigged hand)
  • Wiki
  • C++ how to

##Contact## Post issues to this github or the unreal thread.

##Credits## Event-driven fork by Getnamo.

Original Plugin by Marc Wieser.

About

Leap Motion plugin for Unreal Engine 4

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 99.4%
  • C# 0.6%