Tanoda
HandRepresentation.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 System.Collections.Generic;
10
11namespace Leap.Unity {
18 public class HandRepresentation {
19 HandModelManager parent;
20 public int HandID { get; private set; }
21 public int LastUpdatedTime { get; set; }
22 public bool IsMarked { get; set; }
23 public Chirality RepChirality { get; protected set; }
24 public ModelType RepType { get; protected set; }
25 public Hand MostRecentHand { get; protected set; }
26 public List<HandModelBase> handModels;
27
28 public HandRepresentation(HandModelManager parent, Hand hand, Chirality repChirality, ModelType repType) {
29 this.parent = parent;
30 HandID = hand.Id;
31 this.RepChirality = repChirality;
32 this.RepType = repType;
33 this.MostRecentHand = hand;
34 }
35
37 public void Finish() {
38 if (handModels != null) {
39 for (int i = 0; i < handModels.Count; i++) {
40 handModels[i].FinishHand();
41 parent.ReturnToPool(handModels[i]);
42 handModels[i] = null;
43 }
44 }
45 parent.RemoveHandRepresentation(this);
46 }
47
48 public void AddModel(HandModelBase model) {
49 if (handModels == null) {
50 handModels = new List<HandModelBase>();
51 }
52 handModels.Add(model);
53 if (model.GetLeapHand() == null) {
55 model.InitHand();
56 model.BeginHand();
57 model.UpdateHandWithEvent();
58 } else {
60 model.BeginHand();
61
62 }
63 }
64
65 public void RemoveModel(HandModelBase model) {
66 if (handModels != null) {
67 model.FinishHand();
68 handModels.Remove(model);
69 }
70 }
71
73 public void UpdateRepresentation(Hand hand) {
74 MostRecentHand = hand;
75 if (handModels != null) {
76 for (int i = 0; i < handModels.Count; i++) {
77 handModels[i].SetLeapHand(hand);
78 handModels[i].UpdateHandWithEvent();
79 }
80 }
81 }
82 }
83}
The Hand class reports the physical characteristics of a detected hand.
Definition: Hand.cs:26
int Id
A unique ID assigned to this Hand object, whose value remains the same across consecutive frames whil...
Definition: Hand.cs:152
virtual void FinishHand()
virtual void BeginHand()
virtual void InitHand()
abstract Hand GetLeapHand()
abstract void SetLeapHand(Hand hand)
The HandModelManager manages a pool of HandModelBases and makes HandRepresentations when a it detects...
void RemoveHandRepresentation(HandRepresentation handRepresentation)
void ReturnToPool(HandModelBase model)
void RemoveModel(HandModelBase model)
HandRepresentation(HandModelManager parent, Hand hand, Chirality repChirality, ModelType repType)
List< HandModelBase > handModels
void AddModel(HandModelBase model)