Tanoda
Leap.Unity.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 Leap.Unity.LeapServiceProvider:
Leap.Unity.LeapProvider Leap.Unity.LeapXRServiceProvider

Public Types

enum  InteractionVolumeVisualization { None , LeapMotionController , StereoIR170 , Automatic }
 
enum  FrameOptimizationMode { None , ReuseUpdateForPhysics , ReusePhysicsForUpdate }
 
enum  PhysicsExtrapolationMode { None , Auto , Manual }
 
enum  TrackingOptimizationMode { Desktop , ScreenTop , HMD }
 

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...
 

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)
 
- Protected Member Functions inherited from Leap.Unity.LeapProvider
void DispatchUpdateFrameEvent (Frame frame)
 
void DispatchFixedFrameEvent (Frame frame)
 

Protected Attributes

InteractionVolumeVisualization _interactionVolumeVisualization = InteractionVolumeVisualization.LeapMotionController
 
FrameOptimizationMode _frameOptimization = FrameOptimizationMode.None
 
PhysicsExtrapolationMode _physicsExtrapolation = PhysicsExtrapolationMode.Auto
 
float _physicsExtrapolationTime = 1.0f / 90.0f
 
TrackingOptimizationMode _trackingOptimization = TrackingOptimizationMode.Desktop
 
bool _workerThreadProfiling = false
 
string _serverNameSpace = "Leap Service"
 
bool _useInterpolation = true
 
int ExtrapolationAmount = 0
 
int BounceAmount = 0
 
Controller _leapController
 
bool _isDestroyed
 
SmoothedFloat _fixedOffset = new SmoothedFloat()
 
SmoothedFloat _smoothedTrackingLatency = new SmoothedFloat()
 
long _unityToLeapOffset
 
Frame _untransformedUpdateFrame
 
Frame _transformedUpdateFrame
 
Frame _untransformedFixedFrame
 
Frame _transformedFixedFrame
 

Static Protected Attributes

const double NS_TO_S = 1e-6
 Converts nanoseconds to seconds. More...
 
const double S_TO_NS = 1e6
 Converts seconds to nanoseconds. More...
 
const string HAND_ARRAY_GLOBAL_NAME = "_LeapHandTransforms"
 The transform array used for late-latching. More...
 
const int MAX_RECONNECTION_ATTEMPTS = 5
 The maximum number of times the provider will attempt to reconnect to the service before giving up. More...
 
const int RECONNECTION_INTERVAL = 180
 The number of frames to wait between each reconnection attempt. More...
 

Properties

InteractionVolumeVisualization SelectedInteractionVolumeVisualization [get]
 
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]
 
- Properties inherited from Leap.Unity.LeapProvider
abstract Frame CurrentFrame [get]
 The current frame for this update cycle, in world space. More...
 
abstract Frame CurrentFixedFrame [get]
 The current frame for this fixed update cycle, in world space. More...
 

Additional Inherited Members

- Public Attributes inherited from Leap.Unity.LeapProvider
TestHandPose editTimePose = TestHandPose.HeadMountedA
 
- Events inherited from Leap.Unity.LeapProvider
Action< FrameOnUpdateFrame
 
Action< FrameOnFixedFrame
 
Action< FrameOnPostUpdateFrame
 

Detailed Description

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

Definition at line 20 of file LeapServiceProvider.cs.

Member Enumeration Documentation

◆ FrameOptimizationMode

Enumerator
None 
ReuseUpdateForPhysics 
ReusePhysicsForUpdate 

Definition at line 67 of file LeapServiceProvider.cs.

◆ InteractionVolumeVisualization

Enumerator
None 
LeapMotionController 
StereoIR170 
Automatic 

Definition at line 55 of file LeapServiceProvider.cs.

◆ PhysicsExtrapolationMode

Enumerator
None 
Auto 
Manual 

Definition at line 76 of file LeapServiceProvider.cs.

◆ TrackingOptimizationMode

Enumerator
Desktop 
ScreenTop 
HMD 

Definition at line 92 of file LeapServiceProvider.cs.

Member Function Documentation

◆ Awake()

virtual void Leap.Unity.LeapServiceProvider.Awake ( )
protectedvirtual

Definition at line 278 of file LeapServiceProvider.cs.

◆ CalculateInterpolationTime()

virtual long Leap.Unity.LeapServiceProvider.CalculateInterpolationTime ( bool  endOfFrame = false)
protectedvirtual

Reimplemented in Leap.Unity.LeapXRServiceProvider.

Definition at line 463 of file LeapServiceProvider.cs.

◆ CalculatePhysicsExtrapolation()

float Leap.Unity.LeapServiceProvider.CalculatePhysicsExtrapolation ( )

Definition at line 396 of file LeapServiceProvider.cs.

◆ checkConnectionIntegrity()

bool Leap.Unity.LeapServiceProvider.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

Definition at line 554 of file LeapServiceProvider.cs.

◆ CopySettingsToLeapXRServiceProvider()

void Leap.Unity.LeapServiceProvider.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.

Definition at line 450 of file LeapServiceProvider.cs.

◆ createController()

void Leap.Unity.LeapServiceProvider.createController ( )
protected

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

Definition at line 502 of file LeapServiceProvider.cs.

◆ destroyController()

void Leap.Unity.LeapServiceProvider.destroyController ( )
protected

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

Definition at line 535 of file LeapServiceProvider.cs.

◆ FixedUpdate()

virtual void Leap.Unity.LeapServiceProvider.FixedUpdate ( )
protectedvirtual

Definition at line 334 of file LeapServiceProvider.cs.

◆ GetLeapController()

Controller Leap.Unity.LeapServiceProvider.GetLeapController ( )

Returns the Leap Controller instance.

Definition at line 417 of file LeapServiceProvider.cs.

◆ initializeFlags()

virtual void Leap.Unity.LeapServiceProvider.initializeFlags ( )
protectedvirtual

Initializes Leap Motion policy flags.

Reimplemented in Leap.Unity.LeapXRServiceProvider.

Definition at line 478 of file LeapServiceProvider.cs.

◆ IsConnected()

bool Leap.Unity.LeapServiceProvider.IsConnected ( )

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

Definition at line 431 of file LeapServiceProvider.cs.

◆ OnApplicationPause()

virtual void Leap.Unity.LeapServiceProvider.OnApplicationPause ( bool  isPaused)
protectedvirtual

Definition at line 380 of file LeapServiceProvider.cs.

◆ OnApplicationQuit()

virtual void Leap.Unity.LeapServiceProvider.OnApplicationQuit ( )
protectedvirtual

Definition at line 391 of file LeapServiceProvider.cs.

◆ OnDestroy()

virtual void Leap.Unity.LeapServiceProvider.OnDestroy ( )
protectedvirtual

Definition at line 375 of file LeapServiceProvider.cs.

◆ onHandControllerConnect()

void Leap.Unity.LeapServiceProvider.onHandControllerConnect ( object  sender,
LeapEventArgs  args 
)
protected

Definition at line 578 of file LeapServiceProvider.cs.

◆ Reset()

virtual void Leap.Unity.LeapServiceProvider.Reset ( )
protectedvirtual

Reimplemented in Leap.Unity.LeapXRServiceProvider.

Definition at line 274 of file LeapServiceProvider.cs.

◆ RetransformFrames()

void Leap.Unity.LeapServiceProvider.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.

Definition at line 440 of file LeapServiceProvider.cs.

◆ Start()

virtual void Leap.Unity.LeapServiceProvider.Start ( )
protectedvirtual

Reimplemented in Leap.Unity.LeapXRServiceProvider.

Definition at line 283 of file LeapServiceProvider.cs.

◆ transformFrame()

virtual void Leap.Unity.LeapServiceProvider.transformFrame ( Frame  source,
Frame  dest 
)
protectedvirtual

Reimplemented in Leap.Unity.LeapXRServiceProvider.

Definition at line 586 of file LeapServiceProvider.cs.

◆ Update()

virtual void Leap.Unity.LeapServiceProvider.Update ( )
protectedvirtual

Reimplemented in Leap.Unity.LeapXRServiceProvider.

Definition at line 291 of file LeapServiceProvider.cs.

Member Data Documentation

◆ _fixedOffset

SmoothedFloat Leap.Unity.LeapServiceProvider._fixedOffset = new SmoothedFloat()
protected

Definition at line 137 of file LeapServiceProvider.cs.

◆ _frameOptimization

FrameOptimizationMode Leap.Unity.LeapServiceProvider._frameOptimization = FrameOptimizationMode.None
protected

Definition at line 74 of file LeapServiceProvider.cs.

◆ _interactionVolumeVisualization

InteractionVolumeVisualization Leap.Unity.LeapServiceProvider._interactionVolumeVisualization = InteractionVolumeVisualization.LeapMotionController
protected

Definition at line 63 of file LeapServiceProvider.cs.

◆ _isDestroyed

bool Leap.Unity.LeapServiceProvider._isDestroyed
protected

Definition at line 135 of file LeapServiceProvider.cs.

◆ _leapController

Controller Leap.Unity.LeapServiceProvider._leapController
protected

Definition at line 134 of file LeapServiceProvider.cs.

◆ _physicsExtrapolation

PhysicsExtrapolationMode Leap.Unity.LeapServiceProvider._physicsExtrapolation = PhysicsExtrapolationMode.Auto
protected

Definition at line 86 of file LeapServiceProvider.cs.

◆ _physicsExtrapolationTime

float Leap.Unity.LeapServiceProvider._physicsExtrapolationTime = 1.0f / 90.0f
protected

Definition at line 90 of file LeapServiceProvider.cs.

◆ _serverNameSpace

string Leap.Unity.LeapServiceProvider._serverNameSpace = "Leap Service"
protected

Definition at line 117 of file LeapServiceProvider.cs.

◆ _smoothedTrackingLatency

SmoothedFloat Leap.Unity.LeapServiceProvider._smoothedTrackingLatency = new SmoothedFloat()
protected

Definition at line 138 of file LeapServiceProvider.cs.

◆ _trackingOptimization

TrackingOptimizationMode Leap.Unity.LeapServiceProvider._trackingOptimization = TrackingOptimizationMode.Desktop
protected

Definition at line 102 of file LeapServiceProvider.cs.

◆ _transformedFixedFrame

Frame Leap.Unity.LeapServiceProvider._transformedFixedFrame
protected

Definition at line 144 of file LeapServiceProvider.cs.

◆ _transformedUpdateFrame

Frame Leap.Unity.LeapServiceProvider._transformedUpdateFrame
protected

Definition at line 142 of file LeapServiceProvider.cs.

◆ _unityToLeapOffset

long Leap.Unity.LeapServiceProvider._unityToLeapOffset
protected

Definition at line 139 of file LeapServiceProvider.cs.

◆ _untransformedFixedFrame

Frame Leap.Unity.LeapServiceProvider._untransformedFixedFrame
protected

Definition at line 143 of file LeapServiceProvider.cs.

◆ _untransformedUpdateFrame

Frame Leap.Unity.LeapServiceProvider._untransformedUpdateFrame
protected

Definition at line 141 of file LeapServiceProvider.cs.

◆ _useInterpolation

bool Leap.Unity.LeapServiceProvider._useInterpolation = true
protected

Definition at line 122 of file LeapServiceProvider.cs.

◆ _workerThreadProfiling

bool Leap.Unity.LeapServiceProvider._workerThreadProfiling = false
protected

Definition at line 112 of file LeapServiceProvider.cs.

◆ BounceAmount

int Leap.Unity.LeapServiceProvider.BounceAmount = 0
protected

Definition at line 131 of file LeapServiceProvider.cs.

◆ ExtrapolationAmount

int Leap.Unity.LeapServiceProvider.ExtrapolationAmount = 0
protected

Definition at line 130 of file LeapServiceProvider.cs.

◆ HAND_ARRAY_GLOBAL_NAME

const string Leap.Unity.LeapServiceProvider.HAND_ARRAY_GLOBAL_NAME = "_LeapHandTransforms"
staticprotected

The transform array used for late-latching.

Definition at line 37 of file LeapServiceProvider.cs.

◆ MAX_RECONNECTION_ATTEMPTS

const int Leap.Unity.LeapServiceProvider.MAX_RECONNECTION_ATTEMPTS = 5
staticprotected

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

Definition at line 43 of file LeapServiceProvider.cs.

◆ NS_TO_S

const double Leap.Unity.LeapServiceProvider.NS_TO_S = 1e-6
staticprotected

Converts nanoseconds to seconds.

Definition at line 27 of file LeapServiceProvider.cs.

◆ RECONNECTION_INTERVAL

const int Leap.Unity.LeapServiceProvider.RECONNECTION_INTERVAL = 180
staticprotected

The number of frames to wait between each reconnection attempt.

Definition at line 49 of file LeapServiceProvider.cs.

◆ S_TO_NS

const double Leap.Unity.LeapServiceProvider.S_TO_NS = 1e6
staticprotected

Converts seconds to nanoseconds.

Definition at line 32 of file LeapServiceProvider.cs.

Property Documentation

◆ CurrentFixedFrame

override Frame Leap.Unity.LeapServiceProvider.CurrentFixedFrame
get

Definition at line 250 of file LeapServiceProvider.cs.

◆ CurrentFrame

override Frame Leap.Unity.LeapServiceProvider.CurrentFrame
get

Definition at line 230 of file LeapServiceProvider.cs.

◆ OnDeviceSafe

Action<Device> Leap.Unity.LeapServiceProvider.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.

Definition at line 158 of file LeapServiceProvider.cs.

◆ SelectedInteractionVolumeVisualization

InteractionVolumeVisualization Leap.Unity.LeapServiceProvider.SelectedInteractionVolumeVisualization
get

Definition at line 65 of file LeapServiceProvider.cs.


The documentation for this class was generated from the following file: