/
ofxMotionerSkeleton.cpp
129 lines (113 loc) · 3.48 KB
/
ofxMotionerSkeleton.cpp
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
//
// ofxMotionerSkeleton.cpp
// ofxMotioner
//
// Created by Onishi Yoshito on 4/15/13.
//
//
#include "ofxMotionerSkeleton.h"
using namespace ofxMotioner;
//----------------------------------------------------------------------------------------
Skeleton::Skeleton() :
timestamp(0.0f),
mName("")
{
createTree();
}
//----------------------------------------------------------------------------------------
vector<Node> &Skeleton::getJoints()
{
return mJoints;
}
//----------------------------------------------------------------------------------------
const vector<Node> &Skeleton::getJoints() const
{
return mJoints;
}
//----------------------------------------------------------------------------------------
Node &Skeleton::getJoint(int id)
{
return mJoints.at(id);
}
//----------------------------------------------------------------------------------------
const Node &Skeleton::getJoint(int id) const
{
return mJoints.at(id);
}
//----------------------------------------------------------------------------------------
int Skeleton::getNumJoints() const
{
return mJoints.size();
}
//----------------------------------------------------------------------------------------
void Skeleton::setName(const string &name)
{
mName = name;
}
//----------------------------------------------------------------------------------------
const string &Skeleton::getName() const
{
return mName;
}
//----------------------------------------------------------------------------------------
void Skeleton::createTree()
{
mJoints.clear();
mJoints.assign(NUM_JOINTS, Node());
mJoints.at(JOINT_ABDOMEN).setParent(mJoints.at(JOINT_HIPS));
{
mJoints.at(JOINT_CHEST).setParent(mJoints.at(JOINT_ABDOMEN));
{
mJoints.at(JOINT_NECK).setParent(mJoints.at(JOINT_CHEST));
{
mJoints.at(JOINT_HEAD).setParent(mJoints.at(JOINT_NECK));
}
}
}
mJoints.at(JOINT_LEFT_COLLAR).setParent(mJoints.at(JOINT_ABDOMEN));
{
mJoints.at(JOINT_LEFT_SHOULDER).setParent(mJoints.at(JOINT_LEFT_COLLAR));
{
mJoints.at(JOINT_LEFT_ELBOW).setParent(mJoints.at(JOINT_LEFT_SHOULDER));
{
mJoints.at(JOINT_LEFT_WRIST).setParent(mJoints.at(JOINT_LEFT_ELBOW));
{
mJoints.at(JOINT_LEFT_HAND).setParent(mJoints.at(JOINT_LEFT_WRIST));
}
}
}
}
mJoints.at(JOINT_RIGHT_COLLAR).setParent(mJoints.at(JOINT_ABDOMEN));
{
mJoints.at(JOINT_RIGHT_SHOULDER).setParent(mJoints.at(JOINT_RIGHT_COLLAR));
{
mJoints.at(JOINT_RIGHT_ELBOW).setParent(mJoints.at(JOINT_RIGHT_SHOULDER));
{
mJoints.at(JOINT_RIGHT_WRIST).setParent(mJoints.at(JOINT_RIGHT_ELBOW));
{
mJoints.at(JOINT_RIGHT_HAND).setParent(mJoints.at(JOINT_RIGHT_WRIST));
}
}
}
}
mJoints.at(JOINT_LEFT_HIP).setParent(mJoints.at(JOINT_HIPS));
{
mJoints.at(JOINT_LEFT_KNEE).setParent(mJoints.at(JOINT_LEFT_HIP));
{
mJoints.at(JOINT_LEFT_ANKLE).setParent(mJoints.at(JOINT_LEFT_KNEE));
{
mJoints.at(JOINT_LEFT_TOE).setParent(mJoints.at(JOINT_LEFT_ANKLE));
}
}
}
mJoints.at(JOINT_RIGHT_HIP).setParent(mJoints.at(JOINT_HIPS));
{
mJoints.at(JOINT_RIGHT_KNEE).setParent(mJoints.at(JOINT_RIGHT_HIP));
{
mJoints.at(JOINT_RIGHT_ANKLE).setParent(mJoints.at(JOINT_RIGHT_KNEE));
{
mJoints.at(JOINT_RIGHT_TOE).setParent(mJoints.at(JOINT_RIGHT_ANKLE));
}
}
}
}