コード例 #1
0
    /// <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.
            }
        }
    }
コード例 #2
0
 private void SendThumperCmd(ThumperEffect effect)
 {
     senseGlove.SendThumperCmd(effect);
 }