-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathUser.cs
106 lines (92 loc) · 2.8 KB
/
User.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenNI;
using System.Diagnostics;
using System.Drawing;
namespace KinectProvider
{
/// <summary>
/// One user with two hands
/// keeping track of color and so on
/// </summary>
/// <author>Christopher-Eyk Hrabia - www.ceh-photo.de</author>
class User : IDisposable
{
int id;
/// <summary>
/// Different colors for different users
/// </summary>
static readonly Color[] USERCOLOR = { Color.Blue, Color.Red, Color.Green, Color.Violet,
Color.Yellow, Color.Brown, Color.Cyan, Color.Magenta };
/// <summary>
/// Id this user
/// </summary>
public int Id
{
get { return id; }
set { id = value; }
}
/// <summary>
/// Current user joint setup
/// </summary>
Dictionary<SkeletonJoint, SkeletonJointPosition> joints;
public Dictionary<SkeletonJoint, SkeletonJointPosition> Joints
{
get { return joints; }
set { joints = value; }
}
/// <summary>
/// User hands (usally two)
/// </summary>
Hand[] hands;
public User(int id, Dictionary<SkeletonJoint, SkeletonJointPosition> joints)
{
this.id = id;
this.joints = joints;
hands = new Hand[2];
//init hands, generate color based on id
for (int i = 0; i < hands.Length; i++)
{
hands[i] = new Hand(USERCOLOR[id % USERCOLOR.Length]);
}
}
/// <summary>
/// Update specific hand
/// </summary>
/// <param name="pos"></param>
/// <param name="hand"></param>
/// <param name="status"></param>
/// <returns></returns>
public HandContact updateHand(Point3D pos, uint hand, InputStatus status)
{
if (hand > 1)
{
hand = 1;
}
return hands[hand].update(pos.X, pos.Y, status);
}
/// <summary>
/// Update just hand state
/// </summary>
/// <param name="hand"></param>
/// <param name="status"></param>
/// <returns></returns>
public HandContact updateHand(uint hand, InputStatus status)
{
if (hand > 1)
{
hand = 1;
}
return hands[hand].update(status);
}
public void Dispose()
{
for (int i = 0; i < hands.Length; i++)
{
hands[i].Dispose();
}
}
}
}