forked from liliskubidu/ISoundKP3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPartitionManager.cs
89 lines (82 loc) · 2.64 KB
/
PartitionManager.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
using Microsoft.Kinect;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GesturalMusic
{
enum PartitionType
{
Single,
DoubleLeftRight,
DoubleFrontBack,
Quad
}
static class PartitionManager
{
public static PartitionType currentPartitionType;
// Store whether the partitions are set or not
public static bool[] isPartitionSet = new bool[] {false, false, false, false};
public static string val3 = "void";
// Store which instruments the partitions are set with, if set.
public static string[] partitionInstrSetName = new string[] { val3, val3, val3, val3 };
/// <summary>
/// Get the current partition in which the first tracked body resides in
/// according to the partition type set
/// </summary>
/// <param name="spineMidPos"></param>
/// <returns></returns>
public static int GetPartition(CameraSpacePoint spineMidPos)
{
if(currentPartitionType == PartitionType.Single)
{
return 0;
}
else if(currentPartitionType == PartitionType.DoubleLeftRight)
{
if (spineMidPos.X > 0)
{
return 1;
}
return 0;
}
else if (currentPartitionType == PartitionType.DoubleFrontBack)
{
if (spineMidPos.Z > KinectStageArea.GetCenterZ())
{
return 1;
}
return 0;
}
else
{
// set quad partition
// 3 | 2
// -----------
// 1 | 0
// kinect
int partition = 0;
if (spineMidPos.X > 0)
{
partition = 1;
}
if (spineMidPos.Z > KinectStageArea.GetCenterZ())
{
partition += 2; // add 2 to make it the back partition
}
return partition;
}
}
/// <summary>
/// Set the type of partitions for the current object
/// </summary>
/// <param name="type"></param>
public static void SetPartitionType(PartitionType type)
{
currentPartitionType = type;
isPartitionSet = new bool[] { false, false, false, false };
partitionInstrSetName = new string[] { val3, val3, val3, val3 };
}
}
}