Mercurial > hg > Game > Games
diff Orchestland/Assets/LeapMotion/Scripts/Hands/RiggedHand.cs @ 3:0030a1b971fb default tip
merge
author | Yuta ANSE <e135745@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 17 Jul 2015 23:23:43 +0900 |
parents | f7675884f2a1 |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Orchestland/Assets/LeapMotion/Scripts/Hands/RiggedHand.cs Fri Jul 17 23:23:43 2015 +0900 @@ -0,0 +1,41 @@ +/******************************************************************************\ +* Copyright (C) Leap Motion, Inc. 2011-2014. * +* Leap Motion proprietary. Licensed under Apache 2.0 * +* Available at http://www.apache.org/licenses/LICENSE-2.0.html * +\******************************************************************************/ + +using UnityEngine; +using System.Collections; +using Leap; + +// Class to setup a rigged hand based on a model. +public class RiggedHand : HandModel { + + public Vector3 modelFingerPointing = Vector3.forward; + public Vector3 modelPalmFacing = -Vector3.up; + + public override void InitHand() { + UpdateHand(); + } + + public Quaternion Reorientation() { + return Quaternion.Inverse(Quaternion.LookRotation(modelFingerPointing, -modelPalmFacing)); + } + + public override void UpdateHand() { + if (palm != null) { + palm.position = GetPalmPosition(); + palm.rotation = GetPalmRotation() * Reorientation(); + } + + if (forearm != null) + forearm.rotation = GetArmRotation() * Reorientation(); + + for (int i = 0; i < fingers.Length; ++i) { + if (fingers[i] != null) { + fingers[i].fingerType = (Finger.FingerType)i; + fingers[i].UpdateFinger(); + } + } + } +}