view 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 source

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));
	}
}