-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNumpyReader.cpp
More file actions
executable file
·62 lines (47 loc) · 1.49 KB
/
NumpyReader.cpp
File metadata and controls
executable file
·62 lines (47 loc) · 1.49 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "NumpyReader.h"
#include "LogMsg.h"
#include <Eigen/Dense>
#include <map>
#include <DemBones/MatBlocks.h>
using namespace std;
using namespace Eigen;
#define err(msgStr) {msg(1, msgStr); return false;}
bool readNumpy(MatrixXd vert_data,vector< vector<int> > face_data, DemBonesExt<double, float>& model){
// Using vertices define 3D parameters
model.nS = 1;
model.nF = vert_data.rows()/3;
model.nV = vert_data.cols();
model.fStart.resize(model.nS+1);
model.fStart(0)=0;
model.fStart(1) = model.nF;
model.subjectID.resize(model.nF);
for (int s=0; s<model.nS; s++)
for (int k=model.fStart(s); k<model.fStart(s+1); k++) model.subjectID(k)=s;
// Set model parameters
model.v.resize(3*model.nF,model.nV);
model.fTime.resize(model.nF);
for(auto i=0;i<model.fTime.size();i++){
model.fTime[i] = 1/33;
}
model.v = vert_data.cast<float>();
MatrixXd wd(0, 0);
// Using first frame as u
msg(1, "Adding First timestep as rest pose.\n");
model.u.resize(model.nS*3, model.nV);
for(int i= 0;i<3;i++)
for(int k=0;k<model.nV;k++)
model.u(i,k) = vert_data(i,k);
msg(1, " Done!\n");
// Assign faces
model.fv = face_data;
model.parent.resize(model.nB);
model.bind.resize(model.nS*4, model.nB*4);
model.preMulInv.resize(model.nS*4, model.nB*4);
model.rotOrder.resize(model.nS*3, model.nB);
model.orient.resize(model.nS*3, model.nB);
model.lockM.resize(model.nB);
// Manually set fTime to 1/25 sec
for(auto i=0;i<model.fTime.size();i++)
model.fTime[i] = double(i);
return 1;
}