#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef __APPLE__ #include #else #include #endif #ifndef GLUT_WHEEL_UP #define GLUT_WHEEL_UP 3 #endif #ifndef GLUT_WHEEL_DOWN #define GLUT_WHEEL_DOWN 4 #endif #ifndef GLUT_WHEEL_RIGHT #define GLUT_WHEEL_RIGHT 5 #endif #ifndef GLUT_WHEEL_LEFT #define GLUT_WHEEL_LEFT 6 #endif #ifndef GLUT_ACTIVE_COMMAND #define GLUT_ACTIVE_COMMAND 8 #endif #include #include #include #include enum RotationType { ROTATION_TYPE_IGL_TRACKBALL = 0, ROTATION_TYPE_TWO_AXIS_VALUATOR_FIXED_UP = 1, NUM_ROTATION_TYPES = 2, } rotation_type = ROTATION_TYPE_TWO_AXIS_VALUATOR_FIXED_UP; enum CenterType { CENTER_TYPE_ORBIT = 0, CENTER_TYPE_FPS = 1, NUM_CENTER_TYPES = 2, } center_type = CENTER_TYPE_ORBIT; int width,height; #define REBAR_NAME "temp.rbr" igl::anttweakbar::ReTwBar rebar; struct State { std::vector cameras; std::vector tex_ids; std::vector fbo_ids; std::vector dfbo_ids; State():cameras(4), tex_ids(cameras.size()), fbo_ids(cameras.size()), dfbo_ids(cameras.size()) {} } s; const Eigen::Vector4d back(1,1,1,1); std::stack undo_stack; bool is_rotating = false; igl::Camera down_camera; int down_x,down_y; std::stack redo_stack; Eigen::MatrixXd V,N; Eigen::MatrixXi F; Eigen::Vector4f light_pos(-0.1,-0.1,0.9,0); void push_undo() { undo_stack.push(s); // Clear redo_stack = std::stack(); } void undo() { if(!undo_stack.empty()) { redo_stack.push(s); s = undo_stack.top(); undo_stack.pop(); } } void redo() { if(!redo_stack.empty()) { undo_stack.push(s); s = redo_stack.top(); redo_stack.pop(); } } void print(const igl::Camera & camera) { using namespace std; cout<< "rotation: "<=8"); // Top right corner glutInitWindowSize(glutGet(GLUT_SCREEN_WIDTH)/2.0,glutGet(GLUT_SCREEN_HEIGHT)/2.0); glutInitWindowPosition(glutGet(GLUT_SCREEN_WIDTH)/2.0,-1); glutCreateWindow("camera"); glutDisplayFunc(display); glutReshapeFunc(reshape); glutKeyboardFunc(key); glutMouseFunc(mouse); glutPassiveMotionFunc((GLUTmousemotionfun)TwEventMouseMotionGLUT); glutMotionFunc(mouse_drag); glutMainLoop(); return 0; }