Tanoda
SkeletalHand.cs
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (C) Ultraleap, Inc. 2011-2020. *
3 * *
4 * Use subject to the terms of the Apache License 2.0 available at *
5 * http://www.apache.org/licenses/LICENSE-2.0, or another agreement *
6 * between Ultraleap and you, your company or other organization. *
7 ******************************************************************************/
8
9using UnityEngine;
10using System.Collections;
11using Leap;
12
13namespace Leap.Unity{
19 public class SkeletalHand : HandModel {
20 public override ModelType HandModelType {
21 get {
22 return ModelType.Graphics;
23 }
24 }
25 protected const float PALM_CENTER_OFFSET = 0.015f;
26
27 void Start() {
28 // Ignore collisions with self.
29 Leap.Unity.Utils.IgnoreCollisions(gameObject, gameObject);
30
31 for (int i = 0; i < fingers.Length; ++i) {
32 if (fingers[i] != null) {
34 }
35 }
36 }
37
39 public override void UpdateHand() {
41 }
42
43 protected Vector3 GetPalmCenter() {
44 Vector3 offset = PALM_CENTER_OFFSET * Vector3.Scale(GetPalmDirection(), transform.lossyScale);
45 return GetPalmPosition() - offset;
46 }
47
48 protected void SetPositions() {
49 for (int f = 0; f < fingers.Length; ++f) {
50 if (fingers[f] != null) {
52 }
53 }
54
55 if (palm != null) {
56 palm.position = GetPalmCenter();
57 palm.rotation = GetPalmRotation();
58 }
59
60 if (wristJoint != null) {
61 wristJoint.position = GetWristPosition();
62 wristJoint.rotation = GetPalmRotation();
63 }
64
65 if (forearm != null) {
66 forearm.position = GetArmCenter();
67 forearm.rotation = GetArmRotation();
68 }
69 }
70 }
71}
The Finger class represents a tracked finger.
Definition: Finger.cs:20
FingerType
Enumerates the names of the fingers.
Definition: Finger.cs:167
Finger.FingerType fingerType
Definition: FingerModel.cs:34
abstract void UpdateFinger()
Vector3 GetWristPosition()
Definition: HandModel.cs:165
Vector3 GetPalmPosition()
Definition: HandModel.cs:66
Vector3 GetArmCenter()
Definition: HandModel.cs:127
Quaternion GetArmRotation()
Definition: HandModel.cs:179
Vector3 GetPalmDirection()
Definition: HandModel.cs:88
Transform forearm
Definition: HandModel.cs:53
FingerModel[] fingers
Definition: HandModel.cs:47
Quaternion GetPalmRotation()
Definition: HandModel.cs:73
Transform wristJoint
Definition: HandModel.cs:55
override ModelType HandModelType
Definition: SkeletalHand.cs:20
const float PALM_CENTER_OFFSET
Definition: SkeletalHand.cs:25
override void UpdateHand()
Definition: SkeletalHand.cs:39