Class Leap::Encoding::VectorHand¶
- class Leap.Encoding.VectorHand : public Leap.Encoding.IInterpolable<VectorHand>¶
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.
Public Functions
- VectorHand ()¶
VectorHand constructor. If using this, call Encode(Hand hand) afterwards, or use the constructor VectorHand(Hand hand) instead.
- 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.
- VectorHand CopyFrom (VectorHand h)¶
Copies a VectorHand from another VectorHand
- void Decode (Hand intoHand)¶
Decodes a hand in VectorHand representation back into a Leap hand.
- Param intoHand
intoHand will contain the resulting Leap hand
- void ReadBytes (byte[] bytes, int offset = 0)¶
Fills this VectorHand with data read from the provided byte array, starting at the provided offset.
- void ReadBytes (byte[] bytes, ref int offset)
Fills this VectorHand with data read from the provided byte array, starting at the provided offset.
- 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.
Throws an IndexOutOfRangeException if the provided byte array doesn’t have enough space (starting from the offset) to write the number of bytes required.
- void 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).
- 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.
- 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.
- bool FillLerped (VectorHand a, VectorHand b, float t)¶
Fills the VectorHand with interpolated data between the two argument VectorHands, by t (unclamped), and return true. If either a or b is null, the resulting 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.
Public Members
- Quaternion palmRot¶
palm rotation
Properties
- Pose palmPose { get; set; }¶
The palmPose is a combination of palmPos and palmRot.
- int numBytesRequired { get; set; }¶
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.
Public Static 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.
- 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.
- 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.
- 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.
- 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.