example.cpp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695
  1. #include <igl/draw_skeleton_3d.h>
  2. #include <igl/draw_skeleton_vector_graphics.h>
  3. #include <igl/two_axis_valuator_fixed_up.h>
  4. #include <igl/readOBJ.h>
  5. #include <igl/readTGF.h>
  6. #include <igl/writeOBJ.h>
  7. #include <igl/writeOFF.h>
  8. #include <igl/readWRL.h>
  9. #include <igl/report_gl_error.h>
  10. #include <igl/triangulate.h>
  11. #include <igl/readOFF.h>
  12. #include <igl/readMESH.h>
  13. #include <igl/draw_mesh.h>
  14. #include <igl/draw_floor.h>
  15. #include <igl/pathinfo.h>
  16. #include <igl/list_to_matrix.h>
  17. #include <igl/quat_to_mat.h>
  18. #include <igl/per_face_normals.h>
  19. #include <igl/material_colors.h>
  20. #include <igl/trackball.h>
  21. #include <igl/snap_to_canonical_view_quat.h>
  22. #include <igl/snap_to_fixed_up.h>
  23. #include <igl/REDRUM.h>
  24. #include <igl/Camera.h>
  25. #include <igl/ReAntTweakBar.h>
  26. #include <igl/get_seconds.h>
  27. #include <igl/forward_kinematics.h>
  28. #include <igl/tetgen/mesh_with_skeleton.h>
  29. #include <igl/boundary_conditions.h>
  30. #include <igl/normalize_row_sums.h>
  31. #include <igl/lbs_matrix.h>
  32. #include <igl/bbw/bbw.h>
  33. #include <Eigen/Core>
  34. #include <Eigen/Geometry>
  35. #include <GLUT/glut.h>
  36. #include <string>
  37. #include <vector>
  38. #include <stack>
  39. #include <iostream>
  40. enum SkelStyleType
  41. {
  42. SKEL_STYLE_TYPE_3D = 0,
  43. SKEL_STYLE_TYPE_VECTOR_GRAPHICS = 1,
  44. NUM_SKEL_STYLE_TYPE = 2
  45. }skel_style;
  46. Eigen::MatrixXd V,N,C,W,M;
  47. Eigen::VectorXd Vmid,Vmin,Vmax;
  48. double bbd = 1.0;
  49. Eigen::MatrixXi F,BE;
  50. Eigen::VectorXi P;
  51. struct State
  52. {
  53. igl::Camera camera;
  54. } s;
  55. bool wireframe = false;
  56. bool skeleton_on_top = false;
  57. // See README for descriptions
  58. enum RotationType
  59. {
  60. ROTATION_TYPE_IGL_TRACKBALL = 0,
  61. ROTATION_TYPE_TWO_AXIS_VALUATOR_FIXED_UP = 1,
  62. NUM_ROTATION_TYPES = 2,
  63. } rotation_type;
  64. std::stack<State> undo_stack;
  65. std::stack<State> redo_stack;
  66. bool is_rotating = false;
  67. int down_x,down_y;
  68. igl::Camera down_camera;
  69. bool is_animating = false;
  70. double animation_start_time = 0;
  71. double ANIMATION_DURATION = 0.5;
  72. Eigen::Quaterniond animation_from_quat;
  73. Eigen::Quaterniond animation_to_quat;
  74. int width,height;
  75. Eigen::Vector4f light_pos(-0.1,-0.1,0.9,0);
  76. #define REBAR_NAME "temp.rbr"
  77. igl::ReTwBar rebar;
  78. void push_undo()
  79. {
  80. undo_stack.push(s);
  81. // Clear
  82. redo_stack = std::stack<State>();
  83. }
  84. // No-op setter, does nothing
  85. void TW_CALL no_op(const void * /*value*/, void * /*clientData*/)
  86. {
  87. }
  88. void TW_CALL set_rotation_type(const void * value, void * clientData)
  89. {
  90. using namespace Eigen;
  91. using namespace std;
  92. using namespace igl;
  93. const RotationType old_rotation_type = rotation_type;
  94. rotation_type = *(const RotationType *)(value);
  95. if(rotation_type == ROTATION_TYPE_TWO_AXIS_VALUATOR_FIXED_UP &&
  96. old_rotation_type != ROTATION_TYPE_TWO_AXIS_VALUATOR_FIXED_UP)
  97. {
  98. push_undo();
  99. animation_from_quat = s.camera.m_rotation_conj;
  100. snap_to_fixed_up(animation_from_quat,animation_to_quat);
  101. // start animation
  102. animation_start_time = get_seconds();
  103. is_animating = true;
  104. }
  105. }
  106. void TW_CALL get_rotation_type(void * value, void *clientData)
  107. {
  108. RotationType * rt = (RotationType *)(value);
  109. *rt = rotation_type;
  110. }
  111. void reshape(int width, int height)
  112. {
  113. ::width = width;
  114. ::height = height;
  115. glViewport(0,0,width,height);
  116. // Send the new window size to AntTweakBar
  117. TwWindowSize(width, height);
  118. s.camera.m_aspect = (double)width/(double)height;
  119. }
  120. void push_scene()
  121. {
  122. using namespace igl;
  123. using namespace std;
  124. glMatrixMode(GL_PROJECTION);
  125. glPushMatrix();
  126. glLoadIdentity();
  127. auto & camera = s.camera;
  128. gluPerspective(camera.m_angle,camera.m_aspect,camera.m_near,camera.m_far);
  129. glMatrixMode(GL_MODELVIEW);
  130. glPushMatrix();
  131. glLoadIdentity();
  132. gluLookAt(
  133. camera.eye()(0), camera.eye()(1), camera.eye()(2),
  134. camera.at()(0), camera.at()(1), camera.at()(2),
  135. camera.up()(0), camera.up()(1), camera.up()(2));
  136. }
  137. void push_object()
  138. {
  139. using namespace igl;
  140. glPushMatrix();
  141. glScaled(2./bbd,2./bbd,2./bbd);
  142. glTranslated(-Vmid(0),-Vmid(1),-Vmid(2));
  143. }
  144. void pop_object()
  145. {
  146. glPopMatrix();
  147. }
  148. void pop_scene()
  149. {
  150. glMatrixMode(GL_PROJECTION);
  151. glPopMatrix();
  152. glMatrixMode(GL_MODELVIEW);
  153. glPopMatrix();
  154. }
  155. // Set up double-sided lights
  156. void lights()
  157. {
  158. using namespace std;
  159. using namespace Eigen;
  160. glEnable(GL_LIGHTING);
  161. glLightModelf(GL_LIGHT_MODEL_TWO_SIDE,GL_TRUE);
  162. glEnable(GL_LIGHT0);
  163. glEnable(GL_LIGHT1);
  164. float WHITE[4] = {0.8,0.8,0.8,1.};
  165. float GREY[4] = {0.4,0.4,0.4,1.};
  166. float BLACK[4] = {0.,0.,0.,1.};
  167. Vector4f pos = light_pos;
  168. glLightfv(GL_LIGHT0,GL_AMBIENT,GREY);
  169. glLightfv(GL_LIGHT0,GL_DIFFUSE,WHITE);
  170. glLightfv(GL_LIGHT0,GL_SPECULAR,BLACK);
  171. glLightfv(GL_LIGHT0,GL_POSITION,pos.data());
  172. pos(0) *= -1;
  173. pos(1) *= -1;
  174. pos(2) *= -1;
  175. glLightfv(GL_LIGHT1,GL_AMBIENT,GREY);
  176. glLightfv(GL_LIGHT1,GL_DIFFUSE,WHITE);
  177. glLightfv(GL_LIGHT1,GL_SPECULAR,BLACK);
  178. glLightfv(GL_LIGHT1,GL_POSITION,pos.data());
  179. }
  180. void display()
  181. {
  182. using namespace igl;
  183. using namespace std;
  184. using namespace Eigen;
  185. const float back[4] = {30.0/255.0,30.0/255.0,50.0/255.0,0};
  186. glClearColor(back[0],back[1],back[2],0);
  187. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  188. if(is_animating)
  189. {
  190. double t = (get_seconds() - animation_start_time)/ANIMATION_DURATION;
  191. if(t > 1)
  192. {
  193. t = 1;
  194. is_animating = false;
  195. }
  196. Quaterniond q = animation_from_quat.slerp(t,animation_to_quat).normalized();
  197. auto & camera = s.camera;
  198. camera.orbit(q.conjugate());
  199. }
  200. glEnable(GL_DEPTH_TEST);
  201. glEnable(GL_NORMALIZE);
  202. lights();
  203. push_scene();
  204. // Draw a nice floor
  205. glEnable(GL_DEPTH_TEST);
  206. glPushMatrix();
  207. const double floor_offset =
  208. -2./bbd*(V.col(1).maxCoeff()-Vmid(1));
  209. glTranslated(0,floor_offset,0);
  210. const float GREY[4] = {0.5,0.5,0.6,1.0};
  211. const float DARK_GREY[4] = {0.2,0.2,0.3,1.0};
  212. glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
  213. draw_floor(GREY,DARK_GREY);
  214. glPopMatrix();
  215. push_object();
  216. // Set material properties
  217. glDisable(GL_COLOR_MATERIAL);
  218. glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, SILVER_AMBIENT);
  219. glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, SILVER_DIFFUSE );
  220. glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, SILVER_SPECULAR);
  221. glMaterialf (GL_FRONT_AND_BACK, GL_SHININESS, 128);
  222. vector<Quaterniond> dQ(BE.rows(),Quaterniond::Identity()),vQ;
  223. vector<Vector3d> vT;
  224. Matrix3d A = Matrix3d::Identity();
  225. for(int e = 0;e<BE.rows();e++)
  226. {
  227. dQ[e] = AngleAxisd((sin(get_seconds()+e))*0.06*PI,A.col(e%3));
  228. }
  229. forward_kinematics(C,BE,P,dQ,vQ,vT);
  230. const int dim = C.cols();
  231. MatrixXd T(BE.rows()*(dim+1),dim);
  232. for(int e = 0;e<BE.rows();e++)
  233. {
  234. Affine3d a = Affine3d::Identity();
  235. a.translate(vT[e]);
  236. a.rotate(vQ[e]);
  237. T.block(e*(dim+1),0,dim+1,dim) =
  238. a.matrix().transpose().block(0,0,dim+1,dim);
  239. }
  240. if(wireframe)
  241. {
  242. glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
  243. }
  244. glLineWidth(1.0);
  245. MatrixXd U = M*T;
  246. per_face_normals(U,F,N);
  247. draw_mesh(U,F,N);
  248. glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
  249. if(skeleton_on_top)
  250. {
  251. glDisable(GL_DEPTH_TEST);
  252. }
  253. switch(skel_style)
  254. {
  255. default:
  256. case SKEL_STYLE_TYPE_3D:
  257. draw_skeleton_3d(C,BE,T);
  258. break;
  259. case SKEL_STYLE_TYPE_VECTOR_GRAPHICS:
  260. draw_skeleton_vector_graphics(C,BE,T);
  261. break;
  262. }
  263. pop_object();
  264. pop_scene();
  265. report_gl_error();
  266. TwDraw();
  267. glutSwapBuffers();
  268. glutPostRedisplay();
  269. }
  270. void mouse_wheel(int wheel, int direction, int mouse_x, int mouse_y)
  271. {
  272. using namespace std;
  273. using namespace igl;
  274. using namespace Eigen;
  275. GLint viewport[4];
  276. glGetIntegerv(GL_VIEWPORT,viewport);
  277. if(wheel == 0 && TwMouseMotion(mouse_x, viewport[3] - mouse_y))
  278. {
  279. static double mouse_scroll_y = 0;
  280. const double delta_y = 0.125*direction;
  281. mouse_scroll_y += delta_y;
  282. TwMouseWheel(mouse_scroll_y);
  283. return;
  284. }
  285. push_undo();
  286. auto & camera = s.camera;
  287. if(wheel==0)
  288. {
  289. // factor of zoom change
  290. double s = (1.-0.01*direction);
  291. //// FOV zoom: just widen angle. This is hardly ever appropriate.
  292. //camera.m_angle *= s;
  293. //camera.m_angle = min(max(camera.m_angle,1),89);
  294. camera.push_away(s);
  295. }else
  296. {
  297. // Dolly zoom:
  298. camera.dolly_zoom((double)direction*1.0);
  299. }
  300. }
  301. void mouse(int glutButton, int glutState, int mouse_x, int mouse_y)
  302. {
  303. using namespace std;
  304. using namespace Eigen;
  305. using namespace igl;
  306. bool tw_using = TwEventMouseButtonGLUT(glutButton,glutState,mouse_x,mouse_y);
  307. switch(glutButton)
  308. {
  309. case GLUT_RIGHT_BUTTON:
  310. case GLUT_LEFT_BUTTON:
  311. {
  312. switch(glutState)
  313. {
  314. case 1:
  315. // up
  316. glutSetCursor(GLUT_CURSOR_INHERIT);
  317. is_rotating = false;
  318. break;
  319. case 0:
  320. if(!tw_using)
  321. {
  322. push_undo();
  323. glutSetCursor(GLUT_CURSOR_CYCLE);
  324. // collect information for trackball
  325. is_rotating = true;
  326. down_camera = s.camera;
  327. down_x = mouse_x;
  328. down_y = mouse_y;
  329. }
  330. break;
  331. }
  332. break;
  333. }
  334. // Scroll down
  335. case 3:
  336. {
  337. mouse_wheel(0,-1,mouse_x,mouse_y);
  338. break;
  339. }
  340. // Scroll up
  341. case 4:
  342. {
  343. mouse_wheel(0,1,mouse_x,mouse_y);
  344. break;
  345. }
  346. // Scroll left
  347. case 5:
  348. {
  349. mouse_wheel(1,-1,mouse_x,mouse_y);
  350. break;
  351. }
  352. // Scroll right
  353. case 6:
  354. {
  355. mouse_wheel(1,1,mouse_x,mouse_y);
  356. break;
  357. }
  358. }
  359. }
  360. void mouse_drag(int mouse_x, int mouse_y)
  361. {
  362. using namespace igl;
  363. using namespace std;
  364. using namespace Eigen;
  365. if(is_rotating)
  366. {
  367. glutSetCursor(GLUT_CURSOR_CYCLE);
  368. Quaterniond q;
  369. auto & camera = s.camera;
  370. switch(rotation_type)
  371. {
  372. case ROTATION_TYPE_IGL_TRACKBALL:
  373. {
  374. // Rotate according to trackball
  375. igl::trackball<double>(
  376. width,
  377. height,
  378. 2.0,
  379. down_camera.m_rotation_conj.coeffs().data(),
  380. down_x,
  381. down_y,
  382. mouse_x,
  383. mouse_y,
  384. q.coeffs().data());
  385. break;
  386. }
  387. case ROTATION_TYPE_TWO_AXIS_VALUATOR_FIXED_UP:
  388. {
  389. // Rotate according to two axis valuator with fixed up vector
  390. two_axis_valuator_fixed_up(
  391. width, height,
  392. 2.0,
  393. down_camera.m_rotation_conj,
  394. down_x, down_y, mouse_x, mouse_y,
  395. q);
  396. break;
  397. }
  398. default:
  399. break;
  400. }
  401. camera.orbit(q.conjugate());
  402. }
  403. }
  404. void init_relative()
  405. {
  406. using namespace Eigen;
  407. using namespace igl;
  408. per_face_normals(V,F,N);
  409. Vmax = V.colwise().maxCoeff();
  410. Vmin = V.colwise().minCoeff();
  411. Vmid = 0.5*(Vmax + Vmin);
  412. bbd = (Vmax-Vmin).norm();
  413. }
  414. void undo()
  415. {
  416. using namespace std;
  417. if(!undo_stack.empty())
  418. {
  419. redo_stack.push(s);
  420. s = undo_stack.top();
  421. undo_stack.pop();
  422. }
  423. }
  424. void redo()
  425. {
  426. using namespace std;
  427. if(!redo_stack.empty())
  428. {
  429. undo_stack.push(s);
  430. s = redo_stack.top();
  431. redo_stack.pop();
  432. }
  433. }
  434. void key(unsigned char key, int mouse_x, int mouse_y)
  435. {
  436. using namespace std;
  437. using namespace igl;
  438. using namespace Eigen;
  439. int mod = glutGetModifiers();
  440. const bool command_down = GLUT_ACTIVE_COMMAND & mod;
  441. const bool shift_down = GLUT_ACTIVE_SHIFT & mod;
  442. switch(key)
  443. {
  444. // ESC
  445. case char(27):
  446. rebar.save(REBAR_NAME);
  447. // ^C
  448. case char(3):
  449. exit(0);
  450. case 'z':
  451. case 'Z':
  452. if(command_down)
  453. {
  454. if(shift_down)
  455. {
  456. redo();
  457. }else
  458. {
  459. undo();
  460. }
  461. break;
  462. }else
  463. {
  464. push_undo();
  465. Quaterniond q;
  466. snap_to_canonical_view_quat(s.camera.m_rotation_conj,1.0,q);
  467. s.camera.orbit(q.conjugate());
  468. }
  469. default:
  470. if(!TwEventKeyboardGLUT(key,mouse_x,mouse_y))
  471. {
  472. cout<<"Unknown key command: "<<key<<" "<<int(key)<<endl;
  473. }
  474. }
  475. }
  476. bool init_weights(
  477. const Eigen::MatrixXd & V,
  478. const Eigen::MatrixXi & F,
  479. const Eigen::MatrixXd & C,
  480. const Eigen::MatrixXi & BE,
  481. Eigen::MatrixXd & W)
  482. {
  483. using namespace igl;
  484. using namespace Eigen;
  485. // Mesh with samples on skeleton
  486. // New vertices of tet mesh, V prefaces VV
  487. MatrixXd VV;
  488. MatrixXi TT,FF,CE;
  489. VectorXi P;
  490. if(!mesh_with_skeleton(V,F,C,P,BE,CE,10,VV,TT,FF))
  491. {
  492. return false;
  493. }
  494. // List of boundary indices (aka fixed value indices into VV)
  495. VectorXi b;
  496. // List of boundary conditions of each weight function
  497. MatrixXd bc;
  498. if(!boundary_conditions(VV,TT,C,P,BE,CE,b,bc))
  499. {
  500. return false;
  501. }
  502. // compute BBW
  503. // Default bbw data and flags
  504. BBWData bbw_data;
  505. bbw_data.active_set_params.max_iter = 4;
  506. // Weights matrix
  507. if(!bbw(VV,TT,b,bc,bbw_data,W))
  508. {
  509. return false;
  510. }
  511. // Normalize weights to sum to one
  512. normalize_row_sums(W,W);
  513. W.conservativeResize(V.rows(),W.cols());
  514. return true;
  515. }
  516. int main(int argc, char * argv[])
  517. {
  518. using namespace std;
  519. using namespace Eigen;
  520. using namespace igl;
  521. string filename = "../shared/cheburashka.off";
  522. string skel_filename = "../shared/cheburashka.tgf";
  523. if(argc < 3)
  524. {
  525. cerr<<"Usage:"<<endl<<" ./example input.obj"<<endl;
  526. cout<<endl<<"Opening default mesh..."<<endl;
  527. }else
  528. {
  529. // Read and prepare mesh
  530. filename = argv[1];
  531. skel_filename = argv[2];
  532. }
  533. // print key commands
  534. cout<<"[Click] and [drag] Rotate model using trackball."<<endl;
  535. cout<<"[Z,z] Snap rotation to canonical view."<<endl;
  536. cout<<"[⌘ Z] Undo."<<endl;
  537. cout<<"[⇧ ⌘ Z] Redo."<<endl;
  538. cout<<"[^C,ESC] Exit."<<endl;
  539. // dirname, basename, extension and filename
  540. string d,b,ext,f;
  541. pathinfo(filename,d,b,ext,f);
  542. // Convert extension to lower case
  543. transform(ext.begin(), ext.end(), ext.begin(), ::tolower);
  544. vector<vector<double > > vV,vN,vTC;
  545. vector<vector<int > > vF,vFTC,vFN;
  546. if(ext == "obj")
  547. {
  548. // Convert extension to lower case
  549. if(!igl::readOBJ(filename,vV,vTC,vN,vF,vFTC,vFN))
  550. {
  551. return 1;
  552. }
  553. }else if(ext == "off")
  554. {
  555. // Convert extension to lower case
  556. if(!igl::readOFF(filename,vV,vF,vN))
  557. {
  558. return 1;
  559. }
  560. }else if(ext == "wrl")
  561. {
  562. // Convert extension to lower case
  563. if(!igl::readWRL(filename,vV,vF))
  564. {
  565. return 1;
  566. }
  567. //}else
  568. //{
  569. // // Convert extension to lower case
  570. // MatrixXi T;
  571. // if(!igl::readMESH(filename,V,T,F))
  572. // {
  573. // return 1;
  574. // }
  575. // //if(F.size() > T.size() || F.size() == 0)
  576. // {
  577. // boundary_faces(T,F);
  578. // }
  579. }
  580. if(vV.size() > 0)
  581. {
  582. if(!list_to_matrix(vV,V))
  583. {
  584. return 1;
  585. }
  586. triangulate(vF,F);
  587. }
  588. readTGF(skel_filename,C,BE);
  589. // Recover parent indices because (C,BE) is crappy format for a tree.
  590. P.resize(BE.rows(),1);
  591. for(int e = 0;e<BE.rows();e++)
  592. {
  593. P(e) = -1;
  594. for(int f = 0;f<BE.rows();f++)
  595. {
  596. if(BE(e,0) == BE(f,1))
  597. {
  598. P(e) = f;
  599. }
  600. }
  601. }
  602. init_weights(V,F,C,BE,W);
  603. lbs_matrix(V,W,M);
  604. init_relative();
  605. // Init glut
  606. glutInit(&argc,argv);
  607. if( !TwInit(TW_OPENGL, NULL) )
  608. {
  609. // A fatal error occured
  610. fprintf(stderr, "AntTweakBar initialization failed: %s\n", TwGetLastError());
  611. return 1;
  612. }
  613. // Create a tweak bar
  614. rebar.TwNewBar("TweakBar");
  615. rebar.TwAddVarRW("camera_rotation", TW_TYPE_QUAT4D,
  616. s.camera.m_rotation_conj.coeffs().data(), "open readonly=true");
  617. TwType RotationTypeTW = ReTwDefineEnumFromString("RotationType",
  618. "igl_trackball,two-a...-fixed-up");
  619. rebar.TwAddVarCB( "rotation_type", RotationTypeTW,
  620. set_rotation_type,get_rotation_type,NULL,"keyIncr=] keyDecr=[");
  621. rebar.TwAddVarRW("skeleton_on_top", TW_TYPE_BOOLCPP,&skeleton_on_top,"key=O");
  622. rebar.TwAddVarRW("wireframe", TW_TYPE_BOOLCPP,&wireframe,"key=l");
  623. TwType SkelStyleTypeTW = ReTwDefineEnumFromString("SkelStyleType",
  624. "3d,vector graphics");
  625. rebar.TwAddVarRW("style",SkelStyleTypeTW,&skel_style,"key=s");
  626. rebar.load(REBAR_NAME);
  627. // Init antweakbar
  628. glutInitDisplayString( "rgba depth double samples>=8 ");
  629. glutInitWindowSize(glutGet(GLUT_SCREEN_WIDTH)/2.0,glutGet(GLUT_SCREEN_HEIGHT)/2.0);
  630. glutCreateWindow("upright");
  631. glutDisplayFunc(display);
  632. glutReshapeFunc(reshape);
  633. glutKeyboardFunc(key);
  634. glutMouseFunc(mouse);
  635. glutMotionFunc(mouse_drag);
  636. glutPassiveMotionFunc((GLUTmousemotionfun)TwEventMouseMotionGLUT);
  637. glutMainLoop();
  638. return 0;
  639. }