Beispiel #1
0
        /// <summary> Calculate a 3D position of the wrist, based on an existing tracking hardware and its location. </summary>
        /// <param name="trackedObject"></param>
        /// <param name="hardware"></param>
        /// <param name="wristPos"></param>
        /// <param name="wristRot"></param>
        /// <returns></returns>
        public virtual bool GetWristLocation(Transform trackedObject, SGCore.PosTrackingHardware hardware, out Vector3 wristPos, out Quaternion wristRot)
        {
#if UNFINISHED_FEATURES
            if (CVDataAvailable())
            {
                wristPos = SG.Util.SG_Conversions.ToUnityPosition(this.lastCVData.wristWorldPosition);
                wristRot = SG.Util.SG_Conversions.ToUnityQuaternion(this.lastCVData.wristWorldRotation);
                return(true);
            }
#endif
            if (this.lastGlove != null)
            {
                SGCore.Kinematics.Vect3D trackedPos = SG.Util.SG_Conversions.ToPosition(trackedObject.position, true);
                SGCore.Kinematics.Quat   trackedRot = SG.Util.SG_Conversions.ToQuaternion(trackedObject.rotation);

                SGCore.Kinematics.Vect3D wPos; SGCore.Kinematics.Quat wRot;
                lastGlove.GetWristLocation(trackedPos, trackedRot, hardware, out wPos, out wRot);

                wristPos = SG.Util.SG_Conversions.ToUnityPosition(wPos);
                wristRot = SG.Util.SG_Conversions.ToUnityQuaternion(wRot);
                return(true);
            }
            wristPos = trackedObject.position;
            wristRot = trackedObject.rotation;
            return(false);
        }
Beispiel #2
0
 /// <summary> Update the TrackedObject and -Hardware of this TrackedHand </summary>
 /// <param name="trackedObj"></param>
 /// <param name="hardware"></param>
 public virtual void SetTrackingHardware(Transform trackedObj, SGCore.PosTrackingHardware hardware)
 {
     this.trackedObject    = trackedObj;
     this.trackingHardware = hardware;
     //Calculate custom offstes if these are used.
     if (trackedObject != null)
     {
         SG.Util.SG_Util.CalculateOffsets(this.transform, this.trackedObject, out this.customPosOffset, out this.customRotOffset);
     }
 }
Beispiel #3
0
        //--------------------------------------------------------------------------------------------------------
        // Tracking


        /// <summary> Calculates the 3D position of the glove hardware origin. Mostly used in representing a 3D model of the hardware. If you wish to know where the hand is; use GetWristLocation instead. </summary>
        /// <param name="trackedObject"></param>
        /// <param name="hardware"></param>
        /// <param name="wristPos"></param>
        /// <param name="wristRot"></param>
        /// <returns></returns>
        public virtual bool GetGloveLocation(Transform trackedObject, SGCore.PosTrackingHardware hardware, out Vector3 glovePos, out Quaternion gloveRot)
        {
            if (this.lastGlove != null)
            {
                SGCore.Kinematics.Vect3D trackedPos = SG.Util.SG_Conversions.ToPosition(trackedObject.position, true);
                SGCore.Kinematics.Quat   trackedRot = SG.Util.SG_Conversions.ToQuaternion(trackedObject.rotation);

                SGCore.Kinematics.Vect3D wPos; SGCore.Kinematics.Quat wRot;
                lastGlove.GetGloveLocation(trackedPos, trackedRot, hardware, out wPos, out wRot);

                glovePos = SG.Util.SG_Conversions.ToUnityPosition(wPos);
                gloveRot = SG.Util.SG_Conversions.ToUnityQuaternion(wRot);
                return(true);
            }
            glovePos = trackedObject.position;
            gloveRot = trackedObject.rotation;
            return(false);
        }