-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBVHViewer.cpp
More file actions
48 lines (38 loc) · 1.12 KB
/
Copy pathBVHViewer.cpp
File metadata and controls
48 lines (38 loc) · 1.12 KB
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
#include "BVHViewer.h"
#include <stack>
using namespace std;
BVHViewer::BVHViewer(std::vector<std::unique_ptr<Segment>> roots, Motion motion, int channels):
root(move(roots)), motion(motion), channels(channels){}
void BVHViewer::loadFrame(int frame){
if(frame >= this->frameSize()){
frame %= this->frameSize();
}
vector<double> data = this->motion[frame];
int dataPtr = 0;
stack<Segment *> segQ;
for(auto iter = this->root.begin(); iter < this->root.end(); iter++){
segQ.push((*iter).get());
}
while(segQ.size() > 0){
Segment *curr = segQ.top();
segQ.pop();
int channels = curr->numChannels();
for(int i = 0; i < channels; i++){
curr->applyChannel(data[dataPtr], i);
dataPtr++;
}
int segs = curr->numSub();
for(int i = segs - 1; i >= 0; i--){
segQ.push(curr->getSeg(i));
}
}
}
void BVHViewer::draw(){
auto iter = this->root.begin();
for(; iter != this->root.end(); ++iter){
(*iter)->draw();
}
}
int BVHViewer::frameSize(){
return this->motion.size();
}