comparison 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
comparison
equal deleted inserted replaced
0:347d21cdfc22 1:f7675884f2a1
1 using Leap;
2 using UnityEngine;
3 using System.Collections;
4
5
6 public class HandFader : MonoBehaviour {
7 public float confidenceSmoothing = 10.0f;
8 public AnimationCurve confidenceCurve;
9
10 private HandModel _handModel;
11 private float _smoothedConfidence = 0.0f;
12 private Renderer _renderer;
13
14 void Awake() {
15 _handModel = GetComponent<HandModel>();
16 _renderer = GetComponentInChildren<Renderer>();
17 _renderer.material.SetFloat("_Fade", 0);
18 }
19
20 void Update () {
21 _smoothedConfidence += (_handModel.GetLeapHand().Confidence - _smoothedConfidence) / confidenceSmoothing;
22 float fade = confidenceCurve.Evaluate(_smoothedConfidence);
23 _renderer.enabled = fade != 0.0f;
24 _renderer.material.SetFloat("_Fade", confidenceCurve.Evaluate(_smoothedConfidence));
25 }
26 }