-
Notifications
You must be signed in to change notification settings - Fork 0
/
arap_main.cpp
63 lines (49 loc) · 1.37 KB
/
arap_main.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
#include <igl/opengl/glfw/Viewer.h>
#include <igl/writeOBJ.h>
#include <igl/barycenter.h>
#include <igl/readOFF.h>
#include <igl/readMESH.h>
#include <igl/readOBJ.h>
#include <igl/slice.h>
#include <json.hpp>
#include "newmark.h"
#include "euler.h"
using json = nlohmann::json;
using namespace Eigen;
using namespace std;
json j_input;
int main(int argc, char *argv[])
{
std::cout<<"3d ARAP\n";
json j_config_parameters;
std::ifstream i("../input/input.json");
i >> j_input;
double youngs_mod = j_input["youngs"];
double poisson = j_input["poissons"];
double gravity = j_input["gravity"];
MatrixXd V;
MatrixXi T;
MatrixXi F;
igl::readMESH(j_input["mesh_file"], V, T, F);
Mesh* SM = new Mesh(T, V, youngs_mod, poisson, gravity);
SM->initializeMesh();
// SM->initializeRSCoords();
std::cout<< "STEPPING"<<std::endl;
igl::opengl::glfw::Viewer viewer;
viewer.callback_pre_draw = [&](igl::opengl::glfw::Viewer & viewer)
{
if(viewer.core.is_animating)
{
MatrixXd newV = SM->getCurrentVerts();
viewer.data().set_vertices(newV);
}
return false;
};
viewer.data().set_mesh(V,F);
viewer.data().show_lines = true;
viewer.data().invert_normals = true;
viewer.core.is_animating = false;
viewer.data().face_based = true;
viewer.launch();
return EXIT_SUCCESS;
}