/// <summary> Add a newly detected SenseGlove to the list of detected gloves. </summary>
 /// <param name="model"></param>
 private void AddEntry(SG_SenseGloveHardware model)
 {
     this.detectedGloves.Add(model);
     this.detectionTimes.Add(0);
     this.detectedColliders.Add(1); //already add one.
     this.eventFired.Add(false);
 }
Beispiel #2
0
 /// <summary> Check for relevant scripts connected to this one, that may not yet have been assigned. </summary>
 public virtual void CheckForScripts()
 {
     if (this.Hand == null)
     {
         if (this.hardware != null)
         {
             this.Hand = this.hardware.GetComponent <SG_TrackedHand>();
         }
         if (this.Hand == null)
         {
             this.Hand = this.GetComponentInParent <SG_TrackedHand>();
         }
     }
     if (this.hardware == null)
     {
         if (this.Hand != null && this.Hand.hardware != null)
         {
             this.hardware = this.Hand.hardware;
         }
         else if (this.Hand != null)
         {
             this.hardware = this.Hand.gameObject.GetComponent <SG_SenseGloveHardware>();
         }
         if (this.hardware == null)
         {
             this.hardware = this.gameObject.GetComponent <SG_SenseGloveHardware>();
         }
     }
 }
 protected void OnGloveRemoved(SG_SenseGloveHardware model)
 {
     if (GloveRemoved != null)
     {
         GloveRemoved(this, new GloveDetectionArgs(model));
     }
 }
Beispiel #4
0
 /// <summary> Returns true if this Animator is connected to Sense Glove Hardware. Used in an if statement for safety </summary>
 /// <param name="hardware"></param>
 /// <returns></returns>
 public virtual bool GetHardware(out SG_SenseGloveHardware hardware)
 {
     if (HardwareReady)
     {
         hardware = this.Hand.hardware;
         return(hardware != null);
     }
     hardware = null;
     return(false);
 }
 /// <summary> Returns true if this FeedbackScript is connected to Sense Glove Hardware and returns a link to it. Used in an if statement for safety </summary>
 /// <param name="hardware"></param>
 /// <returns></returns>
 public bool GetHardware(out SG_SenseGloveHardware hardware)
 {
     if (HardwareReady)
     {
         hardware = connectedGlove;
         return(hardware != null);
     }
     hardware = null;
     return(false);
 }
Beispiel #6
0
 /// <summary> Get the index  </summary>
 /// <param name="grabScript"></param>
 /// <returns></returns>
 protected int GetTouchIndex(SG_SenseGloveHardware grabScript)
 {
     for (int i = 0; i < this.touchedScripts.Count; i++)
     {
         if (GameObject.ReferenceEquals(this.touchedScripts[i].gameObject, grabScript.gameObject))
         {
             return(i);
         }
     }
     return(-1);
 }
 /// <summary> Check for Scripts relevant for this Animator </summary>
 protected virtual void CheckForScripts()
 {
     if (this.Hand == null)
     {
         this.Hand = SG_Util.CheckForTrackedHand(this.transform);
     }
     if (this.senseGlove == null && this.Hand != null)
     {
         this.senseGlove = this.Hand.hardware;
     }
 }
 /// <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_SenseGloveHardware model)
 {
     for (int i = 0; i < this.detectedGloves.Count; i++)
     {
         if (GameObject.ReferenceEquals(model.gameObject, this.detectedGloves[i].gameObject))
         {
             return(i);
         }
     }
     return(-1);
 }
Beispiel #9
0
 protected override void FireRemoveEvent(SG_SenseGloveHardware 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
 }
 /// <summary> Checks for scripts that might be connected to this GameObject. Used in editor and during startup. </summary>
 public virtual void CheckForScripts()
 {
     if (connectedGlove == null)
     {
         connectedGlove = this.gameObject.GetComponent <SG_SenseGloveHardware>();
         if (connectedGlove == null && this.transform.parent != null) //still nothing
         {
             connectedGlove = this.transform.parent.GetComponent <SG_SenseGloveHardware>();
         }
     }
     SG_Util.CheckForHandInfo(this.transform, ref this.handModel);
 }
Beispiel #11
0
    //------------------------------------------------------------------------------------------------------
    //   Class Methods

    #region ClassMethods

    protected override void FireDetectEvent(SG_SenseGloveHardware model)
    {
        this.SetAudio(true);
        this.SetParticles(true);
        this.SetEffectObject(true);
        if (this.hapticFeedback)
        {
            this.FireHapticFeedback();
        }
        this.inUse++;
        base.FireDetectEvent(model); //do X, then fire
    }
    /// <summary> Link relevant scripts to this trackedHand, if they have not been assinged yet. </summary>
    protected void CheckForScripts()
    {
        if (this.hardware == null)
        {
            this.hardware = this.gameObject.GetComponent <SG_SenseGloveHardware>();
        }
        if (this.handModel == null)
        {
            this.handModel = this.GetComponentInChildren <SG_HandModelInfo>();
        }

        if (this.grabScript == null)
        {
            this.grabScript = this.GetComponentInChildren <SG_GrabScript>();
        }
        if (this.feedbackScript == null)
        {
            this.feedbackScript = this.GetComponentInChildren <SG_HandFeedback>();
        }
        if (this.handAnimation == null)
        {
            this.handAnimation = this.GetComponentInChildren <SG_HandAnimator>();
        }

        //Since both RB and PhysicsTrackingLayers have the same component, assing whichever one we haven't done yet.
        if (this.rigidBodyLayer == null || this.physicsTrackingLayer == null)
        {
            SG_HandRigidBodies[] components = this.GetComponentsInChildren <SG_HandRigidBodies>();
            for (int i = 0; i < components.Length; i++)
            {
                if (this.rigidBodyLayer == null && //we don't yet have a RigidBody Layer
                    (this.physicsTrackingLayer == null || !GameObject.ReferenceEquals(this.physicsTrackingLayer.gameObject, components[i].gameObject)))
                {
                    rigidBodyLayer = components[i];
                }
                if (this.physicsTrackingLayer == null && //we don't yet have a RigidBody Layer
                    (this.rigidBodyLayer == null || !GameObject.ReferenceEquals(this.rigidBodyLayer.gameObject, components[i].gameObject)))
                {
                    physicsTrackingLayer = components[i];
                }
            }
        }
    }
Beispiel #13
0
        void Start()
        {
            foreach (SG.SG_SenseGloveHardware obj in GameObject.FindObjectsOfType(typeof(SG.SG_SenseGloveHardware)))
            {
                string connectionMethod = obj.connectionMethod.ToString().ToLower();
                bool   match            = isRight ? connectionMethod.Equals("nextrighthand") : connectionMethod.Equals("nextlefthand");
                if (match)
                {
                    glove = obj;
                }
            }

            if (glove == null)
            {
                throw new MissingComponentException($"Could not find {handName} SG_SenseGloveHardware in Scene.");
            }

            Debug.Log($"Awaiting connection with {(isRight ? "right" : "left")} SenseGlove... ");
        }
    protected virtual void Start()
    {
        if (this.handAnimation != null && trackingHardware != TrackingHardware.Custom)
        {
            handAnimation.updateWrist = false;
        }
        SetupTracking(this.trackedObject, this.trackingHardware, this.trackingMethod, this.TracksRightHand);

        if (this.handAnimation != null)
        {
            this.handAnimation.senseGlove = this.hardware;
        }
        if (this.grabScript != null)
        {
            this.grabScript.hardware = this.hardware;
        }
        if (this.feedbackScript != null)
        {
            this.feedbackScript.connectedGlove = this.hardware;
        }
    }
Beispiel #15
0
        // Start is called before the first frame update
        void Start()
        {
            // find SenseGlove hardware automatically, as scene cross-referencing is not supported in unity
            foreach (SG.SG_SenseGloveHardware obj in GameObject.FindObjectsOfType(typeof(SG.SG_SenseGloveHardware)))
            {
                string connectionMethod = obj.connectionMethod.ToString().ToLower();
                bool   match            = isRight ? connectionMethod.Equals("nextrighthand") : connectionMethod.Equals("nextlefthand");
                if (match)
                {
                    hand = obj;
                }
            }

            if (hand == null)
            {
                throw new MissingComponentException($"Could not find {lrName} SG_SenseGloveHardware in Scene.");
            }

            // saving & loading
            OnDone((step) => Save());
            Load();

            // calibration timers
            calibrationParams.waitTimer.SetTimer(calibrationParams.waitTime, CalibrationWaitDone);
            calibrationParams.dwellTimer.SetTimer(calibrationParams.dwellTime, CalibrationDwellDone);

            // test Timer
            testParams.dwellTimer.SetTimer(testParams.dwellTime, () =>
            {
                currentStep = Step.Done;
                hand.SaveHandCalibration();
                Debug.Log($"Saved {lrName} hand calibration");
            });
            virtualHand.SetActive(false);
            calibrating = false;
            Debug.Log($"Awaiting connection with {lrName} SenseGlove... ");

            StateManager.Instance.onStateChangeTo[StateManager.States.HUD].Add((s) => StopCailbration(), once: true);
        }
 /// <summary> Create a new instance of the SenseGlove Detection Arguments </summary>
 /// <param name="grab"></param>
 public GloveDetectionArgs(SG_SenseGloveHardware model)
 {
     this.handModel = model;
 }
 /// <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_SenseGloveHardware model)
 {
     this.OnGloveRemoved(model);
 }