Mercurial > hg > Game > Games
comparison 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 |
comparison
equal
deleted
inserted
replaced
2:fdab88fc2cb9 | 3:0030a1b971fb |
---|---|
1 /******************************************************************************\ | |
2 * Copyright (C) Leap Motion, Inc. 2011-2014. * | |
3 * Leap Motion proprietary. Licensed under Apache 2.0 * | |
4 * Available at http://www.apache.org/licenses/LICENSE-2.0.html * | |
5 \******************************************************************************/ | |
6 | |
7 using UnityEngine; | |
8 using System.Collections; | |
9 using Leap; | |
10 | |
11 // Class to setup a rigged hand based on a model. | |
12 public class RiggedHand : HandModel { | |
13 | |
14 public Vector3 modelFingerPointing = Vector3.forward; | |
15 public Vector3 modelPalmFacing = -Vector3.up; | |
16 | |
17 public override void InitHand() { | |
18 UpdateHand(); | |
19 } | |
20 | |
21 public Quaternion Reorientation() { | |
22 return Quaternion.Inverse(Quaternion.LookRotation(modelFingerPointing, -modelPalmFacing)); | |
23 } | |
24 | |
25 public override void UpdateHand() { | |
26 if (palm != null) { | |
27 palm.position = GetPalmPosition(); | |
28 palm.rotation = GetPalmRotation() * Reorientation(); | |
29 } | |
30 | |
31 if (forearm != null) | |
32 forearm.rotation = GetArmRotation() * Reorientation(); | |
33 | |
34 for (int i = 0; i < fingers.Length; ++i) { | |
35 if (fingers[i] != null) { | |
36 fingers[i].fingerType = (Finger.FingerType)i; | |
37 fingers[i].UpdateFinger(); | |
38 } | |
39 } | |
40 } | |
41 } |