Beispiel #1
0
 /// <summary> Send an impact vibration to this script's connected glove, based on a speed in m/s. Checks for SG_RigidBodies. </summary>
 /// <param name="impactVelocity"></param>
 public void SendImpactFeedback(float impactVelocity, Collider col)
 {
     if (handLocation != SG_HandSection.Unknown && impactVelocity >= minImpactSpeed)
     {
         SG_TrackedBody rbScript;
         if (col == null || (col != null && !SG_TrackedBody.GetTrackedBodyScript(col, out rbScript))) //we either don't have a collider, or we do, but it doesn't have a RigidBody script.
         {
             int impactLevel;
             //evaluate the intensity
             if (impactVelocity > maxImpactSpeed || minImpactSpeed >= maxImpactSpeed)
             {
                 impactLevel = maxBuzzLevel;
             }
             else
             {
                 //map the impact parameters on the speed.
                 float mapped = Mathf.Clamp01(SG_Util.Map(impactVelocity, minImpactSpeed, maxImpactSpeed, 0, 1));
                 //we're actually start at minBuzzLevel; that's when you can start to feel the Sense Glove vibrations
                 impactLevel = (int)(SG_Util.Map(impactProfile.Evaluate(mapped), 0, 1, minBuzzLevel, maxBuzzLevel));
             }
             //actually send the effect
             if (linkedGlove != null && vibrationTime > 0)
             {
                 if (handLocation == SG_HandSection.Wrist) //it's a wrist.
                 {
                     linkedGlove.SendCmd(new SGCore.Haptics.TimedThumpCmd(impactLevel, vibrationTime));
                 }
                 else //finger
                 {
                     SGCore.Finger finger = (SGCore.Finger)handLocation; //can do this since the finger indices match
                     SGCore.Haptics.SG_TimedBuzzCmd buzzCmd = new SGCore.Haptics.SG_TimedBuzzCmd(finger, impactLevel, vibrationTime);
                     linkedGlove.SendCmd(buzzCmd);
                 }
                 cooldownTimer = 0; //reset cooldown for this finger.
             }
         }
     }
 }
    /// <summary> Send an impact vibration to this script's connected glove, based on a speed in m/s.  </summary>
    /// <param name="impactVelocity"></param>
    public void SendImpactFeedback(float impactVelocity)
    {
        if (handLocation != SG_HandSection.Unknown && impactVelocity >= minImpactSpeed)
        {
            int impactLevel;
            //evaluate the intensity
            if (impactVelocity > maxImpactSpeed || minImpactSpeed >= maxImpactSpeed)
            {
                impactLevel = maxBuzzLevel;
            }
            else
            {
                //map the impact parameters on the speed.
                float mapped = Mathf.Clamp01(SG_Util.Map(impactVelocity, minImpactSpeed, maxImpactSpeed, 0, 1));
                //we're actually start at minBuzzLevel; that's when you can start to feel the Sense Glove vibrations
                impactLevel = (int)(SG_Util.Map(impactProfile.Evaluate(mapped), 0, 1, minBuzzLevel, maxBuzzLevel));
            }
            //actually send the effect
            if (linkedGlove != null)
            {
                if (handLocation == SG_HandSection.Wrist)
                {
                    SenseGloveCs.ThumperEffect effect = impactLevel > 50 ? SenseGloveCs.ThumperEffect.Impact_Thump_100
                        : SenseGloveCs.ThumperEffect.Impact_Thump_30;

                    Debug.Log("Speed: " + impactVelocity + " => " + impactLevel + " => " + effect.ToString());
                    linkedGlove.SendThumperCmd(effect);
                }
                else //finger
                {
                    SenseGloveCs.Finger finger = (SenseGloveCs.Finger)handLocation; //can do this since the finger indices match
                    linkedGlove.SendBuzzCmd(finger, impactLevel, vibrationTime);
                }
                cooldownTimer = 0; //reset cooldown for this finger.
            }
        }
    }