Example #1
0
 /// <summary> Fire the GlloveRemoved event </summary>
 /// <param name="hand"></param>
 protected void OnGloveRemoved(SG_TrackedHand hand)
 {
     if (GloveRemoved != null)
     {
         GloveRemoved(this, new GloveDetectionArgs(hand));
     }
 }
Example #2
0
 public static void EnableGrasps(SG_TrackedHand hand, bool enabled)
 {
     if (hand != null && hand.grabScript != null)
     {
         hand.grabScript.GrabEnabled = enabled;
     }
 }
Example #3
0
 public static void SetCalibrationChecks(SG_TrackedHand hand, bool checkOnStart)
 {
     if (hand != null && hand.gloveHardware != null)
     {
         hand.gloveHardware.checkCalibrationOnStart = checkOnStart;
     }
 }
Example #4
0
 public static void SetCalibrationLayer(SG_TrackedHand hand, SG_CalibrationSequence.StartCondition condition)
 {
     if (hand != null && hand.calibration != null)
     {
         hand.calibration.startCondition = condition;
     }
 }
Example #5
0
 /// <summary> Get a list of all SG_TrackedHands within this detection area. </summary>
 /// <returns></returns>
 public SG_TrackedHand[] HandsInside()
 {
     SG_TrackedHand[] res = new SG_TrackedHand[this.detectedHands.Count];
     for (int i = 0; i < this.detectedHands.Count; i++)
     {
         res[i] = this.detectedHands[i].TrackedHand;
     }
     return(res);
 }
Example #6
0
            // Construction.

            /// <summary> Create a new instance of a detectedHand without any colliders. </summary>
            /// <param name="detectedHand"></param>
            public HandDetectArgs(SG_TrackedHand detectedHand)
            {
                TrackedHand     = detectedHand;
                EventFired      = false;
                DetectionTime   = 0;
                FingerColliders = new int[5];
                WristColliders  = 0;
                TotalColliders  = 0;
            }
Example #7
0
 /// <summary> Swap the tracking targets between this hand an another one. </summary>
 /// <param name="otherHand"></param>
 public virtual void SwapTracking(SG_TrackedHand otherHand)
 {
     if (otherHand != null)
     {
         Transform myTrackedObject = this.trackedObject;
         this.trackedObject      = otherHand.trackedObject;
         otherHand.trackedObject = myTrackedObject;
     }
 }
Example #8
0
 /// <summary> Returns the index of the SG_HandAnimator in this detector's detectedGloves. Returns -1 if it is not in the list. </summary>
 /// <param name="grab"></param>
 /// <returns></returns>
 private int HandModelIndex(SG_TrackedHand model)
 {
     for (int i = 0; i < this.detectedHands.Count; i++)
     {
         if (GameObject.ReferenceEquals(model.gameObject, this.detectedHands[i].TrackedHand.gameObject))
         {
             return(i);
         }
     }
     return(-1);
 }
Example #9
0
 public static void SetAnimation(SG_TrackedHand hand, bool enabled)
 {
     if (hand != null && hand.handAnimation != null)
     {
         hand.handAnimation.gameObject.SetActive(enabled);
         if (!enabled)
         {
             hand.handAnimation.UpdateHand(SG_HandPose.Idle(hand.TracksRightHand));
         }
     }
 }
Example #10
0
        //------------------------------------------------------------------------------------------------------
        //   Class Methods

        #region ClassMethods

        protected override void FireDetectEvent(SG_TrackedHand model)
        {
            this.SetAudio(true);
            this.SetParticles(true);
            this.SetEffectObject(true);
            if (this.hapticFeedback)
            {
                this.FireHapticFeedback();
            }
            this.inUse++;
            base.FireDetectEvent(model); //do X, then fire
        }
Example #11
0
 protected override void FireRemoveEvent(SG_TrackedHand model)
 {
     this.SetAudio(false);
     this.SetParticles(false);
     this.SetEffectObject(false);
     if (this.hapticFeedback)
     {
         this.FireHapticFeedback(true);
     }
     this.inUse--;
     base.FireRemoveEvent(model); //do Y, then fire
 }
Example #12
0
 protected void ResetCalibrationRange(SG_TrackedHand hand)
 {
     if (this.currStage == VoidStage.ConfirmCalibration && hand != null && hand.calibration != null && hand.calibration.internalSequence != null)
     {
         Debug.Log("Resettign Range of " + hand.gameObject.name);
         hand.calibration.internalSequence.Reset();
         if (hand.gloveHardware != null)
         {
             hand.gloveHardware.SendCmd(this.wf_connected);
         }
         GoToStage(VoidStage.MoveFingers);
     }
 }
Example #13
0
 /// <summary> Returns true if a SG_TrackedHand is detected by this zone. </summary>
 /// <param name="hand"></param>
 /// <returns></returns>
 public bool IsDetected(SG_TrackedHand hand)
 {
     if (hand != null)
     {
         for (int i = 0; i < this.detectedHands.Count; i++)
         {
             if (detectedHands[i].TrackedHand == hand && detectedHands[i].EventFired)
             {
                 return(true);
             }                                                                                         //returns true but only if the glove has fires its event.
         }
     }
     return(false);
 }
Example #14
0
 public bool CheckConfirm(bool shouldCheck, SG_TrackedHand hand, SG_CalibrationSequence sequence, ref bool[] gest)
 {
     if (shouldCheck)
     {
         float[] normalizedFlexion;
         if (hand != null && hand.gloveHardware != null && hand.gloveHardware.GetNormalizedFlexion(out normalizedFlexion))
         {
             bool allGood = true;
             //Debug.Log(SG.Util.SG_Util.ToString(normalizedFlexion));
             for (int f = 0; f < normalizedFlexion.Length && f < gest.Length && f < thumbsUpThresholds.Length; f++)
             {
                 if (gest[f])                         //finger is currently making a gesture
                 {
                     if (f == 0)
                     {
                         gest[f] = normalizedFlexion[f] < thumbsUpThresholds[f] + thumbPassThreshold;
                     }
                     else
                     {
                         gest[f] = normalizedFlexion[f] > thumbsUpThresholds[f] - thumbPassThreshold;
                     }
                 }
                 else                         //finger is not yet in the right spot
                 {
                     if (f == 0)
                     {
                         gest[f] = normalizedFlexion[f] < thumbsUpThresholds[f];
                     }
                     else
                     {
                         gest[f] = normalizedFlexion[f] > thumbsUpThresholds[f];
                     }
                 }
                 if (!gest[f])
                 {
                     allGood = false;
                 }
             }
             return(allGood);
         }
         return(false);
     }
     return(true);
 }
Example #15
0
        //--------------------------------------------------------------------------------------------------------------------------
        // Events

        #region Events

        /// <summary> A step in between events that can be overridden by sub-classes of the SenseGlove_Detector </summary>
        /// <param name="model"></param>
        protected virtual void FireDetectEvent(SG_TrackedHand hand)
        {
            this.OnGloveDetected(hand);
        }
Example #16
0
 public static bool GetCalibrationLayer(SG_TrackedHand hand, out SG_CalibrationSequence calibrationLayer)
 {
     calibrationLayer = hand != null && hand.calibration != null ? hand.calibration : null;
     return(calibrationLayer != null);
 }
Example #17
0
 /// <summary> Create a new instance of the SenseGlove Detection Arguments </summary>
 /// <param name="grab"></param>
 public GloveDetectionArgs(SG_TrackedHand hand)
 {
     this.trackedHand = hand;
 }
Example #18
0
 /// <summary> Add a newly detected SenseGlove to the list of detected gloves. </summary>
 /// <param name="model"></param>
 private void AddEntry(SG_TrackedHand model)
 {
     this.detectedHands.Add(new HandDetectArgs(model));
 }
Example #19
0
        //--------------------------------------------------------------------------------------------------------------------------
        // Functions

        /// <summary> Check for the relevant scripts connected to this handModel. </summary>
        public virtual void CheckForScripts()
        {
            this.TrackedHand = SG.Util.SG_Util.CheckForTrackedHand(this.transform);
        }
Example #20
0
 /// <summary> A step in between events that can be overridden by sub-classes of the SenseGlove_Detector </summary>
 /// <param name="model"></param>
 protected virtual void FireRemoveEvent(SG_TrackedHand hand)
 {
     this.OnGloveRemoved(hand);
 }