Unity Modules
Leap Motion's Unity SDK
4.4.0
LeapServiceProvider Class Reference

The LeapServiceProvider provides tracked Leap Hand data and images from the device via the Leap service running on the client machine. More...

Inheritance diagram for LeapServiceProvider:
LeapProvider LeapXRServiceProvider

Public Types

Public Member Functions

float CalculatePhysicsExtrapolation ()
 
Controller GetLeapController ()
 Returns the Leap Controller instance. More...
 
bool IsConnected ()
 Returns true if the Leap Motion hardware is plugged in and this application is connected to the Leap Motion service. More...
 
void RetransformFrames ()
 Retransforms hand data from Leap space to the space of the Unity transform. This is only necessary if you're moving the LeapServiceProvider around in a custom script and trying to access Hand data from it directly afterward. More...
 
void CopySettingsToLeapXRServiceProvider (LeapXRServiceProvider leapXRServiceProvider)
 Copies property settings from this LeapServiceProvider to the target LeapXRServiceProvider where applicable. Does not modify any XR-specific settings that only exist on the LeapXRServiceProvider. More...
 

Public Attributes

TestHandPose editTimePose
 

Protected Member Functions

virtual void Reset ()
 
virtual void Awake ()
 
virtual void Start ()
 
virtual void Update ()
 
virtual void FixedUpdate ()
 
virtual void OnDestroy ()
 
virtual void OnApplicationPause (bool isPaused)
 
virtual void OnApplicationQuit ()
 
virtual long CalculateInterpolationTime (bool endOfFrame=false)
 
virtual void initializeFlags ()
 Initializes Leap Motion policy flags. More...
 
void createController ()
 Creates an instance of a Controller, initializing its policy flags and subscribing to its connection event. More...
 
void destroyController ()
 Stops the connection for the existing instance of a Controller, clearing old policy flags and resetting the Controller to null. More...
 
bool checkConnectionIntegrity ()
 Checks whether this provider is connected to a service; If it is not, attempt to reconnect at regular intervals for MAX_RECONNECTION_ATTEMPTS More...
 
void onHandControllerConnect (object sender, LeapEventArgs args)
 
virtual void transformFrame (Frame source, Frame dest)
 
void DispatchUpdateFrameEvent (Frame frame)
 
void DispatchFixedFrameEvent (Frame frame)
 

Protected Attributes

const double NS_TO_S
 Converts nanoseconds to seconds. More...
 
const double S_TO_NS
 Converts seconds to nanoseconds. More...
 
const string HAND_ARRAY_GLOBAL_NAME
 The transform array used for late-latching. More...
 
const int MAX_RECONNECTION_ATTEMPTS
 The maximum number of times the provider will attempt to reconnect to the service before giving up. More...
 
const int RECONNECTION_INTERVAL
 The number of frames to wait between each reconnection attempt. More...
 
FrameOptimizationMode _frameOptimization
 
PhysicsExtrapolationMode _physicsExtrapolation
 
float _physicsExtrapolationTime
 
bool _workerThreadProfiling
 
bool _useInterpolation
 
int ExtrapolationAmount
 
int BounceAmount
 
Controller _leapController
 
bool _isDestroyed
 
SmoothedFloat _fixedOffset
 
SmoothedFloat _smoothedTrackingLatency
 
long _unityToLeapOffset
 
Frame _untransformedUpdateFrame
 
Frame _transformedUpdateFrame
 
Frame _untransformedFixedFrame
 
Frame _transformedFixedFrame
 

Properties

Action< DeviceOnDeviceSafe
 A utility event to get a callback whenever a new device is connected to the service. This callback will ALSO trigger a callback upon subscription if a device is already connected. More...
 
override Frame CurrentFrame [get]
 
override Frame CurrentFixedFrame [get]
 

Events

Action< FrameOnUpdateFrame
 
Action< FrameOnFixedFrame
 

Detailed Description

The LeapServiceProvider provides tracked Leap Hand data and images from the device via the Leap service running on the client machine.

Member Enumeration Documentation

enum FrameOptimizationMode
strong
Enumerator
None 
ReuseUpdateForPhysics 
ReusePhysicsForUpdate 
Enumerator
None 
Auto 
Manual 

Member Function Documentation

virtual void Awake ( )
protectedvirtual
virtual long CalculateInterpolationTime ( bool  endOfFrame = false)
protectedvirtual
float CalculatePhysicsExtrapolation ( )
bool checkConnectionIntegrity ( )
protected

Checks whether this provider is connected to a service; If it is not, attempt to reconnect at regular intervals for MAX_RECONNECTION_ATTEMPTS

Referenced by LeapServiceProvider.Update().

void CopySettingsToLeapXRServiceProvider ( LeapXRServiceProvider  leapXRServiceProvider)

Copies property settings from this LeapServiceProvider to the target LeapXRServiceProvider where applicable. Does not modify any XR-specific settings that only exist on the LeapXRServiceProvider.

Referenced by OldRigHierarchy.Upgrade().

void createController ( )
protected

Creates an instance of a Controller, initializing its policy flags and subscribing to its connection event.

Referenced by LeapServiceProvider.checkConnectionIntegrity(), LeapServiceProvider.GetLeapController(), and LeapServiceProvider.Start().

void destroyController ( )
protected

Stops the connection for the existing instance of a Controller, clearing old policy flags and resetting the Controller to null.

Referenced by LeapServiceProvider.checkConnectionIntegrity(), LeapServiceProvider.OnApplicationQuit(), and LeapServiceProvider.OnDestroy().

void DispatchFixedFrameEvent ( Frame  frame)
protectedinherited
void DispatchUpdateFrameEvent ( Frame  frame)
protectedinherited
virtual void FixedUpdate ( )
protectedvirtual
Controller GetLeapController ( )

Returns the Leap Controller instance.

Referenced by LeapServiceProvider.IsConnected(), and LeapImageRetriever.EyeTextureData.UpdateTextures().

virtual void initializeFlags ( )
protectedvirtual

Initializes Leap Motion policy flags.

Reimplemented in LeapXRServiceProvider.

Referenced by LeapServiceProvider.createController(), and LeapServiceProvider.onHandControllerConnect().

bool IsConnected ( )

Returns true if the Leap Motion hardware is plugged in and this application is connected to the Leap Motion service.

virtual void OnApplicationPause ( bool  isPaused)
protectedvirtual
virtual void OnApplicationQuit ( )
protectedvirtual
virtual void OnDestroy ( )
protectedvirtual
void onHandControllerConnect ( object  sender,
LeapEventArgs  args 
)
protected
virtual void Reset ( )
protectedvirtual

Reimplemented in LeapXRServiceProvider.

void RetransformFrames ( )

Retransforms hand data from Leap space to the space of the Unity transform. This is only necessary if you're moving the LeapServiceProvider around in a custom script and trying to access Hand data from it directly afterward.

virtual void Start ( )
protectedvirtual

Reimplemented in LeapXRServiceProvider.

virtual void transformFrame ( Frame  source,
Frame  dest 
)
protectedvirtual
virtual void Update ( )
protectedvirtual

Reimplemented in LeapXRServiceProvider.

Member Data Documentation

SmoothedFloat _fixedOffset
protected
bool _isDestroyed
protected
SmoothedFloat _smoothedTrackingLatency
protected
Frame _transformedFixedFrame
protected
Frame _transformedUpdateFrame
protected
long _unityToLeapOffset
protected
Frame _untransformedFixedFrame
protected
Frame _untransformedUpdateFrame
protected
bool _useInterpolation
protected
bool _workerThreadProfiling
protected
int BounceAmount
protected
TestHandPose editTimePose
inherited
int ExtrapolationAmount
protected
const string HAND_ARRAY_GLOBAL_NAME
protected

The transform array used for late-latching.

Referenced by LeapXRServiceProvider.OnPreCullHandTransforms(), and LeapXRServiceProvider.resetShaderTransforms().

const int MAX_RECONNECTION_ATTEMPTS
protected

The maximum number of times the provider will attempt to reconnect to the service before giving up.

const double NS_TO_S
protected

Converts nanoseconds to seconds.

const int RECONNECTION_INTERVAL
protected

The number of frames to wait between each reconnection attempt.

const double S_TO_NS
protected

Converts seconds to nanoseconds.

Referenced by LeapXRServiceProvider.CalculateInterpolationTime().

Property Documentation

override Frame CurrentFixedFrame
get
Action<Device> OnDeviceSafe
addremove

A utility event to get a callback whenever a new device is connected to the service. This callback will ALSO trigger a callback upon subscription if a device is already connected.

For situations with multiple devices OnDeviceSafe will be dispatched once for each device.

Event Documentation