Announcement

Collapse
No announcement yet.

[Plugin] Leap Motion - Event Driven

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • [Plugin] Leap Motion - Event Driven

    An event-driven Leap Motion plugin.

    Forked MarcW's plugin to update to the latest Leap SDK and add support for event driven architecture. Since the architecture differs, this new thread is made pertaining to the fork. Expect to see some of these changes make it back to my other plugins (interfaces rock). Full source is provided at github, if you feel you can help, feel free to extend and contribute. Let me know if any bugs crop up!

    NB: Currently only supports Windows 64 & 32 and Mac OSX Platforms.

    Want to try Orion? just update your runtime and you'll get the higher accuracy tracking. NB: The current plugin has more latency than the unity version for now.

    Download
    Latest Stable (4.11 +) - It's already in the engine, just enable and restart!
    Latest Dev (4.11) - For in-between engine fixes and new feature tests

    Older
    0.9.9 for UE4.10 / Leap SDK 2.3.1 - Mac Binaries synced to 4.10
    0.9.7 for UE4.9 / Leap 2.3.1 - (Mac UE4.7)
    0.9.5 for UE4.8 / Leap 2.2.6 - (Mac UE4.7)
    0.9.3 for UE4.7 / Leap 2.2.4
    0.8.3 for UE4.6 / Leap 2.2.1
    0.8.1 for UE4.5 / Leap 2.2
    0.6.1 for UE4.4 / Leap 2.1.5

    Resources
    Github - Main Plugin Source and Documentation
    Leap Motion API documentation - Answers the question: How do I do X?
    Leap Community UE4 Plugin Thread

    How to Use

    1. Install plugin by Downloading and Draging Binaries and Plugins into your project root. (Optional content automatically included since 0.9, delete if you're not using it and you wish to save space)



    2. Open your project and confirm that the plugin is enabled (Window->Plugins, should be under Installed category).

    3A. Easy Option (Since 0.8):

    3A.1 Set your Character to LeapRiggedCharacter, Set your PlayerController to VRPlayerController (if using hmd). See Epic's game mode documentation if you're confused on how to change these.



    3A.2 Play to try it out! Use VRPreview for HMD mode (Do not use launch)



    3A.3 - Optional (since 0.9.3) If you want collision enabled for you fingers, simply change your collision preset to PhysicsActor. If you don't know what that is, use the convenience LeapCollisionCharacter instead of LeapRiggedCharacter. This allows you to interact with movable actors with physics enabled.



    3A.4 - Optional
    Pass-through is supported from 0.9, useful if you wish to blend real-world for AR purposes or simply wish to see where you type in vr.
    Simply select LeapPassthroughCharacter as your pawn and keep the controller as VRController


    3A.4 Play to try out AR/VR transition with a simple gesture


    Convenience content relation diagram


    This setup gives you a wide variety of points to sub-class or modify any convenience blueprint where you wish to change functionality.

    3B. Custom Option: Select the blueprint where you want to receive Leap Events, select Class Settings



    3B.1 Under Details find Interfaces and Add LeapEventInterface to your blueprint.
    3B.2 Add a Leap Controller component by clicking Add Component



    3B.3. (Optional) Right click event graph and from the LeapController set OptimizeForHMD to true if using leap mounted to hmd rather than default on table facing up, keep auto rotate and auto shift if you want the plugin to automatically shift the leap positions to account for HMD movement.

    Debug Hands

    The plugin is now ready to use. Right click on Event Graph and type 'Leap Events' to show all the events you receive, implement the ones you wish to respond to. If you saved your LeapController pointer as a variable, you can also poll any of the latest 60 frames using Leap API. Below is an example of how to get 'Debug Hands' via events.



    With Draw Debug Sphere At Actor defined as


    This will give you the following in the blank template with starter content.



    Please note that this is for the default mode (on table facing up) and you may need to adjust your leap-actor offset. For hmd mode with auto shift and rotate ticked, the values should be passed straight through (with added actor location if you're using debug spheres) as they are already automatically compensated due to the plugin knowing the position of the rift.

    Gestures
    Plugin supports Leap gesture api. You must first enable the gesture you wish to recognize and then listen for your event. Example gesture recognizer setup



    then you can do sub-gesture specific tasks either by casting your gesture to your sub-gesture or subscribing to the specific sub-gesture event. Example of receiving circle gesture event



    Input Mapping
    Useful for simple gameplay mechanics or input parts which behave like joystick axis or buttons. NB: You need to have a Leap Component present in any one of your active blueprints for input mapping events to emit, same as any other blueprint use.

    E.g. adding one input mapping key and 2 axis to the Rolling Template, allows you to roll the ball by the pitch and roll of your hand and jump by closing your fist. Simple fun!



    Changelist

    2.0.0
    -Integrated directly in 4.11 engine
    -Added Image Hands
    -Added Component Hands
    -Thorough code commenting
    -Automatic packaged support
    -Added convenience LeapFloatingHandsCharacter

    0.9.9
    -Updated Mac binary for 4.10

    0.9.8
    -Updated binaries to UE4.10

    0.9.7
    -Fixed packaging for 4.9.2
    -Added EnableBackgroundTracking toggle on LeapController allowing you to
    track when the window isn't focused
    -Updated Echo hands to hide when not being tracked, idle
    animations for Echo hands have been removed. Use
    LeapEchoHandsRiggedCharacter for a rigged mesh hand without attached
    body, use the collision variant for physics enabled version.

    0.9.6
    -Binaries synced with UE 4.9
    -Leap SDK synced with 2.3.1
    -Added Echo convenience hands (rigged floating hands)

    0.9.5
    -Updated binaries to UE4.8

    0.9.4
    -Updated Leap SDK to 2.2.6

    0.9.3
    -Added LeapCollisionCharacter which adds physics collision enabled by
    default. This can be enabled for other setups by using the PhysicsActor
    collision preset.
    -Updated PhysicsAsset used for collision
    -Removed old content
    -Fixed SphereRadius property link found on LeapHand

    0.9.2
    -Mac Binaries compiled for UE 4.7
    -Leap SDK, libs and dlls updated for SDK 2.2.4

    0.9.1
    -Cleaned up inheritence structure, LeapAnimBodyActor renamed to
    LeapAnimBodyConnector. Added Passthrough sub-class
    -LeapPassthroughCharacter now contains the subclass. Rigged characters
    contain no passthrough code
    -Fixed elbow rotation bug

    0.9
    -Added properly HMD warped image passthrough support through both
    materials and a convenience character (LeapPassthrougCharacter)
    -128bit texture support resolved for Distortion textures. Use Distortion
    for proper float data, use DistortioUE to visualize the texture for
    debug purposes.
    -Optional content moved into plugin, delete if you don't use it and wish
    to save space
    -Rigging update to be more loosely coupled. Character anim blueprint
    only depends on AnimBody obtained through a simple and safe
    AnimBodyInterface
    -Rigged character finger rotation bug fixed
    -Updated leap bind to 2.2.3, much improved tracking gained.
    -Added R->Reset position to rigged characters, change key bind to
    reflect own bindings

    0.8.3
    -Now supports Mac OSX
    -Fixed Finger->Hand crash on exit
    -Update to Leap SDK 2.2.1

    0.8.2
    -Now supports UE 4.6

    0.8.1
    -Fixed Memory leaks which would cause crash around 60second mark (GC
    interval) for list-based objects using extended and append
    -Added appendTools and appendFingers to pointableList
    -LeapFrame got its API updated to include all of the missing functions,
    should now reflect the leap api nearly completely (except 64bit values
    in blueprint that are not supported)
    -Added log entry with plugin version at game start for easier debugging

    0.8.0
    -Basic Rigged leap character added. Works like the LeapDebugCharacter,
    change your player controller to VRPlayercontroller and pawn to
    LeapRiggedCharacter
    -Updated bind to Leap SDK 2.2.0
    -Ensured consistency by prepending leap to all classes, this will likely
    break compatibility with old blueprints.
    -Fixed dynamic object allocation architecture
    -Added basic AnimBody, Hand, Finger, and Bone for convenient animation
    state and basis conversion.

    0.7.11
    -You can now check which finger you have by dragging out the Type
    property from Finger.

    0.7.10
    -Added a convenience Leap Debug Hand actor, allowing for easy display of
    debug hands
    -Added a convenience Leap Debug Character which is set up to show debug
    hands in both HMD and Default mode. Simply toggle your hmd (alt+enter)
    to test HMD mode.

    0.7.9
    -added Input Mapping support for pinch grab and palm orientation for
    each hand. See documentation for details
    -added PalmOrientation convenience function to Leap Hand. Origin is
    defined as palm flat facing down, fingers pointing away.

    0.7.8
    -Update to Leap SDK 2.1.6. Includes changes from leap
    (https://developer.leapmotion.com/doc...#version-2-1-6)

    0.7.7
    -If you tick auto-shift on hmd, this will automatically add the
    eye->leapmount offset (8cm default value). Your vr hands should now be
    completely 1:1
    -Added Hand Type enum to Hand and relevant gestures. You can now easily
    switch the hand type instead of checking isLeft/Right to reduce bp
    clutter.
    -Added Leap Plugin Direction (Cardinal Direction) to gestures which
    emit directions (Screen Tap, Key Tap, and Swipe). This is a convenience
    property which will allow you to easily switch the property to get basic
    swipe left/right/up/down/towards/away detection. If you need a more
    precise direction, use the direction vector.

    0.7.6
    -Added Raw Image events which give much cleaner support and memory
    efficient toggling of streaming images from the device.
    -Multiple components are now properly supported. Reason for error was
    mismanaged GC of on-demand UObject subclasses. Plugin will still emit
    multi-component warning for performance reasons (redundancy/duplication).
    -All logging switched to LeapPluginLog sub-category

    0.7.5
    -At the moment multiple components cause a crash after 40-60sec of
    detecting a hand/finger, until this error is resolved, the plugin will
    output a warning to your logs if you add more than one total leap
    component

    0.7.4
    -Normalized vectors such as palm normal were not properly adjusted for
    HMD view direction, this is has now been fixed.

    0.7.3
    -palm normal scaling fixed.

    0.7.2
    -Circle gesture radius now in UE scale
    -Swipe Gesture speed now in UE scale

    0.7.1
    -Hidden Leap header and private implementation from UClasses
    -Fixed image stability, will now correctly resize when requested.
    -R8 texture no longer causes memory leaks
    -Added Gesture sub-classes and corresponding events (e.g. Swipe Gesture
    Detected). Will allow for easy determination of direction and other
    properties of gestures. You can also cast general gesture detection to
    the correct sub-class gesture.
    -Added own category of logging, pay attention to log output to help you
    with debugging errors.

    0.7
    -Added full support for Image API! see post or github readme for an example use case.
    -Fixed a lot of memory leaks, should have no more memory leaks and purr like a kitten.

    0.6.4
    -Fixed lack of categorization caused by previous updates in some of the blueprints classes
    -Cleaned up a lot of the blueprint functions, turning all the relevant
    ones into properties. This will reduce the number of execution pins.
    -Things which return a new object generally remain a function for
    potential performance reasons

    0.6.3
    -Changed plugin to runtime to support shipping builds
    -See the github readme for shipping/packaging instructions.

    0.6.2
    -Updated to UE4.5
    -Removed the need to SetInterfaceDelegate! Just adding the Component and
    adding the LeapEventInterface is enough.
    -Added Image policy flag support, actual image handling is still not
    working at this time. You can query about image dimension and other
    stats, just not the raw image.

    0.6.1
    -OptimizeForHMD now contains 2 more booleans, one for auto rotation
    adjustment and one for auto position adjustment. Setting all three to
    enabled will make your reported leap positions automatically adjust for
    your head position and look direction. VR easy mode enabled!

    0.6
    -Setting policy to optimize for hmd will automatically rotate position
    data
    -Fixed pinch detection stability, grabbing will now override pinching
    event
    -Changed event names to better reflect their purpose
    -Added gesture event, set gesture support at startup to receive this
    event
    -Added polling data for: interaction box, pointables, gestures, images
    (basic support)

    0.5.2
    -Added Event Driven architecture, Add LeapEventInterface to your
    blueprint class and call LeapController->SetDelegate(self). Your class
    will now receive leap events.
    -Added Arm support, please see official leap documentation for reference
    -Plugin now automatically converts leap space position data to UE space
    data including scale (mm->cm)
    -Added support for HMD Optimized tracking (also known as top down
    tracking). Set OptimizeForHMD(true) on your LeapController.

    0.5.1
    -Updated to Leap SDK 2.1.5+22693
    -Enabled getting finger data. Use Hand->Fingers

    0.5.0
    -compile fixes and updated to UE4.4

    Todo:
    -Launch build fix (launch standalone, PIE, and shipping/packaging work without issues)
    Last edited by getnamo; 02-14-2017, 02:45 PM.
    Plugins: TensorFlow - Socket.io Client - ZipUtility - Leap Motion - Hydra - Myo - RealSense - CIM

  • #2
    Hey man, came from the Leap forums! I like this, perfect for what I want to do. Am going to give it a try and see what I can do with it

    Your documentation and explanation is awesome by the way!

    Comment


    • #3
      Hello. I have a question.

      This did not work for OptimizeForHMD set true.

      Will need to have the OVR?

      Comment


      • #4
        Updated plugin to v0.6 with the following changes:

        -Setting policy to optimize for hmd will automatically rotate position
        data
        -Fixed pinch detection stability, grabbing will now override pinching
        event
        -Changed event names to better reflect their purpose
        -Added gesture event, set gesture support at startup to receive
        gesture events (refer to leap api)
        -Added polling data for: interaction box, pointables, gestures, images
        (basic support)


        Originally posted by simpple View Post
        Hello. I have a question.

        This did not work for OptimizeForHMD set true.

        Will need to have the OVR?
        This was working according to the leap api, it expected you to do rotations manually.

        Since this is the expected use case, I've added automatic rotation changes when you enable optimize for HMD, try again and let me know if that is what you wanted.

        Edit: 0.6 only adjusted for front facing rotation, 0.6.1 added HMD orientation and position adjustments as additional options for OptimizeForHMD.
        Last edited by getnamo; 10-12-2014, 11:11 PM.
        Plugins: TensorFlow - Socket.io Client - ZipUtility - Leap Motion - Hydra - Myo - RealSense - CIM

        Comment


        • #5
          Originally posted by simpple View Post
          This did not work for OptimizeForHMD set true.
          First off thanks for the contribution! Hopefully between what you have going on here and what Leap has going on in their forums we'll eventually get an official LeapMotion plugin for UE4.

          Anyways, I am also developing for the Oculus Rift, and using the above blueprint event graph layout with OptmizeForHMD checked. The debug boxes only draw in any meaningful relation to my character when I look straight up at the ceiling where the Leap is in it's Non-HMD orientation. This could be tied to the fact that I'm using a first person template and not third person as you were, and may require some additional rotations/translations to place the debug spheres properly in relation to the headset.

          Note sure if it's relevant, but Leap (https://developer.leapmotion.com/vr) says, "starting with v2.1.3, you must set the policy flags POLICY_IMAGES and POLICY_OPTIMIZE_HMD to access the Image API and head-mounted tracking in your application".

          Hoping to have the time in the near future to start digging through their VRIntro source code.
          Last edited by spyderweb; 10-12-2014, 07:17 PM.

          Comment


          • #6
            Updated plugin to 0.6.1 which contains convenience options for VRMode.

            You will now see autoRotation and autoShift booleans in addition to useTopdown for OptimizeForHMD. Setting all three to enabled will make your reported leap positions automatically adjust for your head position and look direction.

            VR easy mode enabled!

            Note sure if it's relevant, but Leap (https://developer.leapmotion.com/vr) says, "starting with v2.1.3, you must set the policy flags POLICY_IMAGES and POLICY_OPTIMIZE_HMD to access the Image API and head-mounted tracking in your application".
            This is what OptimizeforHMD does. Image API is currently the only real feature not properly supported (may get to it at some point).

            Anyways, I am also developing for the Oculus Rift, and using the above blueprint event graph layout with OptmizeForHMD checked. The debug boxes only draw in any meaningful relation to my character when I look straight up at the ceiling where the Leap is in it's Non-HMD orientation. This could be tied to the fact that I'm using a first person template and not third person as you were, and may require some additional rotations/translations to place the debug spheres properly in relation to the headset.
            Try the auto-rotation and auto-shift options and let me know if that fixes things! If you're using the VR mode I suggest you shrink the debug spheres radius and scale to 1 as this will give that 1:1 feel.
            Plugins: TensorFlow - Socket.io Client - ZipUtility - Leap Motion - Hydra - Myo - RealSense - CIM

            Comment


            • #7
              Thank you so much for this! Finally an easy way to experiment with the leap and vr in ue4.

              The raw image support would be interesting for me only in the sense that it would enable a somewhat easy port of this which is essential for a tracking thing I'm trying. (opentrack use in ue4 is somewhat problematic for me)

              Comment


              • #8
                Update to 0.6.2
                -Updated to UE4.5
                -Removed the need to SetInterfaceDelegate! Just adding the Component and
                adding the LeapEventInterface is enough.
                -Added Image policy flag support, actual image handling is still not
                working at this time. You can query about image dimension and other
                stats, just not the raw image.

                Updated documentation to reflect newer options and added some documentation regarding gestures. Full image support is missing at this time.
                Plugins: TensorFlow - Socket.io Client - ZipUtility - Leap Motion - Hydra - Myo - RealSense - CIM

                Comment


                • #9
                  Hi,
                  and thanks for sharing this plugin with us .
                  However.. I'm currently having a problem with the plugin.. as soon as I add the interface to my controller (MyController) and launches the project I end up with a message saying "Fatal error!" and that the game crashed and the message that's displayed refers to a bunch of addresses and paths (as far as I can tell all the paths do exist).

                  I have added the Bin and Plugin folders and all the files to my project, and the plugin is enabled.

                  Im using the latest Leap SDK and UE4.4.3, I have also confirmed that my leap is working with other leap projects.
                  Im not sure if it matters but Im using Windows 8.1 x64.. if that's helpful in some way .

                  Any ideas?

                  Comment


                  • #10
                    Hi !! First I want to thank you very much for your plugin I was waiting a lot for that !!
                    I was wondering if you could explain me if there is a way to allow the hands to follow the same rotation of the character Root (Capsule Component) ? ^^
                    When i am rotating my character, the hand doesn't rotate :'[
                    Thank you !
                    Last edited by Xeno; 10-15-2014, 06:20 PM.

                    Comment


                    • #11
                      Originally posted by Inx51 View Post
                      Hi,
                      and thanks for sharing this plugin with us .
                      However.. I'm currently having a problem with the plugin.. as soon as I add the interface to my controller (MyController) and launches the project I end up with a message saying "Fatal error!" and that the game crashed and the message that's displayed refers to a bunch of addresses and paths (as far as I can tell all the paths do exist).

                      I have added the Bin and Plugin folders and all the files to my project, and the plugin is enabled.

                      Im using the latest Leap SDK and UE4.4.3, I have also confirmed that my leap is working with other leap projects.
                      Im not sure if it matters but Im using Windows 8.1 x64.. if that's helpful in some way .

                      Any ideas?
                      Ok.. so I just tried the updated version of the plugin with UE4.5 and also changed my projects directory to the default path... but now I keep getting this error:
                      Click image for larger version

Name:	Capture.PNG
Views:	1
Size:	74.2 KB
ID:	1057835
                      Any ideas?

                      If its possible it would be really nice to have a sample project to test with to make sure that I have setup everything right
                      Last edited by Inx51; 10-15-2014, 07:01 PM.

                      Comment


                      • #12
                        Originally posted by Inx51 View Post
                        Ok.. so I just tried the updated version of the plugin with UE4.5 and also changed my projects directory to the default path... but now I keep getting this error:
                        ...
                        Any ideas?

                        If its possible it would be really nice to have a sample project to test with to make sure that I have setup everything right
                        Just did a blank project (no code) test with the currently uploaded 0.6.2 plugin from this page (github download), it worked without problems.

                        Please ensure you're installing this correctly



                        Also check that you're using the Windows x64 platform (XP/Vista/7/8 x64), I have not tested this plugin for any other platform and will need to add relevant binaries before it will work. If both of those cases are correct and it is still not working, send me your logs (found in {ProjectRoot}/Saved/Logs)

                        Originally posted by Xeno
                        Hi !! First I want to thank you very much for your plugin I was waiting a lot for that !!
                        I was wondering if you could explain me if there is a way to allow the hands to follow the same rotation of the character Root (Capsule Component) ? ^^
                        When i am rotating my character, the hand doesn't rotate :'[
                        Thank you !
                        You have to rotate the positions you get from your leap by your control rotation like so


                        Make sure the order you do this is correct as it will rotate the vector around its origin. In most cases this will be before you convert it to world space.
                        Plugins: TensorFlow - Socket.io Client - ZipUtility - Leap Motion - Hydra - Myo - RealSense - CIM

                        Comment


                        • #13
                          Thank you very much it's working perfectly !! Have a good day !!!

                          Comment


                          • #14
                            Hey, Is there anywhere where I can download an example project? Thanks, Lewis

                            Comment


                            • #15
                              Update to 0.6.3
                              -Changed plugin to runtime to support shipping builds
                              -See the github readme for shipping/packaging instructions.

                              Originally posted by Inx51 View Post
                              Ok.. so I just tried the updated version of the plugin with UE4.5 and also changed my projects directory to the default path... but now I keep getting this error:
                              Any ideas?

                              If its possible it would be really nice to have a sample project to test with to make sure that I have setup everything right
                              This was happening because of launching v0.6.2 or lower version of the plugin which didn't have packaged/shipping support. Download 0.6.3 plugin or later and see the github readme for shipping/packaging instructions.

                              Originally posted by lewisq View Post
                              Hey, Is there anywhere where I can download an example project? Thanks, Lewis
                              I don't plan on including an example project as it is two simple steps to include leap support. Follow the how to instructions and you will be up and running in a few minutes.
                              Last edited by getnamo; 10-16-2014, 05:27 PM.
                              Plugins: TensorFlow - Socket.io Client - ZipUtility - Leap Motion - Hydra - Myo - RealSense - CIM

                              Comment

                              Working...
                              X