diff --git a/Runtime/HumanoidControl/Scripts/Extensions/ArmSensor.cs b/Runtime/HumanoidControl/Scripts/Extensions/ArmSensor.cs index b8060c7..984328a 100644 --- a/Runtime/HumanoidControl/Scripts/Extensions/ArmSensor.cs +++ b/Runtime/HumanoidControl/Scripts/Extensions/ArmSensor.cs @@ -341,8 +341,8 @@ namespace Passer.Humanoid { if (handSkeleton == null) return; - Transform thisBoneTransform = handSkeleton.GetBone(finger, fingerBone); - Transform nextBoneTransform = handSkeleton.GetBone(finger, fingerBone + 1); + Transform thisBoneTransform = handSkeleton.GetBoneTransform(finger, fingerBone); + Transform nextBoneTransform = handSkeleton.GetBoneTransform(finger, fingerBone + 1); if (thisBoneTransform == null || nextBoneTransform == null) return; diff --git a/Runtime/HumanoidControl/Scripts/Extensions/BodySkeleton.cs b/Runtime/HumanoidControl/Scripts/Extensions/BodySkeleton.cs index 799127e..92d7f07 100644 --- a/Runtime/HumanoidControl/Scripts/Extensions/BodySkeleton.cs +++ b/Runtime/HumanoidControl/Scripts/Extensions/BodySkeleton.cs @@ -3,46 +3,60 @@ using UnityEngine; namespace Passer.Tracking { - public class BodySkeleton : TrackerComponent { + /// + /// The representation of a tracked body + /// + /// The bone hierarchy will be created below this transform at runtime. + public abstract class BodySkeleton : TrackerComponent { + /// + /// Determines whether the skeleton should be rendered + /// public bool show = false; + /// + /// The list of tracked bones + /// protected List bones; //protected static Material boneWhite; #region Start - protected virtual void InitializeSkeleton() { + /// + /// This function is used to intialize the tracked bones. + /// + protected abstract void InitializeSkeleton(); - } + // protected TrackedBone AddBone(string name, Transform parent) { + // GameObject boneGO = new GameObject(name); + // boneGO.transform.SetParent(parent, false); -// protected TrackedBone AddBone(string name, Transform parent) { -// GameObject boneGO = new GameObject(name); -// boneGO.transform.SetParent(parent, false); + // AddBoneRenderer(boneGO); -// AddBoneRenderer(boneGO); + // TrackedBone bone = new TrackedBone() { + // transform = boneGO.transform + // }; + // return bone; + // } -// TrackedBone bone = new TrackedBone() { -// transform = boneGO.transform -// }; -// return bone; -// } - -// protected void AddBoneRenderer(GameObject boneGO) { -// LineRenderer boneRenderer = boneGO.AddComponent(); -// boneRenderer.startWidth = 0.01F; -// boneRenderer.endWidth = 0.01F; -// boneRenderer.useWorldSpace = false; -// boneRenderer.SetPosition(0, Vector3.zero); -// boneRenderer.SetPosition(1, Vector3.zero); -// boneRenderer.generateLightingData = true; -// boneRenderer.material = boneWhite; -// } + // protected void AddBoneRenderer(GameObject boneGO) { + // LineRenderer boneRenderer = boneGO.AddComponent(); + // boneRenderer.startWidth = 0.01F; + // boneRenderer.endWidth = 0.01F; + // boneRenderer.useWorldSpace = false; + // boneRenderer.SetPosition(0, Vector3.zero); + // boneRenderer.SetPosition(1, Vector3.zero); + // boneRenderer.generateLightingData = true; + // boneRenderer.material = boneWhite; + // } #endregion #region Update + /// + /// Updates the rendering of the bones + /// protected void UpdateSkeletonRender() { if (bones == null) return; @@ -89,6 +103,11 @@ namespace Passer.Tracking { #endregion Update + /// + /// Gets the transform of the tracked bone + /// + /// The requested bone + /// The tracked bone transform or *null* if it does not exist public Transform GetBoneTransform(Humanoid.Tracking.Bone boneId) { TrackedBone trackedBone = GetBone(boneId); if (trackedBone == null) @@ -96,6 +115,11 @@ namespace Passer.Tracking { return trackedBone.transform; } + /// + /// Gets the tracked bone + /// + /// The requested bone + /// The tracked bone or *null* if it does not exist public TrackedBone GetBone(Humanoid.Tracking.Bone boneId) { if (bones == null) return null; diff --git a/Runtime/HumanoidControl/Scripts/Extensions/HandSkeleton.cs b/Runtime/HumanoidControl/Scripts/Extensions/HandSkeleton.cs index 88a7fc1..5c8b1f5 100644 --- a/Runtime/HumanoidControl/Scripts/Extensions/HandSkeleton.cs +++ b/Runtime/HumanoidControl/Scripts/Extensions/HandSkeleton.cs @@ -5,14 +5,24 @@ namespace Passer.Tracking { using Passer.Humanoid.Tracking; /// - /// Hand tracking skeleton + /// The representation of a tracked hand /// + /// The bone hierarchy will be created below this transform at runtime public class HandSkeleton : SensorComponent { + /// + /// True: this is a left hand. Fale: this is a right hand + /// public bool isLeft; + /// + /// Determines whether this skeleton should be rendered + /// public new bool show = false; + /// + /// The list of tracked bones + /// protected List bones; //protected static Material boneWhite; @@ -50,6 +60,9 @@ namespace Passer.Tracking { #region Start + /// + /// This function is used to initialize the tracked bones + /// protected virtual void InitializeSkeleton() { bones = new List(new TrackedBone[(int)BoneId.Count]); @@ -104,6 +117,9 @@ namespace Passer.Tracking { #region Update + /// + /// Updates the rendering of the bones + /// protected void UpdateSkeletonRender() { if (bones == null) return; @@ -158,7 +174,13 @@ namespace Passer.Tracking { return this.transform; } - public virtual Transform GetBone(Finger finger, FingerBone fingerBone) { + /// + /// Gets the transform of the tracked bone + /// + /// The requested finger + /// The requested bone in the finger + /// The tracked bon transform of *null* if it does not exist + public virtual Transform GetBoneTransform(Finger finger, FingerBone fingerBone) { if (bones == null) return null; diff --git a/Runtime/HumanoidControl/Scripts/Extensions/UnityXR/UnityXRHand.cs b/Runtime/HumanoidControl/Scripts/Extensions/UnityXR/UnityXRHand.cs index e324392..8f3c7bc 100644 --- a/Runtime/HumanoidControl/Scripts/Extensions/UnityXR/UnityXRHand.cs +++ b/Runtime/HumanoidControl/Scripts/Extensions/UnityXR/UnityXRHand.cs @@ -190,12 +190,12 @@ namespace Passer.Humanoid { if (handSkeleton == null) return; - Transform thisBoneTransform = handSkeleton.GetBone(finger, fingerBone); + Transform thisBoneTransform = handSkeleton.GetBoneTransform(finger, fingerBone); if (thisBoneTransform == null) { Debug.Log(finger + " " + fingerBone + " " + thisBoneTransform); return; } - Transform nextBoneTransform = handSkeleton.GetBone(finger, fingerBone + 1); + Transform nextBoneTransform = handSkeleton.GetBoneTransform(finger, fingerBone + 1); if (thisBoneTransform == null || nextBoneTransform == null) return; diff --git a/Runtime/HumanoidControl/Scripts/HumanoidControl_Doc.cs b/Runtime/HumanoidControl/Scripts/HumanoidControl_Doc.cs index c5e0c04..69fba29 100644 --- a/Runtime/HumanoidControl/Scripts/HumanoidControl_Doc.cs +++ b/Runtime/HumanoidControl/Scripts/HumanoidControl_Doc.cs @@ -17,7 +17,7 @@ /// * \ref UnityXRTracker "UnityXR" /// * \ref LeapTracker "Leap Motion" /// * \ref ViveTrackerDoc "Vive Tracker" - /// * \ref PerceptionNeuronTracker "Perception Neuron" + /// * \ref NeuronTracker "Perception Neuron" /// /// Input /// -----