example.cpp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707
  1. // Small GLUT application to test different scene rotation paradigms
  2. //
  3. #include <igl/readOBJ.h>
  4. #include <igl/writeOBJ.h>
  5. #include <igl/writeOFF.h>
  6. #include <igl/readWRL.h>
  7. #include <igl/report_gl_error.h>
  8. #include <igl/triangulate.h>
  9. #include <igl/readOFF.h>
  10. #include <igl/readMESH.h>
  11. #include <igl/draw_mesh.h>
  12. #include <igl/draw_floor.h>
  13. #include <igl/pathinfo.h>
  14. #include <igl/list_to_matrix.h>
  15. #include <igl/quat_to_mat.h>
  16. #include <igl/per_face_normals.h>
  17. #include <igl/material_colors.h>
  18. #include <igl/trackball.h>
  19. #include <igl/snap_to_canonical_view_quat.h>
  20. #include <igl/REDRUM.h>
  21. #include <igl/Camera.h>
  22. #include <igl/ReAntTweakBar.h>
  23. #include <igl/get_seconds.h>
  24. #include <igl/jet.h>
  25. #include <igl/randperm.h>
  26. #include <igl/normalize_row_lengths.h>
  27. #include <igl/boost/manifold_patches.h>
  28. #include <igl/boost/components.h>
  29. #include <igl/boost/bfs_orient.h>
  30. #include <igl/orient_outward.h>
  31. #include <Eigen/Core>
  32. #include <Eigen/Geometry>
  33. #include <GLUT/glut.h>
  34. #include <string>
  35. #include <vector>
  36. #include <stack>
  37. #include <iostream>
  38. Eigen::MatrixXd V,C;
  39. Eigen::VectorXd Vmid,Vmin,Vmax;
  40. double bbd = 1.0;
  41. Eigen::MatrixXi F;
  42. struct State
  43. {
  44. igl::Camera camera;
  45. Eigen::MatrixXd N;
  46. } s;
  47. // See README for descriptions
  48. enum RotationType
  49. {
  50. ROTATION_TYPE_IGL_TRACKBALL = 0,
  51. ROTATION_TYPE_TWO_AXIS_VALUATOR_FIXED_UP = 1,
  52. NUM_ROTATION_TYPES = 2,
  53. } rotation_type;
  54. std::stack<State> undo_stack;
  55. std::stack<State> redo_stack;
  56. bool wireframe_visible = false;
  57. bool fill_visible = true;
  58. bool is_rotating = false;
  59. int down_x,down_y;
  60. igl::Camera down_camera;
  61. bool is_animating = false;
  62. double animation_start_time = 0;
  63. double ANIMATION_DURATION = 0.5;
  64. Eigen::Quaterniond animation_from_quat;
  65. Eigen::Quaterniond animation_to_quat;
  66. int width,height;
  67. Eigen::Vector4f light_pos(-0.1,-0.1,0.9,0);
  68. #define REBAR_NAME "temp.rbr"
  69. igl::ReTwBar rebar;
  70. void push_undo()
  71. {
  72. undo_stack.push(s);
  73. // Clear
  74. redo_stack = std::stack<State>();
  75. }
  76. void TW_CALL set_camera_rotation(const void * value, void *clientData)
  77. {
  78. using namespace std;
  79. // case current value to double
  80. const double * quat = (const double *)(value);
  81. std::copy(quat,quat+4,s.camera.rotation);
  82. }
  83. void TW_CALL set_rotation_type(const void * value, void * clientData)
  84. {
  85. using namespace Eigen;
  86. using namespace std;
  87. using namespace igl;
  88. const RotationType old_rotation_type = rotation_type;
  89. rotation_type = *(const RotationType *)(value);
  90. if(rotation_type == ROTATION_TYPE_TWO_AXIS_VALUATOR_FIXED_UP &&
  91. old_rotation_type != ROTATION_TYPE_TWO_AXIS_VALUATOR_FIXED_UP)
  92. {
  93. push_undo();
  94. copy(s.camera.rotation,s.camera.rotation+4,animation_from_quat.coeffs().data());
  95. const Vector3d up = animation_from_quat.matrix() * Vector3d(0,1,0);
  96. Vector3d proj_up(0,up(1),up(2));
  97. if(proj_up.norm() == 0)
  98. {
  99. proj_up = Vector3d(0,1,0);
  100. }
  101. proj_up.normalize();
  102. Quaterniond dq;
  103. dq = Quaterniond::FromTwoVectors(up,proj_up);
  104. animation_to_quat = dq * animation_from_quat;
  105. // start animation
  106. animation_start_time = get_seconds();
  107. is_animating = true;
  108. }
  109. }
  110. void TW_CALL get_rotation_type(void * value, void *clientData)
  111. {
  112. RotationType * rt = (RotationType *)(value);
  113. *rt = rotation_type;
  114. }
  115. void TW_CALL get_camera_rotation(void * value, void *clientData)
  116. {
  117. using namespace std;
  118. // case current value to double
  119. double * quat = (double *)(value);
  120. std::copy(s.camera.rotation,s.camera.rotation+4,quat);
  121. }
  122. void reshape(int width, int height)
  123. {
  124. ::width = width;
  125. ::height = height;
  126. glViewport(0,0,width,height);
  127. // Send the new window size to AntTweakBar
  128. TwWindowSize(width, height);
  129. }
  130. void push_scene()
  131. {
  132. using namespace igl;
  133. using namespace std;
  134. const double angle = s.camera.angle;
  135. glMatrixMode(GL_PROJECTION);
  136. glPushMatrix();
  137. glLoadIdentity();
  138. double zNear = 1e-2;
  139. double zFar = 100;
  140. double aspect = ((double)width)/((double)height);
  141. // Amount of scaling needed to "fix" perspective z-shift
  142. double z_fix = 1.0;
  143. // 5 is far enough to see unit "things" well
  144. const double camera_z = 2;
  145. // Test if should be using true orthographic projection
  146. if(angle == 0)
  147. {
  148. glOrtho(
  149. -0.5*camera_z*aspect,
  150. 0.5*camera_z*aspect,
  151. -0.5*camera_z,
  152. 0.5*camera_z,
  153. zNear,
  154. zFar);
  155. }else
  156. {
  157. // Make sure aspect is sane
  158. aspect = aspect < 0.01 ? 0.01 : aspect;
  159. gluPerspective(angle,aspect,zNear,zFar);
  160. z_fix = 2.*tan(angle/2./360.*2.*M_PI);
  161. }
  162. glMatrixMode(GL_MODELVIEW);
  163. glPushMatrix();
  164. glLoadIdentity();
  165. gluLookAt(0,0,camera_z,0,0,0,0,1,0);
  166. // Adjust scale to correct perspective
  167. glScaled(z_fix,z_fix,z_fix);
  168. // scale, pan
  169. glScaled( s.camera.zoom, s.camera.zoom, s.camera.zoom);
  170. double mat[4*4];
  171. quat_to_mat(s.camera.rotation,mat);
  172. glMultMatrixd(mat);
  173. }
  174. void push_object()
  175. {
  176. using namespace igl;
  177. glPushMatrix();
  178. glScaled(2./bbd,2./bbd,2./bbd);
  179. glTranslated(-Vmid(0),-Vmid(1),-Vmid(2));
  180. }
  181. void pop_object()
  182. {
  183. glPopMatrix();
  184. }
  185. void pop_scene()
  186. {
  187. glMatrixMode(GL_PROJECTION);
  188. glPopMatrix();
  189. glMatrixMode(GL_MODELVIEW);
  190. glPopMatrix();
  191. }
  192. // Set up double-sided lights
  193. void lights()
  194. {
  195. using namespace std;
  196. using namespace Eigen;
  197. glEnable(GL_LIGHTING);
  198. //glLightModelf(GL_LIGHT_MODEL_TWO_SIDE,GL_TRUE);
  199. glEnable(GL_LIGHT0);
  200. float WHITE[4] = {1,1,1,1.};
  201. float GREY[4] = {0.4,0.4,0.4,1.};
  202. float BLACK[4] = {0.,0.,0.,1.};
  203. float NEAR_BLACK[4] = {0.1,0.1,0.1,1.};
  204. Vector4f pos = light_pos;
  205. glLightfv(GL_LIGHT0,GL_AMBIENT,BLACK);
  206. glLightfv(GL_LIGHT0,GL_DIFFUSE,WHITE);
  207. glLightfv(GL_LIGHT0,GL_SPECULAR,BLACK);
  208. glLightfv(GL_LIGHT0,GL_POSITION,pos.data());
  209. //glEnable(GL_LIGHT1);
  210. //pos(0) *= -1;
  211. //pos(1) *= -1;
  212. //pos(2) *= -1;
  213. //glLightfv(GL_LIGHT1,GL_AMBIENT,BLACK);
  214. //glLightfv(GL_LIGHT1,GL_DIFFUSE,NEAR_BLACK);
  215. //glLightfv(GL_LIGHT1,GL_SPECULAR,BLACK);
  216. //glLightfv(GL_LIGHT1,GL_POSITION,pos.data());
  217. }
  218. void display()
  219. {
  220. using namespace igl;
  221. using namespace std;
  222. using namespace Eigen;
  223. glClearColor(1,1,1,0);
  224. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  225. if(is_animating)
  226. {
  227. double t = (get_seconds() - animation_start_time)/ANIMATION_DURATION;
  228. if(t > 1)
  229. {
  230. t = 1;
  231. is_animating = false;
  232. }
  233. Quaterniond q;
  234. q.coeffs() =
  235. animation_to_quat.coeffs()*t + animation_from_quat.coeffs()*(1.-t);
  236. q.normalize();
  237. copy(q.coeffs().data(),q.coeffs().data()+4,s.camera.rotation);
  238. }
  239. glEnable(GL_DEPTH_TEST);
  240. glEnable(GL_NORMALIZE);
  241. lights();
  242. push_scene();
  243. push_object();
  244. // Set material properties
  245. glEnable(GL_COLOR_MATERIAL);
  246. glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE);
  247. if(wireframe_visible)
  248. {
  249. glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
  250. if(fill_visible)
  251. {
  252. glColor3f(0,0,0);
  253. draw_mesh(V,F,s.N);
  254. }else
  255. {
  256. draw_mesh(V,F,s.N,C);
  257. }
  258. }
  259. glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
  260. if(fill_visible)
  261. {
  262. glEnable(GL_POLYGON_OFFSET_FILL); // Avoid Stitching!
  263. glPolygonOffset(1.0, 0);
  264. draw_mesh(V,F,s.N,C);
  265. }
  266. pop_object();
  267. // Draw a nice floor
  268. glPushMatrix();
  269. const double floor_offset =
  270. -2./bbd*(V.col(1).maxCoeff()-Vmid(1));
  271. glTranslated(0,floor_offset,0);
  272. const float GREY[4] = {0.5,0.5,0.6,1.0};
  273. const float DARK_GREY[4] = {0.2,0.2,0.3,1.0};
  274. draw_floor(GREY,DARK_GREY);
  275. glPopMatrix();
  276. pop_scene();
  277. report_gl_error();
  278. TwDraw();
  279. glutSwapBuffers();
  280. glutPostRedisplay();
  281. }
  282. void mouse_wheel(int wheel, int direction, int mouse_x, int mouse_y)
  283. {
  284. using namespace std;
  285. push_undo();
  286. if(wheel == 0)
  287. {
  288. static double mouse_scroll_y = 0;
  289. const double delta_y = 0.125*direction;
  290. mouse_scroll_y += delta_y;
  291. // absolute scale difference when changing zooms (+1)
  292. const double z_diff = 0.01;
  293. GLint viewport[4];
  294. glGetIntegerv(GL_VIEWPORT,viewport);
  295. if(TwMouseMotion(mouse_x, viewport[3] - mouse_y))
  296. {
  297. TwMouseWheel(mouse_scroll_y);
  298. }else
  299. {
  300. s.camera.zoom *= (1.0+double(direction)*z_diff);
  301. const double min_zoom = 0.01;
  302. const double max_zoom = 10.0;
  303. s.camera.zoom = min(max_zoom,max(min_zoom,s.camera.zoom));
  304. }
  305. }else
  306. {
  307. if(!is_rotating)
  308. {
  309. // Change viewing angle (reshape will take care of adjust zoom)
  310. const double a_diff = 1.0;
  311. s.camera.angle += double(direction)*a_diff;
  312. const double min_angle = 15.0;
  313. s.camera.angle =
  314. min(90.0,max(min_angle,s.camera.angle));
  315. }
  316. }
  317. }
  318. void mouse(int glutButton, int glutState, int mouse_x, int mouse_y)
  319. {
  320. using namespace std;
  321. using namespace Eigen;
  322. using namespace igl;
  323. bool tw_using = TwEventMouseButtonGLUT(glutButton,glutState,mouse_x,mouse_y);
  324. switch(glutButton)
  325. {
  326. case GLUT_RIGHT_BUTTON:
  327. case GLUT_LEFT_BUTTON:
  328. {
  329. switch(glutState)
  330. {
  331. case 1:
  332. // up
  333. glutSetCursor(GLUT_CURSOR_INHERIT);
  334. is_rotating = false;
  335. break;
  336. case 0:
  337. if(!tw_using)
  338. {
  339. push_undo();
  340. glutSetCursor(GLUT_CURSOR_CYCLE);
  341. // collect information for trackball
  342. is_rotating = true;
  343. down_camera = s.camera;
  344. down_x = mouse_x;
  345. down_y = mouse_y;
  346. }
  347. break;
  348. }
  349. break;
  350. // Scroll down
  351. case GLUT_WHEEL_DOWN:
  352. {
  353. mouse_wheel(0,-1,mouse_x,mouse_y);
  354. break;
  355. }
  356. // Scroll up
  357. case GLUT_WHEEL_UP:
  358. {
  359. mouse_wheel(0,1,mouse_x,mouse_y);
  360. break;
  361. }
  362. // Scroll left
  363. case GLUT_WHEEL_LEFT:
  364. {
  365. mouse_wheel(1,-1,mouse_x,mouse_y);
  366. break;
  367. }
  368. // Scroll right
  369. case GLUT_WHEEL_RIGHT:
  370. {
  371. mouse_wheel(1,1,mouse_x,mouse_y);
  372. break;
  373. }
  374. }
  375. }
  376. }
  377. void mouse_drag(int mouse_x, int mouse_y)
  378. {
  379. using namespace igl;
  380. using namespace std;
  381. using namespace Eigen;
  382. bool tw_using = TwMouseMotion(mouse_x,mouse_y);
  383. if(is_rotating)
  384. {
  385. glutSetCursor(GLUT_CURSOR_CYCLE);
  386. switch(rotation_type)
  387. {
  388. case ROTATION_TYPE_IGL_TRACKBALL:
  389. {
  390. // Rotate according to trackball
  391. igl::trackball<double>(
  392. width,
  393. height,
  394. 2.0,
  395. down_camera.rotation,
  396. down_x,
  397. down_y,
  398. mouse_x,
  399. mouse_y,
  400. s.camera.rotation);
  401. break;
  402. }
  403. case ROTATION_TYPE_TWO_AXIS_VALUATOR_FIXED_UP:
  404. {
  405. Quaterniond down_q;
  406. copy(down_camera.rotation,down_camera.rotation+4,down_q.coeffs().data());
  407. Vector3d axis(0,1,0);
  408. const double speed = 2.0;
  409. Quaterniond q;
  410. q = down_q *
  411. Quaterniond(
  412. AngleAxisd(
  413. M_PI*((double)(mouse_x-down_x))/(double)width*speed/2.0,
  414. axis.normalized()));
  415. q.normalize();
  416. {
  417. Vector3d axis(1,0,0);
  418. const double speed = 2.0;
  419. if(axis.norm() != 0)
  420. {
  421. q =
  422. Quaterniond(
  423. AngleAxisd(
  424. M_PI*(mouse_y-down_y)/(double)width*speed/2.0,
  425. axis.normalized())) * q;
  426. q.normalize();
  427. }
  428. }
  429. copy(q.coeffs().data(),q.coeffs().data()+4,s.camera.rotation);
  430. break;
  431. }
  432. default:
  433. break;
  434. }
  435. }
  436. }
  437. void init_relative()
  438. {
  439. using namespace Eigen;
  440. using namespace igl;
  441. per_face_normals(V,F,s.N);
  442. normalize_row_lengths(s.N,s.N);
  443. Vmax = V.colwise().maxCoeff();
  444. Vmin = V.colwise().minCoeff();
  445. Vmid = 0.5*(Vmax + Vmin);
  446. bbd = (Vmax-Vmin).norm();
  447. }
  448. void init_patches()
  449. {
  450. using namespace Eigen;
  451. using namespace igl;
  452. using namespace std;
  453. VectorXi CC;
  454. SparseMatrix<int> A;
  455. components(F,CC);
  456. cout<<"There are "<<CC.maxCoeff()+1<<" connected components."<<endl;
  457. //manifold_patches(F,CC,A);
  458. bfs_orient(F,F,CC);
  459. VectorXi I;
  460. orient_outward(V,F,CC,F,I);
  461. C.resize(CC.rows(),3);
  462. double num_cc = (double)CC.maxCoeff()+1.0;
  463. cout<<"There are "<<num_cc<<" 'manifold/orientable' patches."<<endl;
  464. randperm(num_cc,I);
  465. for(int f = 0;f<CC.rows();f++)
  466. {
  467. jet(
  468. (double)I(CC(f))/num_cc,
  469. C(f,0),
  470. C(f,1),
  471. C(f,2));
  472. }
  473. }
  474. void undo()
  475. {
  476. using namespace std;
  477. if(!undo_stack.empty())
  478. {
  479. redo_stack.push(s);
  480. s = undo_stack.top();
  481. undo_stack.pop();
  482. }
  483. }
  484. void redo()
  485. {
  486. using namespace std;
  487. if(!redo_stack.empty())
  488. {
  489. undo_stack.push(s);
  490. s = redo_stack.top();
  491. redo_stack.pop();
  492. }
  493. }
  494. void key(unsigned char key, int mouse_x, int mouse_y)
  495. {
  496. using namespace std;
  497. int mod = glutGetModifiers();
  498. switch(key)
  499. {
  500. // ESC
  501. case char(27):
  502. rebar.save(REBAR_NAME);
  503. // ^C
  504. case char(3):
  505. exit(0);
  506. case 'I':
  507. case 'i':
  508. {
  509. push_undo();
  510. s.N *= -1.0;
  511. break;
  512. }
  513. case 'z':
  514. case 'Z':
  515. if(mod & GLUT_ACTIVE_COMMAND)
  516. {
  517. if(mod & GLUT_ACTIVE_SHIFT)
  518. {
  519. redo();
  520. }else
  521. {
  522. undo();
  523. }
  524. break;
  525. }else
  526. {
  527. push_undo();
  528. igl::snap_to_canonical_view_quat<double>(
  529. s.camera.rotation,
  530. 1.0,
  531. s.camera.rotation);
  532. break;
  533. }
  534. default:
  535. if(!TwEventKeyboardGLUT(key,mouse_x,mouse_y))
  536. {
  537. cout<<"Unknown key command: "<<key<<" "<<int(key)<<endl;
  538. }
  539. }
  540. }
  541. int main(int argc, char * argv[])
  542. {
  543. using namespace std;
  544. using namespace Eigen;
  545. using namespace igl;
  546. string filename = "../shared/truck.obj";
  547. if(argc < 2)
  548. {
  549. cerr<<"Usage:"<<endl<<" ./example input.obj"<<endl;
  550. cout<<endl<<"Opening default mesh..."<<endl;
  551. }else
  552. {
  553. // Read and prepare mesh
  554. filename = argv[1];
  555. }
  556. // print key commands
  557. cout<<"[Click] and [drag] Rotate model using trackball."<<endl;
  558. cout<<"[Z,z] Snap rotation to canonical view."<<endl;
  559. cout<<"[⌘ Z] Undo."<<endl;
  560. cout<<"[⇧ ⌘ Z] Redo."<<endl;
  561. cout<<"[^C,ESC] Exit."<<endl;
  562. // dirname, basename, extension and filename
  563. string d,b,ext,f;
  564. pathinfo(filename,d,b,ext,f);
  565. // Convert extension to lower case
  566. transform(ext.begin(), ext.end(), ext.begin(), ::tolower);
  567. vector<vector<double > > vV,vN,vTC;
  568. vector<vector<int > > vF,vFTC,vFN;
  569. if(ext == "obj")
  570. {
  571. // Convert extension to lower case
  572. if(!igl::readOBJ(filename,vV,vTC,vN,vF,vFTC,vFN))
  573. {
  574. return 1;
  575. }
  576. }else if(ext == "off")
  577. {
  578. // Convert extension to lower case
  579. if(!igl::readOFF(filename,vV,vF,vN))
  580. {
  581. return 1;
  582. }
  583. }else if(ext == "wrl")
  584. {
  585. // Convert extension to lower case
  586. if(!igl::readWRL(filename,vV,vF))
  587. {
  588. return 1;
  589. }
  590. //}else
  591. //{
  592. // // Convert extension to lower case
  593. // MatrixXi T;
  594. // if(!igl::readMESH(filename,V,T,F))
  595. // {
  596. // return 1;
  597. // }
  598. // //if(F.size() > T.size() || F.size() == 0)
  599. // {
  600. // boundary_faces(T,F);
  601. // }
  602. }
  603. if(vV.size() > 0)
  604. {
  605. if(!list_to_matrix(vV,V))
  606. {
  607. return 1;
  608. }
  609. triangulate(vF,F);
  610. }
  611. init_patches();
  612. init_relative();
  613. // Init glut
  614. glutInit(&argc,argv);
  615. if( !TwInit(TW_OPENGL, NULL) )
  616. {
  617. // A fatal error occured
  618. fprintf(stderr, "AntTweakBar initialization failed: %s\n", TwGetLastError());
  619. return 1;
  620. }
  621. // Create a tweak bar
  622. rebar.TwNewBar("TweakBar");
  623. rebar.TwAddVarCB("camera_rotation", TW_TYPE_QUAT4D, set_camera_rotation,get_camera_rotation, NULL, "open readonly=true");
  624. TwEnumVal RotationTypesEV[NUM_ROTATION_TYPES] =
  625. {
  626. {ROTATION_TYPE_IGL_TRACKBALL,"igl trackball"},
  627. {ROTATION_TYPE_TWO_AXIS_VALUATOR_FIXED_UP,"two axis fixed up"}
  628. };
  629. TwType RotationTypeTW =
  630. ReTwDefineEnum(
  631. "RotationType",
  632. RotationTypesEV,
  633. NUM_ROTATION_TYPES);
  634. rebar.TwAddVarCB( "rotation_type", RotationTypeTW,
  635. set_rotation_type,get_rotation_type,NULL,"keyIncr=] keyDecr=[");
  636. rebar.TwAddVarRW("wireframe_visible",TW_TYPE_BOOLCPP,&wireframe_visible,"key=l");
  637. rebar.TwAddVarRW("fill_visible",TW_TYPE_BOOLCPP,&fill_visible,"key=f");
  638. rebar.load(REBAR_NAME);
  639. animation_from_quat = Quaterniond(1,0,0,0);
  640. copy(s.camera.rotation,s.camera.rotation+4,animation_to_quat.coeffs().data());
  641. animation_start_time = get_seconds();
  642. // Init antweakbar
  643. glutInitDisplayString( "rgba depth double samples>=8 ");
  644. glutInitWindowSize(glutGet(GLUT_SCREEN_WIDTH)/2.0,glutGet(GLUT_SCREEN_HEIGHT)/2.0);
  645. glutCreateWindow("patches");
  646. glutDisplayFunc(display);
  647. glutReshapeFunc(reshape);
  648. glutKeyboardFunc(key);
  649. glutMouseFunc(mouse);
  650. glutMotionFunc(mouse_drag);
  651. glutPassiveMotionFunc((GLUTmousemotionfun)TwEventMouseMotionGLUT);
  652. glutMainLoop();
  653. return 0;
  654. }