Tanoda
RigidHand.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 {
15 public class RigidHand : SkeletalHand {
16 public override ModelType HandModelType {
17 get {
18 return ModelType.Physics;
19 }
20 }
21 public float filtering = 0.5f;
22
23 public override bool SupportsEditorPersistence() {
24 return true;
25 }
26
27 public override void InitHand() {
28 base.InitHand();
29 }
30
31 public override void UpdateHand() {
32
33 for (int f = 0; f < fingers.Length; ++f) {
34 if (fingers[f] != null) {
36 }
37 }
38
39 if (palm != null) {
40 Rigidbody palmBody = palm.GetComponent<Rigidbody>();
41 if (palmBody) {
42 palmBody.MovePosition(GetPalmCenter());
43 palmBody.MoveRotation(GetPalmRotation());
44 } else {
45 palm.position = GetPalmCenter();
46 palm.rotation = GetPalmRotation();
47 }
48 }
49
50 if (forearm != null) {
51 // Set arm dimensions.
52 CapsuleCollider capsule = forearm.GetComponent<CapsuleCollider>();
53 if (capsule != null) {
54 // Initialization
55 capsule.direction = 2;
56 forearm.localScale = new Vector3(1f / transform.lossyScale.x, 1f / transform.lossyScale.y, 1f / transform.lossyScale.z);
57
58 // Update
59 capsule.radius = GetArmWidth() / 2f;
60 capsule.height = GetArmLength() + GetArmWidth();
61 }
62
63 Rigidbody forearmBody = forearm.GetComponent<Rigidbody>();
64 if (forearmBody) {
65 forearmBody.MovePosition(GetArmCenter());
66 forearmBody.MoveRotation(GetArmRotation());
67 } else {
68 forearm.position = GetArmCenter();
69 forearm.rotation = GetArmRotation();
70 }
71 }
72 }
73 }
74}
abstract void UpdateFinger()
Vector3 GetArmCenter()
Definition: HandModel.cs:127
Quaternion GetArmRotation()
Definition: HandModel.cs:179
Transform forearm
Definition: HandModel.cs:53
FingerModel[] fingers
Definition: HandModel.cs:47
Quaternion GetPalmRotation()
Definition: HandModel.cs:73
override ModelType HandModelType
Definition: RigidHand.cs:16
override void UpdateHand()
Definition: RigidHand.cs:31
override void InitHand()
Definition: RigidHand.cs:27
override bool SupportsEditorPersistence()
Returns whether or not this hand model supports editor persistence. This is false by default and must...
Definition: RigidHand.cs:23