/// <summary> Fire the GlloveRemoved event </summary> /// <param name="hand"></param> protected void OnGloveRemoved(SG_TrackedHand hand) { if (GloveRemoved != null) { GloveRemoved(this, new GloveDetectionArgs(hand)); } }
public static void EnableGrasps(SG_TrackedHand hand, bool enabled) { if (hand != null && hand.grabScript != null) { hand.grabScript.GrabEnabled = enabled; } }
public static void SetCalibrationChecks(SG_TrackedHand hand, bool checkOnStart) { if (hand != null && hand.gloveHardware != null) { hand.gloveHardware.checkCalibrationOnStart = checkOnStart; } }
public static void SetCalibrationLayer(SG_TrackedHand hand, SG_CalibrationSequence.StartCondition condition) { if (hand != null && hand.calibration != null) { hand.calibration.startCondition = condition; } }
/// <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); }
// 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; }
/// <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; } }
/// <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); }
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)); } } }
//------------------------------------------------------------------------------------------------------ // 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 }
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 }
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); } }
/// <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); }
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); }
//-------------------------------------------------------------------------------------------------------------------------- // 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); }
public static bool GetCalibrationLayer(SG_TrackedHand hand, out SG_CalibrationSequence calibrationLayer) { calibrationLayer = hand != null && hand.calibration != null ? hand.calibration : null; return(calibrationLayer != null); }
/// <summary> Create a new instance of the SenseGlove Detection Arguments </summary> /// <param name="grab"></param> public GloveDetectionArgs(SG_TrackedHand hand) { this.trackedHand = hand; }
/// <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)); }
//-------------------------------------------------------------------------------------------------------------------------- // 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); }
/// <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); }