Tanoda
Leap.Unity.Encoding.VectorHand Class Reference

A Vector-based encoding of a Leap Hand. More...

Inheritance diagram for Leap.Unity.Encoding.VectorHand:
Leap.Unity.Encoding.IInterpolable< VectorHand >

Public Member Functions

 VectorHand ()
 
 VectorHand (Hand hand)
 Constructs a VectorHand representation from a Leap hand. This allocates a vector array for the encoded hand data. More...
 
VectorHand CopyFrom (VectorHand h)
 Copies a VectorHand from another VectorHand More...
 
void Encode (Hand fromHand)
 
void Decode (Hand intoHand)
 
void ReadBytes (byte[] bytes, int offset=0)
 Fills this VectorHand with data read from the provided byte array, starting at the provided offset. More...
 
void ReadBytes (byte[] bytes, ref int offset)
 Fills this VectorHand with data read from the provided byte array, starting at the provided offset. More...
 
void FillBytes (byte[] bytesToFill, ref int offset)
 Fills the provided byte array with a compressed, 86-byte form of this VectorHand, starting at the provided offset. More...
 
void FillBytes (byte[] bytesToFill)
 Fills the provided byte array with a compressed, 86-byte form of this VectorHand. More...
 
void ReadBytes (byte[] bytes, ref int offset, Hand intoHand)
 Shortcut for reading a VectorHand-encoded byte representation of a Leap hand and decoding it immediately into a Hand object. More...
 
void FillBytes (byte[] bytes, ref int offset, Hand fromHand)
 Shortcut for encoding a Leap hand into a VectorHand representation and compressing it immediately into a byte representation. If the provided Hand is null, the 86 bytes are set to zero. More...
 
bool FillLerped (VectorHand a, VectorHand b, float t)
 Fills the ref-argument VectorHand with interpolated data between the two other VectorHands, by t (unclamped), and return true. If either a or b is null, the ref-argument VectorHand is also set to null, and the method returns false. An exception is thrown if the interpolation arguments a and b don't have the same chirality. More...
 
bool FillSplined (VectorHand a, VectorHand b, VectorHand c, VectorHand d, float t)
 Fills the ref-argument VectorHand with interpolated data between the 4 other VectorHands, by t (unclamped), and return true. If either a, b, c or d is null, the ref-argument VectorHand is also set to null, and the method returns false. An exception is thrown if the interpolation arguments a and b don't have the same chirality. More...
 
- Public Member Functions inherited from Leap.Unity.Encoding.IInterpolable< VectorHand >
CopyFrom (T toCopy)
 
bool FillLerped (T from, T to, float t)
 
bool FillSplined (T a, T b, T c, T d, float t)
 

Static Public Member Functions

static void StaticFillBytes (byte[] bytes, Hand fromHand)
 Fills bytes using a thread-safe (ThreadStatic) cached VectorHand to encode the provided Hand. If the provided Hand is null, the 86 bytes are set to zero. More...
 
static void StaticFillBytes (byte[] bytes, int offset, Hand fromHand)
 Fills bytes at the argument offset using a thread-safe (ThreadStatic) cached VectorHand to encode the provided Hand. If the provided Hand is null, the 86 bytes are set to zero. More...
 
static void StaticFillBytes (byte[] bytes, ref int offset, Hand fromHand)
 Fills bytes at the argument offset using a thread-safe (ThreadStatic) cached VectorHand to encode the provided Hand. If the provided Hand is null, the 86 bytes are set to zero. More...
 
static Vector3 ToWorld (Vector3 localPoint, Vector3 localOrigin, Quaternion localRot)
 Converts a local-space point to a world-space point given the local space's origin and rotation. More...
 
static Vector3 ToLocal (Vector3 worldPoint, Vector3 localOrigin, Quaternion localRot)
 Converts a world-space point to a local-space point given the local space's origin and rotation. More...
 

Public Attributes

bool isLeft
 
Vector3 palmPos
 
Quaternion palmRot
 

Static Public Attributes

const int NUM_JOINT_POSITIONS = 25
 
static Vector3 tweakWristPosition = new Vector3(0f, -0.015f, -0.065f)
 
const int NUM_BYTES = 86
 

Properties

Pose palmPose [get]
 
Vector3[] jointPositions [get]
 
int numBytesRequired [get]
 The number of bytes required to encode a VectorHand into its byte representation. The byte representation is compressed to 86 bytes. More...
 

Detailed Description

A Vector-based encoding of a Leap Hand.

You can Encode a VectorHand from a Leap hand, Decode a VectorHand into a Leap hand, convert the VectorHand to a compressed byte representation using FillBytes, and decompress back into a VectorHand using FromBytes.

Also see CurlHand for a more compressed but slightly less articulated encoding. TODO: CurlHand not yet brought in from Networking module!

Definition at line 36 of file VectorHand.cs.

Constructor & Destructor Documentation

◆ VectorHand() [1/2]

Leap.Unity.Encoding.VectorHand.VectorHand ( )

Definition at line 62 of file VectorHand.cs.

◆ VectorHand() [2/2]

Leap.Unity.Encoding.VectorHand.VectorHand ( Hand  hand)

Constructs a VectorHand representation from a Leap hand. This allocates a vector array for the encoded hand data.

Use a pooling strategy to avoid unnecessary allocation in runtime contexts.

Definition at line 70 of file VectorHand.cs.

Member Function Documentation

◆ CopyFrom()

VectorHand Leap.Unity.Encoding.VectorHand.CopyFrom ( VectorHand  h)

Copies a VectorHand from another VectorHand

Definition at line 77 of file VectorHand.cs.

◆ Decode()

void Leap.Unity.Encoding.VectorHand.Decode ( Hand  intoHand)

Definition at line 109 of file VectorHand.cs.

◆ Encode()

void Leap.Unity.Encoding.VectorHand.Encode ( Hand  fromHand)

Definition at line 88 of file VectorHand.cs.

◆ FillBytes() [1/3]

void Leap.Unity.Encoding.VectorHand.FillBytes ( byte[]  bytes,
ref int  offset,
Hand  fromHand 
)

Shortcut for encoding a Leap hand into a VectorHand representation and compressing it immediately into a byte representation. If the provided Hand is null, the 86 bytes are set to zero.

Definition at line 333 of file VectorHand.cs.

◆ FillBytes() [2/3]

void Leap.Unity.Encoding.VectorHand.FillBytes ( byte[]  bytesToFill)

Fills the provided byte array with a compressed, 86-byte form of this VectorHand.

Throws an IndexOutOfRangeException if the provided byte array doesn't have enough space to write the number of bytes required (see VectorHand.BYTE_ENCODING_SIZE).

Definition at line 313 of file VectorHand.cs.

◆ FillBytes() [3/3]

void Leap.Unity.Encoding.VectorHand.FillBytes ( byte[]  bytesToFill,
ref int  offset 
)

Fills the provided byte array with a compressed, 86-byte form of this VectorHand, starting at the provided offset.

Throws an IndexOutOfRangeException if the provided byte array doesn't have enough space (starting from the offset) to write the number of bytes required.

Definition at line 271 of file VectorHand.cs.

◆ FillLerped()

bool Leap.Unity.Encoding.VectorHand.FillLerped ( VectorHand  a,
VectorHand  b,
float  t 
)

Fills the ref-argument VectorHand with interpolated data between the two other VectorHands, by t (unclamped), and return true. If either a or b is null, the ref-argument VectorHand is also set to null, and the method returns false. An exception is thrown if the interpolation arguments a and b don't have the same chirality.

Definition at line 425 of file VectorHand.cs.

◆ FillSplined()

bool Leap.Unity.Encoding.VectorHand.FillSplined ( VectorHand  a,
VectorHand  b,
VectorHand  c,
VectorHand  d,
float  t 
)

Fills the ref-argument VectorHand with interpolated data between the 4 other VectorHands, by t (unclamped), and return true. If either a, b, c or d is null, the ref-argument VectorHand is also set to null, and the method returns false. An exception is thrown if the interpolation arguments a and b don't have the same chirality.

Definition at line 448 of file VectorHand.cs.

◆ ReadBytes() [1/3]

void Leap.Unity.Encoding.VectorHand.ReadBytes ( byte[]  bytes,
int  offset = 0 
)

Fills this VectorHand with data read from the provided byte array, starting at the provided offset.

Definition at line 229 of file VectorHand.cs.

◆ ReadBytes() [2/3]

void Leap.Unity.Encoding.VectorHand.ReadBytes ( byte[]  bytes,
ref int  offset 
)

Fills this VectorHand with data read from the provided byte array, starting at the provided offset.

Definition at line 237 of file VectorHand.cs.

◆ ReadBytes() [3/3]

void Leap.Unity.Encoding.VectorHand.ReadBytes ( byte[]  bytes,
ref int  offset,
Hand  intoHand 
)

Shortcut for reading a VectorHand-encoded byte representation of a Leap hand and decoding it immediately into a Hand object.

Definition at line 323 of file VectorHand.cs.

◆ StaticFillBytes() [1/3]

static void Leap.Unity.Encoding.VectorHand.StaticFillBytes ( byte[]  bytes,
Hand  fromHand 
)
static

Fills bytes using a thread-safe (ThreadStatic) cached VectorHand to encode the provided Hand. If the provided Hand is null, the 86 bytes are set to zero.

Definition at line 372 of file VectorHand.cs.

◆ StaticFillBytes() [2/3]

static void Leap.Unity.Encoding.VectorHand.StaticFillBytes ( byte[]  bytes,
int  offset,
Hand  fromHand 
)
static

Fills bytes at the argument offset using a thread-safe (ThreadStatic) cached VectorHand to encode the provided Hand. If the provided Hand is null, the 86 bytes are set to zero.

Definition at line 381 of file VectorHand.cs.

◆ StaticFillBytes() [3/3]

static void Leap.Unity.Encoding.VectorHand.StaticFillBytes ( byte[]  bytes,
ref int  offset,
Hand  fromHand 
)
static

Fills bytes at the argument offset using a thread-safe (ThreadStatic) cached VectorHand to encode the provided Hand. If the provided Hand is null, the 86 bytes are set to zero.

Definition at line 390 of file VectorHand.cs.

◆ ToLocal()

static Vector3 Leap.Unity.Encoding.VectorHand.ToLocal ( Vector3  worldPoint,
Vector3  localOrigin,
Quaternion  localRot 
)
static

Converts a world-space point to a local-space point given the local space's origin and rotation.

Definition at line 413 of file VectorHand.cs.

◆ ToWorld()

static Vector3 Leap.Unity.Encoding.VectorHand.ToWorld ( Vector3  localPoint,
Vector3  localOrigin,
Quaternion  localRot 
)
static

Converts a local-space point to a world-space point given the local space's origin and rotation.

Definition at line 404 of file VectorHand.cs.

Member Data Documentation

◆ isLeft

bool Leap.Unity.Encoding.VectorHand.isLeft

Definition at line 42 of file VectorHand.cs.

◆ NUM_BYTES

const int Leap.Unity.Encoding.VectorHand.NUM_BYTES = 86
static

Definition at line 223 of file VectorHand.cs.

◆ NUM_JOINT_POSITIONS

const int Leap.Unity.Encoding.VectorHand.NUM_JOINT_POSITIONS = 25
static

Definition at line 40 of file VectorHand.cs.

◆ palmPos

Vector3 Leap.Unity.Encoding.VectorHand.palmPos

Definition at line 43 of file VectorHand.cs.

◆ palmRot

Quaternion Leap.Unity.Encoding.VectorHand.palmRot

Definition at line 44 of file VectorHand.cs.

◆ tweakWristPosition

Vector3 Leap.Unity.Encoding.VectorHand.tweakWristPosition = new Vector3(0f, -0.015f, -0.065f)
static

Definition at line 107 of file VectorHand.cs.

Property Documentation

◆ jointPositions

Vector3 [] Leap.Unity.Encoding.VectorHand.jointPositions
get

Definition at line 49 of file VectorHand.cs.

◆ numBytesRequired

int Leap.Unity.Encoding.VectorHand.numBytesRequired
get

The number of bytes required to encode a VectorHand into its byte representation. The byte representation is compressed to 86 bytes.

The first byte determines chirality, the camera-local hand position uses 6 bytes, the camera-local hand rotation uses 4 bytes, and each joint position component is encoded in hand-local space using 3 bytes.

Definition at line 222 of file VectorHand.cs.

◆ palmPose

Pose Leap.Unity.Encoding.VectorHand.palmPose
get

Definition at line 45 of file VectorHand.cs.


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