Mercurial > hg > Game > Games
diff Orchestland/Assets/LeapMotion/Scripts/Hands/HandFader.cs @ 1:f7675884f2a1
Add Orchestland project
author | Daiki OYAKAWA <e135764@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 17 Jul 2015 23:09:20 +0900 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Orchestland/Assets/LeapMotion/Scripts/Hands/HandFader.cs Fri Jul 17 23:09:20 2015 +0900 @@ -0,0 +1,26 @@ +using Leap; +using UnityEngine; +using System.Collections; + + +public class HandFader : MonoBehaviour { + public float confidenceSmoothing = 10.0f; + public AnimationCurve confidenceCurve; + + private HandModel _handModel; + private float _smoothedConfidence = 0.0f; + private Renderer _renderer; + + void Awake() { + _handModel = GetComponent<HandModel>(); + _renderer = GetComponentInChildren<Renderer>(); + _renderer.material.SetFloat("_Fade", 0); + } + + void Update () { + _smoothedConfidence += (_handModel.GetLeapHand().Confidence - _smoothedConfidence) / confidenceSmoothing; + float fade = confidenceCurve.Evaluate(_smoothedConfidence); + _renderer.enabled = fade != 0.0f; + _renderer.material.SetFloat("_Fade", confidenceCurve.Evaluate(_smoothedConfidence)); + } +}