-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathmain.cpp
68 lines (46 loc) · 1.25 KB
/
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
64
65
66
67
68
#include <iostream>
#include <thread>
#include <assignment_setup.h>
#include <visualization.h>
//Simulation State
Eigen::VectorXd q;
Eigen::VectorXd qdot;
//simulation time and time step
double t = 0; //simulation time
double dt = 0.001; //time step
//simulation loop
bool simulating = true;
bool simulation_callback() {
while(simulating) {
simulate(q, qdot, dt, t);
t += dt;
}
return false;
}
bool draw_callback(igl::opengl::glfw::Viewer &viewer) {
draw(q, qdot, t);
return false;
}
void f(int &a, int b, int c) {
a = b + c;
}
void g(Eigen::Vector3d &a, Eigen::Vector3d b, Eigen::Vector3d c) {
a = b + c;
}
template<typename Ret, typename B, typename C>
void h(Ret &&a, B b, C c, void (*func)(Ret, B, C)) {
func(a,b,c);
}
int main(int argc, char **argv) {
std::cout<<"Start A4\n";
//assignment specific setup
assignment_setup(argc, argv, q, qdot);
//run simulation in seperate thread to avoid slowing down the UI
std::thread simulation_thread(simulation_callback);
simulation_thread.detach();
//setup libigl viewer and activate
Visualize::setup(q, qdot, true);
Visualize::viewer().callback_post_draw = &draw_callback;
Visualize::viewer().launch();
return 1;
}