comparison Orchestland/Assets/LeapMotion/Scripts/Hands/DebugHand.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 /**
12 * A HandModel that draws lines for the bones in the hand and its fingers.
13 *
14 * The debugs lines are only drawn in the Editor Scene view (when a hand is tracked) and
15 * not in the Game view. Use debug hands when you aren't using visible hands in a scene
16 * so that you can see where the hands are in the scene view.
17 * */
18 public class DebugHand : HandModel {
19
20 /**
21 * Initializes the hand and calls the line drawing function.
22 */
23 public override void InitHand() {
24 for (int f = 0; f < fingers.Length; ++f) {
25 if (fingers[f] != null)
26 fingers[f].InitFinger();
27 }
28
29 DrawDebugLines();
30 }
31
32 /**
33 * Updates the hand and calls the line drawing function.
34 */
35 public override void UpdateHand() {
36 for (int f = 0; f < fingers.Length; ++f) {
37 if (fingers[f] != null)
38 fingers[f].UpdateFinger();
39 }
40
41 DrawDebugLines();
42 }
43
44 /**
45 * Draws lines from elbow to wrist, wrist to palm, and normal to the palm.
46 */
47 protected void DrawDebugLines() {
48 HandModel hand = GetComponent<HandModel>();
49 Debug.DrawLine(hand.GetElbowPosition(), hand.GetWristPosition(), Color.red);
50 Debug.DrawLine(hand.GetWristPosition(), hand.GetPalmPosition(), Color.white);
51 Debug.DrawLine(hand.GetPalmPosition(),
52 hand.GetPalmPosition() + hand.GetPalmNormal(), Color.black);
53 Debug.Log(Vector3.Dot(hand.GetPalmDirection(), hand.GetPalmNormal()));
54 }
55 }