From e577f317ae8bc2e07967a1249e85069340971743 Mon Sep 17 00:00:00 2001 From: Jean-Loup Macarit Date: Wed, 5 Jul 2023 15:31:53 +0200 Subject: [PATCH 1/4] remove body70 --- .../Scenes/Body Tracking Fusion.unity | 4 + .../ZEDFusion/Scripts/SkeletonHandler.cs | 372 +----------------- .../Assets/ZEDFusion/Scripts/ZEDCommon.cs | 84 +--- 3 files changed, 7 insertions(+), 453 deletions(-) diff --git a/ZEDUnityLivelink/Assets/ZEDFusion/Scenes/Body Tracking Fusion.unity b/ZEDUnityLivelink/Assets/ZEDFusion/Scenes/Body Tracking Fusion.unity index 764e00b..86d82c4 100644 --- a/ZEDUnityLivelink/Assets/ZEDFusion/Scenes/Body Tracking Fusion.unity +++ b/ZEDUnityLivelink/Assets/ZEDFusion/Scenes/Body Tracking Fusion.unity @@ -344,6 +344,10 @@ PrefabInstance: m_Modification: m_TransformParent: {fileID: 0} m_Modifications: + - target: {fileID: 688287088, guid: 6bd423642e236464196866e274c23689, type: 3} + propertyPath: useMulticast + value: 1 + objectReference: {fileID: 0} - target: {fileID: 688287089, guid: 6bd423642e236464196866e274c23689, type: 3} propertyPath: enableFootIK value: 0 diff --git a/ZEDUnityLivelink/Assets/ZEDFusion/Scripts/SkeletonHandler.cs b/ZEDUnityLivelink/Assets/ZEDFusion/Scripts/SkeletonHandler.cs index 5b92304..3897526 100644 --- a/ZEDUnityLivelink/Assets/ZEDFusion/Scripts/SkeletonHandler.cs +++ b/ZEDUnityLivelink/Assets/ZEDFusion/Scripts/SkeletonHandler.cs @@ -52,50 +52,6 @@ public const int JointType_38_LEFT_HAND_PINKY_1 = 36, // knuckle JointType_38_RIGHT_HAND_PINKY_1 = 37, JointType_38_COUNT = 38, - // --------- Body 70 specific - // Left hand - JointType_70_LEFT_HAND_THUMB_1 = 30, - JointType_70_LEFT_HAND_THUMB_2 = 31, - JointType_70_LEFT_HAND_THUMB_3 = 32, - JointType_70_LEFT_HAND_THUMB_4 = 33, // tip - JointType_70_LEFT_HAND_INDEX_1 = 34, // knuckle - JointType_70_LEFT_HAND_INDEX_2 = 35, - JointType_70_LEFT_HAND_INDEX_3 = 36, - JointType_70_LEFT_HAND_INDEX_4 = 37, // tip - JointType_70_LEFT_HAND_MIDDLE_1 = 38, - JointType_70_LEFT_HAND_MIDDLE_2 = 39, - JointType_70_LEFT_HAND_MIDDLE_3 = 40, - JointType_70_LEFT_HAND_MIDDLE_4 = 41, - JointType_70_LEFT_HAND_RING_1 = 42, - JointType_70_LEFT_HAND_RING_2 = 43, - JointType_70_LEFT_HAND_RING_3 = 44, - JointType_70_LEFT_HAND_RING_4 = 45, - JointType_70_LEFT_HAND_PINKY_1 = 46, - JointType_70_LEFT_HAND_PINKY_2 = 47, - JointType_70_LEFT_HAND_PINKY_3 = 48, - JointType_70_LEFT_HAND_PINKY_4 = 49, - // Right hand - JointType_70_RIGHT_HAND_THUMB_1 = 50, - JointType_70_RIGHT_HAND_THUMB_2 = 51, - JointType_70_RIGHT_HAND_THUMB_3 = 52, - JointType_70_RIGHT_HAND_THUMB_4 = 53, - JointType_70_RIGHT_HAND_INDEX_1 = 54, - JointType_70_RIGHT_HAND_INDEX_2 = 55, - JointType_70_RIGHT_HAND_INDEX_3 = 56, - JointType_70_RIGHT_HAND_INDEX_4 = 57, - JointType_70_RIGHT_HAND_MIDDLE_1 = 58, - JointType_70_RIGHT_HAND_MIDDLE_2 = 59, - JointType_70_RIGHT_HAND_MIDDLE_3 = 60, - JointType_70_RIGHT_HAND_MIDDLE_4 = 61, - JointType_70_RIGHT_HAND_RING_1 = 62, - JointType_70_RIGHT_HAND_RING_2 = 63, - JointType_70_RIGHT_HAND_RING_3 = 64, - JointType_70_RIGHT_HAND_RING_4 = 65, - JointType_70_RIGHT_HAND_PINKY_1 = 66, - JointType_70_RIGHT_HAND_PINKY_2 = 67, - JointType_70_RIGHT_HAND_PINKY_3 = 68, - JointType_70_RIGHT_HAND_PINKY_4 = 69, - JointType_70_COUNT = 70, // --------- Body34 JointType_34_Head = 26, JointType_34_Neck = 3, @@ -173,83 +129,6 @@ public const int JointType_RIGHT_ANKLE, JointType_RIGHT_SMALL_TOE }; - // List of bones (pair of joints) for BODY_70. Used for Skeleton mode. - private static readonly int[] bonesList70 = new int[] { - // Torso - JointType_PELVIS, JointType_SPINE_1, - JointType_SPINE_1, JointType_SPINE_2, - JointType_SPINE_2, JointType_SPINE_3, - JointType_SPINE_3, JointType_NECK, - JointType_PELVIS, JointType_LEFT_HIP, - JointType_PELVIS, JointType_RIGHT_HIP, - JointType_NECK, JointType_NOSE, - JointType_NECK, JointType_LEFT_CLAVICLE, - JointType_LEFT_CLAVICLE, JointType_LEFT_SHOULDER, - JointType_NECK, JointType_RIGHT_CLAVICLE, - JointType_RIGHT_CLAVICLE, JointType_RIGHT_SHOULDER, - JointType_NOSE, JointType_LEFT_EYE, - JointType_LEFT_EYE, JointType_LEFT_EAR, - JointType_NOSE, JointType_RIGHT_EYE, - JointType_RIGHT_EYE, JointType_RIGHT_EAR, - // Left arm - JointType_LEFT_SHOULDER, JointType_LEFT_ELBOW, - JointType_LEFT_ELBOW, JointType_LEFT_WRIST, - JointType_LEFT_WRIST, JointType_70_LEFT_HAND_THUMB_1, - JointType_70_LEFT_HAND_THUMB_1, JointType_70_LEFT_HAND_THUMB_2, - JointType_70_LEFT_HAND_THUMB_2, JointType_70_LEFT_HAND_THUMB_3, - JointType_70_LEFT_HAND_THUMB_3, JointType_70_LEFT_HAND_THUMB_4, - JointType_LEFT_WRIST, JointType_70_LEFT_HAND_INDEX_1, - JointType_70_LEFT_HAND_INDEX_1, JointType_70_LEFT_HAND_INDEX_2, - JointType_70_LEFT_HAND_INDEX_2, JointType_70_LEFT_HAND_INDEX_3, - JointType_70_LEFT_HAND_INDEX_3, JointType_70_LEFT_HAND_INDEX_4, - JointType_LEFT_WRIST, JointType_70_LEFT_HAND_MIDDLE_1, - JointType_70_LEFT_HAND_MIDDLE_1, JointType_70_LEFT_HAND_MIDDLE_2, - JointType_70_LEFT_HAND_MIDDLE_2, JointType_70_LEFT_HAND_MIDDLE_3, - JointType_70_LEFT_HAND_MIDDLE_3, JointType_70_LEFT_HAND_MIDDLE_4, - JointType_LEFT_WRIST, JointType_70_LEFT_HAND_RING_1, - JointType_70_LEFT_HAND_RING_1, JointType_70_LEFT_HAND_RING_2, - JointType_70_LEFT_HAND_RING_2, JointType_70_LEFT_HAND_RING_3, - JointType_70_LEFT_HAND_RING_3, JointType_70_LEFT_HAND_RING_4, - JointType_LEFT_WRIST, JointType_70_LEFT_HAND_PINKY_1, - JointType_70_LEFT_HAND_PINKY_1, JointType_70_LEFT_HAND_PINKY_2, - JointType_70_LEFT_HAND_PINKY_2, JointType_70_LEFT_HAND_PINKY_3, - JointType_70_LEFT_HAND_PINKY_3, JointType_70_LEFT_HAND_PINKY_4, - // right arm - JointType_RIGHT_SHOULDER, JointType_RIGHT_ELBOW, - JointType_RIGHT_ELBOW, JointType_RIGHT_WRIST, - JointType_RIGHT_WRIST, JointType_70_RIGHT_HAND_THUMB_1, - JointType_70_RIGHT_HAND_THUMB_1, JointType_70_RIGHT_HAND_THUMB_2, - JointType_70_RIGHT_HAND_THUMB_2, JointType_70_RIGHT_HAND_THUMB_3, - JointType_70_RIGHT_HAND_THUMB_3, JointType_70_RIGHT_HAND_THUMB_4, - JointType_RIGHT_WRIST, JointType_70_RIGHT_HAND_INDEX_1, - JointType_70_RIGHT_HAND_INDEX_1, JointType_70_RIGHT_HAND_INDEX_2, - JointType_70_RIGHT_HAND_INDEX_2, JointType_70_RIGHT_HAND_INDEX_3, - JointType_70_RIGHT_HAND_INDEX_3, JointType_70_RIGHT_HAND_INDEX_4, - JointType_RIGHT_WRIST, JointType_70_RIGHT_HAND_MIDDLE_1, - JointType_70_RIGHT_HAND_MIDDLE_1, JointType_70_RIGHT_HAND_MIDDLE_2, - JointType_70_RIGHT_HAND_MIDDLE_2, JointType_70_RIGHT_HAND_MIDDLE_3, - JointType_70_RIGHT_HAND_MIDDLE_3, JointType_70_RIGHT_HAND_MIDDLE_4, - JointType_RIGHT_WRIST, JointType_70_RIGHT_HAND_RING_1, - JointType_70_RIGHT_HAND_RING_1, JointType_70_RIGHT_HAND_RING_2, - JointType_70_RIGHT_HAND_RING_2, JointType_70_RIGHT_HAND_RING_3, - JointType_70_RIGHT_HAND_RING_3, JointType_70_RIGHT_HAND_RING_4, - JointType_RIGHT_WRIST, JointType_70_RIGHT_HAND_PINKY_1, - JointType_70_RIGHT_HAND_PINKY_1, JointType_70_RIGHT_HAND_PINKY_2, - JointType_70_RIGHT_HAND_PINKY_2, JointType_70_RIGHT_HAND_PINKY_3, - JointType_70_RIGHT_HAND_PINKY_3, JointType_70_RIGHT_HAND_PINKY_4, - // legs - JointType_LEFT_HIP, JointType_LEFT_KNEE, - JointType_LEFT_KNEE, JointType_LEFT_ANKLE, - JointType_LEFT_ANKLE, JointType_LEFT_HEEL, - JointType_LEFT_ANKLE, JointType_LEFT_BIG_TOE, - JointType_LEFT_ANKLE, JointType_LEFT_SMALL_TOE, - JointType_RIGHT_HIP, JointType_RIGHT_KNEE, - JointType_RIGHT_KNEE, JointType_RIGHT_ANKLE, - JointType_RIGHT_ANKLE, JointType_RIGHT_HEEL, - JointType_RIGHT_ANKLE, JointType_RIGHT_BIG_TOE, - JointType_RIGHT_ANKLE, JointType_RIGHT_SMALL_TOE - }; - // List of bones (pair of joints) for BODY_34. Used for Skeleton mode. private static readonly int[] bonesList34 = new int[] { // Torso @@ -329,84 +208,6 @@ public const int JointType_38_RIGHT_HAND_PINKY_1 }; - // List of joint that will be rendered as a sphere in the Skeleton mode. - // These are the joints with a rotation information (not the hands in order to not clutter the display) - private static readonly int[] sphereList70 = new int[] { - JointType_PELVIS, - JointType_SPINE_1, - JointType_SPINE_2, - JointType_SPINE_3, - JointType_NECK, - JointType_NOSE, - JointType_LEFT_EYE, - JointType_RIGHT_EYE, - JointType_LEFT_EAR, - JointType_RIGHT_EAR, - JointType_LEFT_CLAVICLE, - JointType_RIGHT_CLAVICLE, - JointType_LEFT_SHOULDER, - JointType_RIGHT_SHOULDER, - JointType_LEFT_ELBOW, - JointType_RIGHT_ELBOW, - JointType_LEFT_WRIST, - JointType_RIGHT_WRIST, - JointType_LEFT_HIP, - JointType_RIGHT_HIP, - JointType_LEFT_KNEE, - JointType_RIGHT_KNEE, - JointType_LEFT_ANKLE, - JointType_RIGHT_ANKLE, - JointType_LEFT_BIG_TOE, - JointType_RIGHT_BIG_TOE, - JointType_LEFT_SMALL_TOE, - JointType_RIGHT_SMALL_TOE, - JointType_LEFT_HEEL, - JointType_RIGHT_HEEL, - // --------- Body 70 specific - // Left hand - JointType_70_LEFT_HAND_THUMB_1, - JointType_70_LEFT_HAND_THUMB_2, - JointType_70_LEFT_HAND_THUMB_3, - JointType_70_LEFT_HAND_THUMB_4, // tip - JointType_70_LEFT_HAND_INDEX_1, // knuckle - JointType_70_LEFT_HAND_INDEX_2, - JointType_70_LEFT_HAND_INDEX_3, - JointType_70_LEFT_HAND_INDEX_4, // tip - JointType_70_LEFT_HAND_MIDDLE_1, - JointType_70_LEFT_HAND_MIDDLE_2, - JointType_70_LEFT_HAND_MIDDLE_3, - JointType_70_LEFT_HAND_MIDDLE_4, - JointType_70_LEFT_HAND_RING_1, - JointType_70_LEFT_HAND_RING_2, - JointType_70_LEFT_HAND_RING_3, - JointType_70_LEFT_HAND_RING_4, - JointType_70_LEFT_HAND_PINKY_1, - JointType_70_LEFT_HAND_PINKY_2, - JointType_70_LEFT_HAND_PINKY_3, - JointType_70_LEFT_HAND_PINKY_4, - // Right hand - JointType_70_RIGHT_HAND_THUMB_1, - JointType_70_RIGHT_HAND_THUMB_2, - JointType_70_RIGHT_HAND_THUMB_3, - JointType_70_RIGHT_HAND_THUMB_4, - JointType_70_RIGHT_HAND_INDEX_1, - JointType_70_RIGHT_HAND_INDEX_2, - JointType_70_RIGHT_HAND_INDEX_3, - JointType_70_RIGHT_HAND_INDEX_4, - JointType_70_RIGHT_HAND_MIDDLE_1, - JointType_70_RIGHT_HAND_MIDDLE_2, - JointType_70_RIGHT_HAND_MIDDLE_3, - JointType_70_RIGHT_HAND_MIDDLE_4, - JointType_70_RIGHT_HAND_RING_1, - JointType_70_RIGHT_HAND_RING_2, - JointType_70_RIGHT_HAND_RING_3, - JointType_70_RIGHT_HAND_RING_4, - JointType_70_RIGHT_HAND_PINKY_1, - JointType_70_RIGHT_HAND_PINKY_2, - JointType_70_RIGHT_HAND_PINKY_3, - JointType_70_RIGHT_HAND_PINKY_4 - }; - // List of joint that will be rendered as a sphere in the Skeleton mode. // These are the joints with a rotation information (not the hands in order to not clutter the display) private static readonly int[] sphereList34 = new int[] { @@ -494,81 +295,6 @@ public const int 17 }; - // Indexes of bones' parents for BODY_70 - private static readonly int[] parentsIdx_70 = new int[] - { - -1, - 0, - 1, - 2, - 3, - 4, - 4, - 4, - 4, - 4, - 3, - 3, - 10, - 11, - 12, - 13, - 14, - 15, - 0, - 0, - 18, - 19, - 20, - 21, - 22, - 23, - 22, - 23, - 22, - 23, - 16, - 30, - 31, - 32, - 16, - 30, - 31, - 32, - 16, - 30, - 31, - 32, - 16, - 30, - 31, - 32, - 16, - 30, - 31, - 32, - 17, - 50, - 51, - 52, - 17, - 50, - 51, - 52, - 17, - 50, - 51, - 52, - 17, - 50, - 51, - 52, - 17, - 50, - 51, - 52 - }; - // Indexes of bones' parents for BODY_34 private static readonly int[] parentsIdx_34 = new int[] { @@ -650,83 +376,6 @@ public const int HumanBodyBones.LastBone // Last }; - // Bones output by the ZED SDK (in this order) - private static HumanBodyBones[] humanBones70 = new HumanBodyBones[] { - HumanBodyBones.Hips, - HumanBodyBones.Spine, - HumanBodyBones.Chest, - HumanBodyBones.UpperChest, - HumanBodyBones.Neck, - HumanBodyBones.LastBone, // Nose - HumanBodyBones.LastBone, // Left Eye - HumanBodyBones.LastBone, // Right Eye - HumanBodyBones.LastBone, // Left Ear - HumanBodyBones.LastBone, // Right Ear - HumanBodyBones.LeftShoulder, - HumanBodyBones.RightShoulder, - HumanBodyBones.LeftUpperArm, - HumanBodyBones.RightUpperArm, - HumanBodyBones.LeftLowerArm, - HumanBodyBones.RightLowerArm, - HumanBodyBones.LeftHand, // Left Wrist - HumanBodyBones.RightHand, // Left Wrist - HumanBodyBones.LeftUpperLeg, // Left Hip - HumanBodyBones.RightUpperLeg, // Right Hip - HumanBodyBones.LeftLowerLeg, - HumanBodyBones.RightLowerLeg, - HumanBodyBones.LeftFoot, - HumanBodyBones.RightFoot, - HumanBodyBones.LastBone, // Left Big Toe - HumanBodyBones.LastBone, // Right Big Toe - HumanBodyBones.LastBone, // Left Small Toe - HumanBodyBones.LastBone, // Right Small Toe - HumanBodyBones.LastBone, // Left Heel - HumanBodyBones.LastBone, // Right Heel - // Left Hand - HumanBodyBones.LeftThumbProximal, - HumanBodyBones.LeftThumbIntermediate, - HumanBodyBones.LeftThumbDistal, - HumanBodyBones.LastBone, // Left Hand Thumb Tip - HumanBodyBones.LeftIndexProximal, - HumanBodyBones.LeftIndexIntermediate, - HumanBodyBones.LeftIndexDistal, - HumanBodyBones.LastBone, // Left Hand Index Tip - HumanBodyBones.LeftMiddleProximal, - HumanBodyBones.LeftMiddleIntermediate, - HumanBodyBones.LeftMiddleDistal, - HumanBodyBones.LastBone, // Left Hand Middle Tip - HumanBodyBones.LeftRingProximal, - HumanBodyBones.LeftRingIntermediate, - HumanBodyBones.LeftRingDistal, - HumanBodyBones.LastBone, // Left Hand Ring Tip - HumanBodyBones.LeftLittleProximal, - HumanBodyBones.LeftLittleIntermediate, - HumanBodyBones.LeftLittleDistal, - HumanBodyBones.LastBone, // Left Hand Pinky Tip - // Right Hand - HumanBodyBones.RightThumbProximal, - HumanBodyBones.RightThumbIntermediate, - HumanBodyBones.RightThumbDistal, - HumanBodyBones.LastBone, // Right Hand Thumb Tip - HumanBodyBones.RightIndexProximal, - HumanBodyBones.RightIndexIntermediate, - HumanBodyBones.RightIndexDistal, - HumanBodyBones.LastBone, // Right Hand Index Tip - HumanBodyBones.RightMiddleProximal, - HumanBodyBones.RightMiddleIntermediate, - HumanBodyBones.RightMiddleDistal, - HumanBodyBones.LastBone, // Right Hand Middle Tip - HumanBodyBones.RightRingProximal, - HumanBodyBones.RightRingIntermediate, - HumanBodyBones.RightRingDistal, - HumanBodyBones.LastBone, // Right Hand Ring Tip - HumanBodyBones.RightLittleProximal, - HumanBodyBones.RightLittleIntermediate, - HumanBodyBones.RightLittleDistal, - HumanBodyBones.LastBone, // Right Hand Pinky Tip - HumanBodyBones.LastBone // Last - }; - // Bones output by the ZED SDK (in this order) private static HumanBodyBones[] humanBones34 = new HumanBodyBones[] { HumanBodyBones.Hips, @@ -832,12 +481,10 @@ public const int public Vector3[] joints34 = new Vector3[jointType_34_COUNT]; public Vector3[] joints38 = new Vector3[JointType_38_COUNT]; - public Vector3[] joints70 = new Vector3[JointType_70_COUNT]; public Vector3[] currentJoints; public float[] confidences34 = new float[jointType_34_COUNT]; public float[] confidences38 = new float[JointType_38_COUNT]; - public float[] confidences70 = new float[JointType_70_COUNT]; public float[] currentConfidences; public int[] currentSpheresList; @@ -924,19 +571,8 @@ private void UpdateCurrentValues(sl.BODY_FORMAT pBodyFormat) currentRightAnkleIndex = JointType_RIGHT_ANKLE; currentKeypointsCount = JointType_38_COUNT; break; - case sl.BODY_FORMAT.BODY_70: - currentConfidences = confidences70; - currentJoints = joints70; - currentHumanBodyBones = humanBones70; - currentSpheresList = sphereList70; - currentBonesList = bonesList70; - currentParentIds = parentsIdx_70; - currentLeftAnkleIndex = JointType_LEFT_ANKLE; - currentRightAnkleIndex = JointType_RIGHT_ANKLE; - currentKeypointsCount = JointType_70_COUNT; - break; default: - Debug.LogError("Error: Invalid BODY_MODEL! Please use either BODY_34, BODY_38 or BODY_70."); + Debug.LogError("Error: Invalid BODY_MODEL! Please use either BODY_34 or BODY_38."); #if UNITY_EDITOR EditorApplication.ExitPlaymode(); #else @@ -959,7 +595,7 @@ public Animator GetAnimator() /// Create the avatar control /// /// The humanoid GameObject prefab. - /// The Body model to apply (38 or 70 bones). + /// The Body model to apply (34 or 38). public void Create(GameObject h, sl.BODY_FORMAT body_format) { humanoid = (GameObject)Instantiate(h, Vector3.zero, Quaternion.identity); @@ -1178,10 +814,6 @@ void UpdateSkeleton(Vector3 offsetSDK, bool mirrorMode = false) bones[i].SetActive(true); Vector3 offset = end - start; - // if hands Body70, thinner cylinders - //Vector3 scale = (BodyFormat == sl.BODY_FORMAT.BODY_70 && i >= 29) - // ? new Vector3(width / 2f, offset.magnitude / 2.0f, width / 2f) - // : new Vector3(width, offset.magnitude / 2.0f, width); Vector3 scale = new Vector3(width, offset.magnitude / 2.0f, width); Vector3 position = start + (offset / 2.0f); diff --git a/ZEDUnityLivelink/Assets/ZEDFusion/Scripts/ZEDCommon.cs b/ZEDUnityLivelink/Assets/ZEDFusion/Scripts/ZEDCommon.cs index feebceb..38fb60a 100644 --- a/ZEDUnityLivelink/Assets/ZEDFusion/Scripts/ZEDCommon.cs +++ b/ZEDUnityLivelink/Assets/ZEDFusion/Scripts/ZEDCommon.cs @@ -106,87 +106,6 @@ public enum BODY_PARTS_POSE_38 LAST = 38 }; - /// - /// ssemantic of human body parts and order keypoints for BODY_FORMAT.POSE_34. - /// - public enum BODY_PARTS_POSE_70 - { - PELVIS = 0, - SPINE_1 = 1, - SPINE_2 = 2, - SPINE_3 = 3, - NECK = 4, - NOSE = 5, - LEFT_EYE = 6, - RIGHT_EYE = 7, - LEFT_EAR = 8, - RIGHT_EAR = 9, - LEFT_CLAVICLE = 10, - RIGHT_CLAVICLE = 11, - LEFT_SHOULDER = 12, - RIGHT_SHOULDER = 13, - LEFT_ELBOW = 14, - RIGHT_ELBOW = 15, - LEFT_WRIST = 16, - RIGHT_WRIST = 17, - LEFT_HIP = 18, - RIGHT_HIP = 19, - LEFT_KNEE = 20, - RIGHT_KNEE = 21, - LEFT_ANKLE = 22, - RIGHT_ANKLE = 23, - LEFT_BIG_TOE = 24, - RIGHT_BIG_TOE = 25, - LEFT_SMALL_TOE = 26, - RIGHT_SMALL_TOE = 27, - LEFT_HEEL = 28, - RIGHT_HEEL = 29, - // Hands - // Left - LEFT_HAND_THUMB_1 = 30, - LEFT_HAND_THUMB_2 = 31, - LEFT_HAND_THUMB_3 = 32, - LEFT_HAND_THUMB_4 = 33, // tip - LEFT_HAND_INDEX_1 = 34, // knuckle - LEFT_HAND_INDEX_2 = 35, - LEFT_HAND_INDEX_3 = 36, - LEFT_HAND_INDEX_4 = 37, // tip - LEFT_HAND_MIDDLE_1 = 38, - LEFT_HAND_MIDDLE_2 = 39, - LEFT_HAND_MIDDLE_3 = 40, - LEFT_HAND_MIDDLE_4 = 41, - LEFT_HAND_RING_1 = 42, - LEFT_HAND_RING_2 = 43, - LEFT_HAND_RING_3 = 44, - LEFT_HAND_RING_4 = 45, - LEFT_HAND_PINKY_1 = 46, - LEFT_HAND_PINKY_2 = 47, - LEFT_HAND_PINKY_3 = 48, - LEFT_HAND_PINKY_4 = 49, - // Right - RIGHT_HAND_THUMB_1 = 50, - RIGHT_HAND_THUMB_2 = 51, - RIGHT_HAND_THUMB_3 = 52, - RIGHT_HAND_THUMB_4 = 53, - RIGHT_HAND_INDEX_1 = 54, - RIGHT_HAND_INDEX_2 = 55, - RIGHT_HAND_INDEX_3 = 56, - RIGHT_HAND_INDEX_4 = 57, - RIGHT_HAND_MIDDLE_1 = 58, - RIGHT_HAND_MIDDLE_2 = 59, - RIGHT_HAND_MIDDLE_3 = 60, - RIGHT_HAND_MIDDLE_4 = 61, - RIGHT_HAND_RING_1 = 62, - RIGHT_HAND_RING_2 = 63, - RIGHT_HAND_RING_3 = 64, - RIGHT_HAND_RING_4 = 65, - RIGHT_HAND_PINKY_1 = 66, - RIGHT_HAND_PINKY_2 = 67, - RIGHT_HAND_PINKY_3 = 68, - RIGHT_HAND_PINKY_4 = 69, - LAST = 70 - }; - public enum OBJECT_TRACK_STATE { OFF, /**< The tracking is not yet initialized, the object ID is not usable */ @@ -252,8 +171,7 @@ public enum BODY_FORMAT { BODY_18, BODY_34, - BODY_38, - BODY_70, + BODY_38 }; public class BodyData From 6572e622ba904b86882ab64c6d982b42ad35ecc2 Mon Sep 17 00:00:00 2001 From: Jean-Loup Macarit Date: Wed, 5 Jul 2023 15:35:43 +0200 Subject: [PATCH 2/4] Clamp animation smoothing & change default --- .../Assets/ZEDFusion/Scripts/ZEDBodyTrackingManager.cs | 4 ++-- .../Assets/ZEDFusion/Scripts/ZEDSkeletonAnimator.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ZEDUnityLivelink/Assets/ZEDFusion/Scripts/ZEDBodyTrackingManager.cs b/ZEDUnityLivelink/Assets/ZEDFusion/Scripts/ZEDBodyTrackingManager.cs index 8fa7f88..65cafaf 100644 --- a/ZEDUnityLivelink/Assets/ZEDFusion/Scripts/ZEDBodyTrackingManager.cs +++ b/ZEDUnityLivelink/Assets/ZEDFusion/Scripts/ZEDBodyTrackingManager.cs @@ -64,8 +64,8 @@ public enum BODY_MODE [Space(5)] [Header("------ Animation Smoothing ------")] - [Tooltip("Animation smoothing setting. 0 = No latency, no smoothing. 1 = \"Full latency\" so no movement.\n Tweak this value depending on your framerate, and the fps of the camera."), Range(0f, 1f)] - public float smoothingValue = 0f; + [Tooltip("Animation smoothing setting. 0 = No latency, no smoothing. 1 = Maximum latency.\n Tweak this value depending on your framerate, and the fps of the camera."), Range(0f, 1f)] + public float smoothingValue = .2f; [SerializeField] [Tooltip("Enable animation smoothing or not (induces latency).")] private bool enableSmoothing = true; diff --git a/ZEDUnityLivelink/Assets/ZEDFusion/Scripts/ZEDSkeletonAnimator.cs b/ZEDUnityLivelink/Assets/ZEDFusion/Scripts/ZEDSkeletonAnimator.cs index 311a4ad..c3cec4f 100644 --- a/ZEDUnityLivelink/Assets/ZEDFusion/Scripts/ZEDSkeletonAnimator.cs +++ b/ZEDUnityLivelink/Assets/ZEDFusion/Scripts/ZEDSkeletonAnimator.cs @@ -258,7 +258,7 @@ void ApplyAllRigRotationsOnAnimator() { if(bodyTrackingManager.bodyMode == ZEDBodyTrackingManager.BODY_MODE.FULL_BODY) { - skhandler.MoveAnimator(bodyTrackingManager.EnableSmoothing, Mathf.Clamp(1 - bodyTrackingManager.smoothingValue, 0, 1)); + skhandler.MoveAnimator(bodyTrackingManager.EnableSmoothing, 1 - Mathf.Clamp(bodyTrackingManager.smoothingValue, 0, 0.99f)); } else if(bodyTrackingManager.bodyMode == ZEDBodyTrackingManager.BODY_MODE.UPPER_BODY) { From fd4bc594ee0f438d3d0d87748fcd252d89ea7b19 Mon Sep 17 00:00:00 2001 From: Jean-Loup Macarit Date: Wed, 5 Jul 2023 15:42:23 +0200 Subject: [PATCH 3/4] fix first frame pose --- .../ZEDFusion/Scripts/SkeletonHandler.cs | 39 ++++++++++++------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/ZEDUnityLivelink/Assets/ZEDFusion/Scripts/SkeletonHandler.cs b/ZEDUnityLivelink/Assets/ZEDFusion/Scripts/SkeletonHandler.cs index 3897526..6039e76 100644 --- a/ZEDUnityLivelink/Assets/ZEDFusion/Scripts/SkeletonHandler.cs +++ b/ZEDUnityLivelink/Assets/ZEDFusion/Scripts/SkeletonHandler.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System; using UnityEditor; +using Unity.VisualScripting; public class SkeletonHandler : ScriptableObject { @@ -961,6 +962,11 @@ public void Move() } } + /// + /// Ignore the smoothing on the first frame to not have the lerp from 0-pose as first animation. + /// + private bool firstFrame = true; + /// /// Propagate rotations and set them to the animator. /// @@ -1005,20 +1011,7 @@ public void MoveAnimator(bool smoothingEnabled, float smoothValue) targetBodyOrientationSmoothed = targetBodyOrientation; // animatorization - if (!smoothingEnabled) - { - foreach (HumanBodyBones bone in currentHumanBodyBones) - { - if (bone != HumanBodyBones.LastBone && bone != HumanBodyBones.Hips) - { - if (rigBone[bone].transform) - { - animator.SetBoneLocalRotation(bone, rigBone[bone].transform.localRotation); - } - } - } - } - else // smoothing enabled + if (smoothingEnabled && ! firstFrame) { targetBodyPositionWithHipOffset = Vector3.Lerp(targetBodyPositionLastFrame, targetBodyPositionWithHipOffset, smoothValue); targetBodyPositionLastFrame = targetBodyPositionWithHipOffset; @@ -1045,6 +1038,24 @@ public void MoveAnimator(bool smoothingEnabled, float smoothValue) } } } + else // smoothing disabled + { + targetBodyPositionLastFrame = targetBodyPositionWithHipOffset; + targetBodyOrientationLastFrame = targetBodyOrientationSmoothed; + + foreach (HumanBodyBones bone in currentHumanBodyBones) + { + if (bone != HumanBodyBones.LastBone && bone != HumanBodyBones.Hips) + { + if (rigBone[bone].transform) + { + animator.SetBoneLocalRotation(bone, rigBone[bone].transform.localRotation); + RigBoneRotationLastFrame[bone] = rigBone[bone].transform.localRotation; + } + } + } + firstFrame = false; + } } From 402afedd78317af2e3c412e7782e074e4e8d197c Mon Sep 17 00:00:00 2001 From: Jean-Loup Macarit Date: Wed, 5 Jul 2023 15:44:30 +0200 Subject: [PATCH 4/4] remove body70 from fusion viewer --- zed-unity-livelink-fusion/src/GLViewer.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/zed-unity-livelink-fusion/src/GLViewer.cpp b/zed-unity-livelink-fusion/src/GLViewer.cpp index e9f7de9..e5ed417 100644 --- a/zed-unity-livelink-fusion/src/GLViewer.cpp +++ b/zed-unity-livelink-fusion/src/GLViewer.cpp @@ -287,9 +287,6 @@ void GLViewer::addSKeleton(sl::BodyData& obj, Simple3DObject& simpleObj, sl::flo case sl::BODY_FORMAT::BODY_38: createSKPrimitive(obj, sl::BODY_38_BONES, simpleObj, clr_id, raw); break; - case sl::BODY_FORMAT::BODY_70: - createSKPrimitive(obj, sl::BODY_70_BONES, simpleObj, clr_id, raw); - break; } } @@ -306,9 +303,6 @@ void GLViewer::addSKeleton(sl::BodyData& obj, Simple3DObject& simpleObj, sl::flo case 38: createSKPrimitive(obj, sl::BODY_38_BONES, simpleObj, clr_id, raw); break; - case 70: - createSKPrimitive(obj, sl::BODY_70_BONES, simpleObj, clr_id, raw); - break; } }