Leap Motion Controller DeviceΒΆ
Implementation of the Leap Motion device.
It bridges access to Leap API. You shouldn’t use this in your code. Use LeapMotionFunctionLibrary, or LeapMotionControllerActor instead.
Public Functionsconst Leap::Frame Frame()Gets the cached reference frame.
Call SetReferenceFrameOncePerTick() before the first access to this variable during a tick.
Data in a Leap::Frame object has not been transformed into the Unreal Engine frame of reference or unit system.
bool GetAllHandsIds(TArray< int32 > & OutAllHandIds)Returns list of IDs of all hands tracked by the device.
- Return
- True, if the device is connected
- Parameters
- OutAllHandIds -
An output array set to contain the ids of all tracked hands.
bool GetBonePostionAndOrientation(int32 HandId, ELeapBone LeapBone, FVector & OutPosition, FRotator & OutOrientation)Gets the position and orientation of the specified hand from the device.
Data returned by this function is relative to the Unreal Engine origin rather than a particular LeapMotionControllerComponent or LeapMotionHandActor instance. Get the properties of a LeapMotionBoneActor instance to get the data relative to that actor’s parent hand actor and controller component. In this case, use the standard Unreal Actor location and rotation properties.
- Return
- True if a hand with the specified id exists, false otherwise
- Parameters
- HandId -
The id of the hand of interest.
- LeapBone -
Which hand bone to get position & orientation for
- OutPosition -
An FVector set to the relative position of the hand, or zero if the hand wasn’t detected this frame.
- OutOrientation -
An FRotator set to the relative orientation of the hand, or zero if the hand wasn’t detected this frame.
bool GetBoneWidthAndLength(int32 HandId, ELeapBone LeapBone, float & OutWidth, float & OutLength)Gets the width and length of the specified bone of a hand from the device.
- Return
- True if the hand was detected and bone was identified, false otherwise
- Parameters
- HandId -
The id of the hand of interest.
- LeapBone -
The bone of interest.
- OutWidth -
A float set to the bone’s width (in centimeters).
- OutLength -
A float set to the bone’s length (in centimeters).
bool GetGrabStrength(int32 HandId, float & OutGrabStrength)The grab strength rating of the specified hand.
Grab strength is a rating of how the hand’s posture resembles a fist. A strength of 0 is close to an open, flat hand; a strength of 1 is close to a fist.
- Return
- True, if the hand with the specified id exists, false otherwise.
- Parameters
- HandId -
The id of the hand of interest.
- OutGrabStrength -
A float set to the hand’s grabbing strength as reported by Leap API.
bool GetIsHandLeft(int32 HandId, bool & OutIsLeft)Reports whether the specified hand us identified as a left or a right hand.
- Return
- True if a hand of the specified type exists, false otherwise.
- Parameters
- HandId -
The id of the hand of interest.
- OutIsLeft -
A bool set to true if the specified hand is a left hand.
bool GetOldestLeftOrRightHandId(ELeapSide LeapSide, int32 & OutHandId)Returns the oldest left- or right-hand actor, if one exists, nullptr otherwise.
If more than one left or right hand is being tracked, this function returns the one that has been tracked the longest.
- Return
- True if a hand of the specified type exists, false otherwise.
- Parameters
- LeapSide -
Look for a left or a right hand.
- OutHandId -
An integer set to the Leap Motion id of the oldest left or right hand. If no hand is found, this is set to -1.
bool GetPinchStrength(int32 HandId, float & OutPinchStrength)The pinch strength rating of the specified hand.
Pinch strength is a rating of whether the hand is in a pinching posture. Pinch strength starts at 0 and increases to 1 as any finger tip approaches the tip of the thumb. Note that pinch and grab strength are not independent. A grabbing hand will generally have a non-zero pinch strength as well.
- Return
- True, if the hand with the specified id exists, false otherwise.
- Parameters
- HandId -
The id of the hand of interest.
- OutPinchStrength -
A float set to the hand’s pinch strength as reported by Leap API
bool IsConnected()Checks whether or not the device is connected and ready to be polled for data.
- Return
- True if controller is connected, false otherwise.
bool SetHmdPolicy(bool UseHmdPolicy)Enables or disables the Leap Motion Controller policy that improves tracking for an HMD-mounted controller.
Note that calling this function does not change the transforms of any LeapMotionControllerComponent instances that may exist.
- Return
- True if the device is connected.
- Parameters
- UseHmdPolicy -
True to enable for HMD-mounted mode, false to disable.
bool SetImagePolicy(bool UseImagePolicy)Enables or disables the Leap Motion Controller policy that transmits image data.
Note that calling this function does not change the transforms of any LeapMotionControllerComponent instances that may exist.
- Return
- True if the device is connected.
- Parameters
- UseImagePolicy -
True to enable for image pass-through, false to disable.
void SetReferenceFrameOncePerTick()Caches the current Leap::Frame as a reference.
Call once per Unreal frame tick, and before any other calls to LeapMotionDevice on that frame tick. The Leap Motion software produces frames of data at a rate independent of the Unreal Engine. Cache the frame so that subsequent calls to get data from the device use the same data.
Calling the function a second time in the same tick has no affect, but it does need to be called at least once.
void ShutdownDevice()Tear down the device.
bool StartupDevice()Startup the device, and do any initialization that may be needed.