-
Notifications
You must be signed in to change notification settings - Fork 20
/
PBvh.pde
55 lines (50 loc) · 1.89 KB
/
PBvh.pde
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
class PBvh{
BvhParser parser;
PVector scaleFactor = new PVector(1,1,1);
PVector offset = new PVector(0,0,0);
int frame = 0;
int frameMax = 0;
PBvh(String[] data, PVector _sf, PVector _ofs){
parser = new BvhParser();
parser.init();
parser.parse(data);
//parser.setMotionLoop(false);
frameMax = parser._nbFrames;
scaleFactor = _sf;
offset = _ofs;
}
void update(int ms){
parser.moveMsTo(ms - startTime);
parser.update();
frame = parser.frame;
int counter = 0;
for(BvhBone b : parser.getBones()){
pushMatrix();
translate((b.absPos.x * scaleFactor.x) + offset.x, (b.absPos.y * scaleFactor.y) + offset.y, (b.absPos.z * scaleFactor.z) + offset.z);
//ellipse(0, 0, 10, 10);
popMatrix();
if (!b.hasChildren()){
pushMatrix();
translate((b.absEndPos.x * scaleFactor.x) + offset.x, (b.absEndPos.y * scaleFactor.y) + offset.y, (b.absEndPos.z * scaleFactor.z) + offset.z);
//ellipse(0, 0, 10, 10);
popMatrix();
}
boolean writeCoords = false;
for (int i=0;i<osceletonNames.length;i++) {
String name1 = "" + b.getName();
String name2 = "" + bvhJointNames[i];
if(name1.equals(name2)){
writeCoords = true;
counter=i;
}
}
if(writeCoords){
x[counter] = ((b.getAbsPosition().x * scaleFactor.x) + offset.x)/sW;
y[counter] = ((b.getAbsPosition().y * scaleFactor.y) + offset.y)/sH;
z[counter] = ((b.getAbsPosition().z * scaleFactor.z) + offset.z)/sD;///(sD*10); //approximate 'cause don't know real SimpleOpenNI depth max/min in pixels; will fix
//if(counter<osceletonNames.length-1d) counter++;
println(scaleFactor + " " + offset + " " + b.getName() + " " + osceletonNames[counter] + " " + x[counter] + " " + y[counter] + " " + z[counter]);
}
}
}
}