Mercurial > hg > Game > Games
comparison Orchestland/Assets/LeapMotion/Scripts/Hands/RiggedFinger.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 /******************************************************************************\ | |
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 /** | |
12 * Manages the orientation of the bones in a model rigged for skeletal animation. | |
13 * | |
14 * The class expects that the graphics model bones corresponding to bones in the Leap Motion | |
15 * hand model are in the same order in the bones array. | |
16 */ | |
17 public class RiggedFinger : FingerModel { | |
18 | |
19 /** Allows the mesh to be stretched to align with finger joint positions | |
20 * Only set to true when mesh is not visible | |
21 */ | |
22 public bool deformPosition = false; | |
23 | |
24 public Vector3 modelFingerPointing = Vector3.forward; | |
25 public Vector3 modelPalmFacing = -Vector3.up; | |
26 | |
27 public Quaternion Reorientation() { | |
28 return Quaternion.Inverse(Quaternion.LookRotation(modelFingerPointing, -modelPalmFacing)); | |
29 } | |
30 | |
31 /** Updates the bone rotations. */ | |
32 public override void UpdateFinger() { | |
33 for (int i = 0; i < bones.Length; ++i) { | |
34 if (bones[i] != null) { | |
35 bones[i].rotation = GetBoneRotation(i) * Reorientation(); | |
36 if (deformPosition) { | |
37 bones[i].position = GetBoneCenter(i); | |
38 } | |
39 } | |
40 } | |
41 } | |
42 } |