mirror of
https://github.com/hanetzer/sdraw_mods_cvr.git
synced 2025-09-05 11:29:23 +00:00
Update to Ultraleap Gemini v5.12
Update to Ultraleap Unity Plugin v6.9.0 Unclamped spreads and curls
This commit is contained in:
parent
965c0bf93d
commit
5c33abc9d2
46 changed files with 1143 additions and 2564 deletions
|
@ -1,5 +1,5 @@
|
|||
/******************************************************************************
|
||||
* Copyright (C) Ultraleap, Inc. 2011-2021. *
|
||||
* Copyright (C) Ultraleap, Inc. 2011-2023. *
|
||||
* *
|
||||
* Use subject to the terms of the Apache License 2.0 available at *
|
||||
* http://www.apache.org/licenses/LICENSE-2.0, or another agreement *
|
||||
|
@ -9,9 +9,19 @@
|
|||
namespace LeapInternal
|
||||
{
|
||||
using Leap;
|
||||
#pragma warning disable 0618
|
||||
using UnityEngine;
|
||||
public static class CopyFromLeapCExtensions
|
||||
{
|
||||
public static readonly float MM_TO_M = 1e-3f;
|
||||
|
||||
public static void TransformToUnityUnits(this Hand hand)
|
||||
{
|
||||
LeapTransform leapTransform = new LeapTransform(Vector3.zero, Quaternion.identity, new Vector3(MM_TO_M, MM_TO_M, MM_TO_M));
|
||||
leapTransform.MirrorZ();
|
||||
|
||||
hand.Transform(leapTransform);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Copies the data from an internal tracking message into a frame.
|
||||
|
@ -42,7 +52,7 @@ namespace LeapInternal
|
|||
* @param leapHand The internal hand definition to be copied into this hand.
|
||||
* @param frameId The frame id of the frame this hand belongs to.
|
||||
*/
|
||||
public static Hand CopyFrom(this Hand hand, ref LEAP_HAND leapHand, long frameId)
|
||||
private static Hand CopyFrom(this Hand hand, ref LEAP_HAND leapHand, long frameId)
|
||||
{
|
||||
hand.FrameId = frameId;
|
||||
hand.Id = (int)leapHand.id;
|
||||
|
@ -51,18 +61,17 @@ namespace LeapInternal
|
|||
|
||||
hand.Confidence = leapHand.confidence;
|
||||
hand.GrabStrength = leapHand.grab_strength;
|
||||
hand.GrabAngle = leapHand.grab_angle;
|
||||
hand.PinchStrength = leapHand.pinch_strength;
|
||||
hand.PinchDistance = leapHand.pinch_distance;
|
||||
hand.PalmWidth = leapHand.palm.width;
|
||||
hand.IsLeft = leapHand.type == eLeapHandType.eLeapHandType_Left;
|
||||
hand.TimeVisible = (float)(leapHand.visible_time * 1e-6);
|
||||
hand.PalmPosition = leapHand.palm.position.ToLeapVector();
|
||||
hand.StabilizedPalmPosition = leapHand.palm.stabilized_position.ToLeapVector();
|
||||
hand.PalmVelocity = leapHand.palm.velocity.ToLeapVector();
|
||||
hand.PalmNormal = leapHand.palm.normal.ToLeapVector();
|
||||
hand.Rotation = leapHand.palm.orientation.ToLeapQuaternion();
|
||||
hand.Direction = leapHand.palm.direction.ToLeapVector();
|
||||
hand.PalmPosition = leapHand.palm.position.ToVector3();
|
||||
hand.StabilizedPalmPosition = leapHand.palm.stabilized_position.ToVector3();
|
||||
hand.PalmVelocity = leapHand.palm.velocity.ToVector3();
|
||||
hand.PalmNormal = leapHand.palm.normal.ToVector3();
|
||||
hand.Rotation = leapHand.palm.orientation.ToQuaternion();
|
||||
hand.Direction = leapHand.palm.direction.ToVector3();
|
||||
hand.WristPosition = hand.Arm.NextJoint;
|
||||
|
||||
hand.Fingers[0].CopyFrom(leapHand.thumb, Leap.Finger.FingerType.TYPE_THUMB, hand.Id, hand.TimeVisible);
|
||||
|
@ -71,6 +80,8 @@ namespace LeapInternal
|
|||
hand.Fingers[3].CopyFrom(leapHand.ring, Leap.Finger.FingerType.TYPE_RING, hand.Id, hand.TimeVisible);
|
||||
hand.Fingers[4].CopyFrom(leapHand.pinky, Leap.Finger.FingerType.TYPE_PINKY, hand.Id, hand.TimeVisible);
|
||||
|
||||
hand.TransformToUnityUnits();
|
||||
|
||||
return hand;
|
||||
}
|
||||
|
||||
|
@ -83,7 +94,7 @@ namespace LeapInternal
|
|||
* @param handId The hand id of the hand this finger belongs to.
|
||||
* @param timeVisible The time in seconds that this finger has been visible.
|
||||
*/
|
||||
public static Finger CopyFrom(this Finger finger, LEAP_DIGIT leapBone, Finger.FingerType type, int handId, float timeVisible)
|
||||
private static Finger CopyFrom(this Finger finger, LEAP_DIGIT leapBone, Finger.FingerType type, int handId, float timeVisible)
|
||||
{
|
||||
finger.Id = (handId * 10) + leapBone.finger_id;
|
||||
finger.HandId = handId;
|
||||
|
@ -115,17 +126,17 @@ namespace LeapInternal
|
|||
* @param leapBone The internal bone definition to be copied into this bone.
|
||||
* @param type The bone type of this bone.
|
||||
*/
|
||||
public static Bone CopyFrom(this Bone bone, LEAP_BONE leapBone, Bone.BoneType type)
|
||||
private static Bone CopyFrom(this Bone bone, LEAP_BONE leapBone, Bone.BoneType type)
|
||||
{
|
||||
bone.Type = type;
|
||||
bone.PrevJoint = leapBone.prev_joint.ToLeapVector();
|
||||
bone.NextJoint = leapBone.next_joint.ToLeapVector();
|
||||
bone.PrevJoint = leapBone.prev_joint.ToVector3();
|
||||
bone.NextJoint = leapBone.next_joint.ToVector3();
|
||||
bone.Direction = (bone.NextJoint - bone.PrevJoint);
|
||||
bone.Length = bone.Direction.Magnitude;
|
||||
bone.Length = bone.Direction.magnitude;
|
||||
|
||||
if (bone.Length < float.Epsilon)
|
||||
{
|
||||
bone.Direction = Vector.Zero;
|
||||
bone.Direction = Vector3.zero;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -133,11 +144,10 @@ namespace LeapInternal
|
|||
}
|
||||
|
||||
bone.Center = (bone.PrevJoint + bone.NextJoint) / 2.0f;
|
||||
bone.Rotation = leapBone.rotation.ToLeapQuaternion();
|
||||
bone.Rotation = leapBone.rotation.ToQuaternion();
|
||||
bone.Width = leapBone.width;
|
||||
|
||||
return bone;
|
||||
}
|
||||
}
|
||||
#pragma warning restore 0618
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue