home *** CD-ROM | disk | FTP | other *** search
/ ftp.hitl.washington.edu / ftp.hitl.washington.edu.tar / ftp.hitl.washington.edu / pub / people / habib / kodak / interfaceHenry.h < prev    next >
C/C++ Source or Header  |  2000-04-18  |  97KB  |  2,791 lines

  1. #include <mmsystem.h>  // WinUnix
  2. #define DimX 400
  3. #define DimY 150
  4. #define DimZ 400
  5. struct Virtual_Espace{
  6.     char  FULL;
  7.     //struct point *N;
  8. } ;
  9. void 
  10. rectangle(int x1,int y1,int x2,int y2, float r, float g, float b, rect *re) //frectangle
  11. // x1 , y1 are the upper left  corner
  12. // x2 , y2 are the low   right corner
  13. {
  14.          glBegin(GL_POLYGON);
  15.          glColor3f (r,g,b);
  16.          glVertex2f(x1 , y1 );
  17.          glVertex2f(x1 , y2 );
  18.          glVertex2f(x2 , y2 );
  19.          glVertex2f(x2 , y1 );
  20.          glEnd();
  21.          re->xmin = x1;
  22.          re->xmax = x2;
  23.          re->ymin = y1;
  24.          re->ymax = y2;
  25. }
  26. void
  27. scrollbar(int x,int y,int w,scr_bar *s) //fscrollbar
  28. // (x,y) is the upper left corner
  29. // w is the width of the scroll bar.
  30. // The scrollbar is 88 pixel long
  31.  
  32. {
  33.          // Create a srall bar.
  34.  
  35.          // Drawing the green squar up
  36.          glBegin(GL_POLYGON);
  37.          glColor3f (0,1,0);
  38.          glVertex2f(x  ,y   );
  39.          glVertex2f(x  ,y+10);
  40.          glVertex2f(x+w,y+10);
  41.          glVertex2f(x+w,y   );
  42.          glEnd();
  43.          s->x_g_min = x;
  44.          s->x_g_max = x+w;
  45.          s->y_g_min = y;
  46.          s->y_g_max = y+10;
  47.  
  48.          // Drawing the red squar down
  49.          glBegin(GL_POLYGON);
  50.          glColor3f (1,0,0);
  51.          glVertex2f(x  ,y+78);
  52.          glVertex2f(x  ,y+88);
  53.          glVertex2f(x+w,y+88);
  54.          glVertex2f(x+w,y+78);
  55.          glEnd();
  56.          s->x_r_min = x;
  57.          s->x_r_max = x+w;
  58.          s->y_r_min = y+78;
  59.          s->y_r_max = y+88;
  60.  
  61.          // Drawing upper triangle
  62.          glBegin (GL_TRIANGLES);
  63.           glColor3f (0.7f,0.6f,0.5f);
  64.          glVertex2f(x+w/2, y+12);
  65.          glVertex2f(x    , y+22);
  66.          glVertex2f(x+w  , y+22);
  67.          glEnd();
  68.          s->x_ht_min = x;
  69.          s->x_ht_max = x+w;
  70.          s->y_ht_min = y+12;
  71.          s->y_ht_max = y+22;
  72.  
  73.          // Drawing lower triangle
  74.          glBegin (GL_TRIANGLES);
  75.           glColor3f (0.7f,0.6f,0.5f);
  76.          glVertex2f(x    ,y+66);
  77.          glVertex2f(x+w/2,y+76);
  78.          glVertex2f(x+w  ,y+66);
  79.          glEnd();
  80.          s->x_lt_min = x;
  81.          s->x_lt_max = x+w;
  82.          s->y_lt_min = y+66;
  83.          s->y_lt_max = y+76;
  84.  
  85.          // Drawing the middle rectangle.
  86.          glBegin (GL_POLYGON);
  87.          glColor3f (0.7f,0.9f,0.6f);
  88.          glVertex2f(x   ,y+24   );
  89.          glVertex2f(x   ,y+24+40);
  90.          glVertex2f(x+w ,y+24+40);
  91.          glVertex2f(x+w ,y+24   );
  92.          glEnd();
  93.          s->x_m_min = x;
  94.          s->x_m_max = x+w;
  95.          s->y_m_min = y+24;
  96.          s->y_m_max = y+64;
  97.  
  98. }
  99.  
  100.  
  101. void
  102. draw_carre1() //fdraw_carre1
  103. {
  104.          glEnable (GL_BLEND);
  105.          glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  106.          // glDepthMask(GL_FALSE);
  107.          // glMateriali (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE,1);
  108.          double z = zmin+carre1;
  109.          if (expand_carre1){
  110.                     glBegin (GL_POLYGON);
  111.                     glColor4f (0.0f, 0.0f, 0.9f,carre1_trans);
  112.                     // glShadeModel (GL_FLAT);
  113.                     glVertex3f (xmin_e,ymin_e,z);
  114.                     glVertex3f (xmax_e,ymin_e,z);
  115.                     glVertex3f (xmax_e,ymax_e,z);
  116.                     glVertex3f (xmin_e,ymax_e,z);
  117.                     glEnd();
  118.  
  119.                     glBegin (GL_POLYGON);
  120.                     glColor4f (0.0f, 0.0f, 0.9f,carre1_trans);
  121.                     glVertex3f (xmin_e,ymax_e,z);
  122.                     glVertex3f (xmax_e,ymax_e,z);
  123.                     glVertex3f (xmax_e,ymin_e,z);
  124.                     glVertex3f (xmin_e,ymin_e,z);
  125.                     glEnd();
  126.          }
  127.          else{
  128.                     glBegin (GL_POLYGON);
  129.                     glColor4f (0, 0, 0.9f,carre1_trans);
  130.                     glVertex3f (xmin,ymin,z);
  131.                     glVertex3f (xmax,ymin,z);
  132.                     glVertex3f (xmax,ymax,z);
  133.                     glVertex3f (xmin,ymax,z);
  134.                     glEnd();
  135.  
  136.                     glBegin (GL_POLYGON);
  137.                     glColor4f (0, 0, 0.9f,carre1_trans);
  138.                     glVertex3f (xmin,ymax,z);
  139.                     glVertex3f (xmax,ymax,z);
  140.                     glVertex3f (xmax,ymin,z);
  141.                     glVertex3f (xmin,ymin,z);
  142.                     glEnd();
  143.          }
  144.          glDisable(GL_BLEND);
  145.          // glDepthMask(GL_TRUE);
  146. }
  147. void
  148. draw_carre2() //fdraw_carre2
  149. {
  150.          glEnable (GL_BLEND);
  151.          glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  152.          // glDepthMask(GL_FALSE);
  153.          double y = ymin+carre2;
  154.          if (expand_carre2){
  155.                     glBegin (GL_POLYGON);
  156.                     glColor4f (0, 0.9f, 0.0f,carre2_trans);
  157.                     glVertex3f (xmin_e,y,zmin_e);
  158.                     glVertex3f (xmax_e,y,zmin_e);
  159.                     glVertex3f (xmax_e,y,zmax_e);
  160.                     glVertex3f (xmin_e,y,zmax_e);
  161.                     glEnd();
  162.  
  163.                     glBegin (GL_POLYGON);
  164.                     glColor4f (0, 0.9f, 0.0f,carre1_trans);
  165.                     glVertex3f (xmin_e,y,zmax_e);
  166.                     glVertex3f (xmax_e,y,zmax_e);
  167.                     glVertex3f (xmax_e,y,zmin_e);
  168.                     glVertex3f (xmin_e,y,zmin_e);
  169.                     glEnd();
  170.          }
  171.          else{
  172.                     glBegin (GL_POLYGON);
  173.                     glColor4f (0, 0.9f, 0.0f,carre1_trans);
  174.                     glVertex3f (xmin ,y,zmin );
  175.                     glVertex3f (xmax ,y,zmin );
  176.                     glVertex3f (xmax ,y,zmax );
  177.                     glVertex3f (xmin ,y,zmax );
  178.                     glEnd();
  179.  
  180.                     glBegin (GL_POLYGON);
  181.                     glColor4f (0, 0.9f, 0.0f,carre1_trans);
  182.                     glVertex3f (xmin ,y,zmax );
  183.                     glVertex3f (xmax ,y,zmax );
  184.                     glVertex3f (xmax ,y,zmin );
  185.                     glVertex3f (xmin ,y,zmin );
  186.                     glEnd();
  187.          }
  188.          glDisable(GL_BLEND);
  189.          // glDepthMask(GL_TRUE);
  190. }
  191.  
  192. void
  193. draw_carre3() //fdraw_carre3
  194. {
  195.          glEnable (GL_BLEND);
  196.          glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  197.          // glDepthMask(GL_FALSE);
  198.          double x = xmin+carre3;
  199.          if (expand_carre3){
  200.                     glBegin (GL_POLYGON);
  201.                     glColor4f (0.9f, 0.0f, 0.0f,carre3_trans);
  202.                     glVertex3f (x,ymin_e,zmax_e);
  203.                     glVertex3f (x,ymin_e,zmin_e);
  204.                     glVertex3f (x,ymax_e,zmin_e);
  205.                     glVertex3f (x,ymax_e,zmax_e);
  206.                     glEnd();
  207.  
  208.                     glBegin (GL_POLYGON);
  209.                     glColor4f (0.9f, 0, 0.0f,carre3_trans);
  210.                     glVertex3f (x,ymax_e,zmax_e);
  211.                     glVertex3f (x,ymax_e,zmin_e);
  212.                     glVertex3f (x,ymin_e,zmin_e);
  213.                     glVertex3f (x,ymin_e,zmax_e);
  214.                     glEnd();
  215.          }
  216.          else{
  217.                     glBegin (GL_POLYGON);
  218.                     glColor4f (0.9f, 0.0f, 0.0f,carre3_trans);
  219.                     glVertex3f (x,ymin,zmax);
  220.                     glVertex3f (x,ymin,zmin);
  221.                     glVertex3f (x,ymax,zmin);
  222.                     glVertex3f (x,ymax,zmax);
  223.                     glEnd();
  224.  
  225.                     glBegin (GL_POLYGON);
  226.                     glColor4f (0.9f, 0, 0.0f,carre3_trans);
  227.                     glVertex3f (x,ymax,zmax);
  228.                     glVertex3f (x,ymax,zmin);
  229.                     glVertex3f (x,ymin,zmin);
  230.                     glVertex3f (x,ymin,zmax);
  231.                     glEnd();
  232.          }
  233.          glDisable(GL_BLEND);
  234.          // glDepthMask(GL_TRUE);
  235. }
  236.  
  237. inline void
  238. draw_commande_de_bord() //fdraw_commande_de
  239. // Draws the commande de bord Glut Menu.
  240. {
  241.          // Draw The Vertical Control Menu.
  242.          glDisable (GL_LIGHTING);
  243.          // Set View Port.
  244.          glViewport (0,0,CDW,H);
  245.  
  246.          // Set Projection Matrix
  247.          glMatrixMode(GL_PROJECTION);/* set up projection transform */
  248.          glLoadIdentity();
  249.          glOrtho (0,CDW, H,0, -1,1);
  250.          
  251.          // Set ModelView Matrix.
  252.          glMatrixMode (GL_MODELVIEW);
  253.          glLoadIdentity();
  254.          
  255.          // Draw Menu.
  256.          glBegin (GL_POLYGON);
  257.          glColor3f (0.25f,0.2f,0.1f);
  258.          glVertex3f (0  ,H,-0.5);
  259.          glColor3f (0.25f,0.2f,0.1f);
  260.          glVertex3f (CDW,H,-0.5);
  261.          glColor3f (0.3f,0.1f,0.15f);
  262.          glVertex3f (CDW,  0.0f,-0.5f);
  263.          glColor3f (0.3f, 0.1f,0.15f);
  264.          glVertex3f(0.0f, 0.0f,-0.5f);
  265.          glEnd(); 
  266.  
  267.          // writing on the window characters Blue -->X...
  268.          int i;
  269.          glColor3f (0.75f,0.75f,1.0f);
  270.          glRasterPos3f(0,10,0.5f);
  271.          int len;
  272.          len = (int) strlen(string3);
  273.          for (i = 0; i < len; i++) 
  274.                     glutBitmapCharacter(GLUT_BITMAP_8_BY_13, string3[i]);
  275.          
  276.          glColor3f (0.75f,1.0f,0.75f);
  277.          glRasterPos3f(0,20,0.5f);
  278.          len = (int) strlen(string2);
  279.          for (i = 0; i < len; i++) 
  280.                     glutBitmapCharacter(GLUT_BITMAP_8_BY_13, string2[i]);
  281.          
  282.          glColor3f (1.0f,0.75f,0.75f);
  283.          glRasterPos3f(0,30,0.5);
  284.          len = (int) strlen(string1);
  285.          for (i = 0; i < len; i++) 
  286.                     glutBitmapCharacter(GLUT_BITMAP_8_BY_13, string1[i]);
  287.          
  288.  
  289.          // Drawing the scrollbar for carre1.
  290.          scrollbar (10,40,20,m1_expand);
  291.          scrollbar (40,40,20,top_expand);
  292.          scrollbar (70,40,20,sb_c3);
  293.  
  294.          // Drawing rectanle Stereo_Zoom
  295.          rectangle (10,130,90,143,0.9f,0.3f,0.7f,stereo_zoom_rect);
  296.          glColor3f (0,0,0);
  297.          glRasterPos3f(10,142,0.5);
  298.          len = (int) strlen(string4);
  299.          for (i = 0; i < len; i++) 
  300.                     glutBitmapCharacter(GLUT_BITMAP_8_BY_13, string4[i]);
  301.  
  302.          // Drawing rectanle Scaling
  303.          rectangle (10,145,90,158,0.7f,0.9f,0.4f,scaling_rect);
  304.          glColor3f (0,0,0);
  305.          glRasterPos3f(10,157,0.5);
  306.          len = (int) strlen(string5);
  307.          for (i = 0; i < len; i++) 
  308.                     glutBitmapCharacter(GLUT_BITMAP_8_BY_13, string5[i]);
  309.          
  310.          // Drawing rectanle Animation.
  311.          rectangle (10,160,90,173,0.7f,0.9f,0.4f,animation_rect);
  312.          glColor3f (0,0,0);
  313.          glRasterPos3f(10,172,0.5);
  314.          len = (int) strlen(string6);
  315.          for (i = 0; i < len; i++) 
  316.                     glutBitmapCharacter(GLUT_BITMAP_8_BY_13, string6[i]);
  317.  
  318.          // Drawing rectanle Vertical Adjustment..
  319.          rectangle (10,175,90,188,0.9f,0.9f,0.4f,vertical_adj_rect);
  320.          glColor3f (0,0,0);
  321.          glRasterPos3f(10,187,0.5);
  322.          len = (int) strlen(string7);
  323.          for (i = 0; i < len; i++) 
  324.                     glutBitmapCharacter(GLUT_BITMAP_8_BY_13, string7[i]);
  325.  
  326.     
  327.          // Drawing rectanle Color mapping...
  328.          rectangle (10,191,90,204,0.9f,0.3f,0.4f,color_rect);
  329.          glColor3f (0.0f,0.0f,0.0f);
  330.          glRasterPos3f(10,203,0.5f);
  331.          len = (int) strlen(string8);
  332.          for (i = 0; i < len; i++) 
  333.                     glutBitmapCharacter(GLUT_BITMAP_8_BY_13, string8[i]);
  334.  
  335.          // Drawing rectanle change pt_size...
  336.          rectangle (10,207,90,220,0.5f,0.3f,0.8f,pt_size_rect);
  337.          glColor3f (0,0,0);
  338.          glRasterPos3f(10,219,0.5f);
  339.          len = (int) strlen(string9);
  340.          for (i = 0; i < len; i++) 
  341.                     glutBitmapCharacter(GLUT_BITMAP_8_BY_13, string9[i]);
  342.  
  343.          // Drawing rectanle Mirror translate
  344.          rectangle (10,223,90,236,0.1f,0.6f,0.5f,mirror_translate_rect);
  345.          glColor3f (0,0,0);
  346.          glRasterPos3f(10,236,0.5);
  347.          len = (int) strlen(string10);
  348.          for (i = 0; i < len; i++) 
  349.                     glutBitmapCharacter(GLUT_BITMAP_8_BY_13, string10[i]);
  350.  
  351.          // Drawing rectanle Mirror translate
  352.          rectangle (10,239,90,252,0.3f,0.1f,0.9f,mirror_translateZ_rect);
  353.          glColor3f (0,0,0);
  354.          glRasterPos3f(10,252,0.5);
  355.          len = (int) strlen(string11);
  356.          for (i = 0; i < len; i++) 
  357.                     glutBitmapCharacter(GLUT_BITMAP_8_BY_13, string11[i]);
  358.          
  359.          // Drawing rectanle top_view_comm
  360.          rectangle (10,255,90,268,0.6f,0.0f,0.0f,top_view_comm);
  361.          glColor3f (0.0f,0.0f,0.6f);
  362.          glRasterPos3f(10,268,0.5);
  363.          len = (int) strlen(string11);
  364.          for (i = 0; i < len; i++) 
  365.                     glutBitmapCharacter(GLUT_BITMAP_8_BY_13, string12[i]);
  366.  
  367.          // Drawing rectanle big_win_comm
  368.          rectangle (10,271,90,284,0.6f,0.0f,0.2f,big_win_comm);
  369.          glColor3f (0,0.5,0);
  370.          glRasterPos3f(10,284,0.5);
  371.          len = (int) strlen(string13);
  372.          for (i = 0; i < len; i++) 
  373.                     glutBitmapCharacter(GLUT_BITMAP_8_BY_13, string13[i]);
  374.  
  375.          if (!FLAG_TOGGLE_MENU1) glDisable(GL_LIGHTING);
  376.  
  377.          // Drawing rectanle Mirror rotate
  378.          rectangle (10,287,90,300,0.5,0.5,0.0,mirror_rotate_rect);
  379.          glColor3f (1.0,0,0);
  380.          glRasterPos3f(10,300,0.5);
  381.          len = (int) strlen(string14);
  382.          for (i = 0; i < len; i++) 
  383.                     glutBitmapCharacter(GLUT_BITMAP_8_BY_13, string14[i]);
  384.  
  385.          // Drawing rectanle Zoom y.
  386.          rectangle (10,303,90,316,0.2f,0.5f,0.2f,zoom_y_rect);
  387.          glColor3f (1.0,0,1.0);
  388.          glRasterPos3f(10,316,0.5);
  389.          len = (int) strlen(string15);
  390.          for (i = 0; i < len; i++) 
  391.                     glutBitmapCharacter(GLUT_BITMAP_8_BY_13, string15[i]);
  392.  
  393.          char string_zoomx[10];
  394.          char buffer[10];
  395.          strcpy (string_zoomx,"X:");
  396.          strcat (string_zoomx,itoa( LEFT, buffer, 10 )); //WinUnix just comment this for now...
  397.          glColor3f (0.75f,0.75f,0.8f);
  398.          glRasterPos3f(0,400,0.5f);
  399.          len = (int) strlen(string_zoomx);
  400.          for (i = 0; i < len; i++) 
  401.                     glutBitmapCharacter(GLUT_BITMAP_8_BY_13, string_zoomx[i]);
  402.  
  403.  
  404.          if (!FLAG_TOGGLE_MENU1) glDisable(GL_LIGHTING);
  405.  
  406.  
  407. }
  408. inline void 
  409. // looks where you did hit the mous on the commande_de_bord and sets accordingly the flag.
  410. commande_de_bord(int x, int y) //fcommand_de_bord
  411. {
  412.    void redraw();
  413.          void animation_window2();
  414.  
  415.          // if you are in the green square one, expand mirror1 in the x direction.
  416.          if (x>m1_expand->x_g_min  && x<m1_expand->x_g_max // if you are in the green square.
  417.                  && y>m1_expand->y_g_min && y<m1_expand->y_g_max){
  418.                     flag_motion_command = flag_expand_mirror1_x;
  419.          }
  420.  
  421.          // if you are in the red square one, expand mirror1 in the y direction.
  422.          if (x>m1_expand->x_r_min && x<m1_expand->x_r_max 
  423.                  && y>m1_expand->y_r_min && y<m1_expand->y_r_max) 
  424.                     flag_motion_command = flag_expand_mirror1_y;
  425.  
  426.          // if you are in the middle square one, expand mirror1 in the y direction.
  427.          if (x>m1_expand->x_m_min && x<m1_expand->x_m_max 
  428.                  && y>m1_expand->y_m_min && y<m1_expand->y_m_max) 
  429.                     flag_motion_command = flag_expand_mirror1_xy;
  430.  
  431.          // if you are in the middle square one, expand mirror1 in the y direction.
  432.          if (x>top_expand->x_m_min && x<top_expand->x_m_max 
  433.                  && y>top_expand->y_m_min && y<top_expand->y_m_max) 
  434.                     flag_motion_command = flag_top_expand_xy;
  435.  
  436. /*         // if... draw the transparent carre2.
  437.          if (x>sb_c2->x_g_min  && x<sb_c2->x_g_max 
  438.                  && y>sb_c2->y_g_min && y<sb_c2->y_g_max){
  439.                     DRAW_CARRE2 = 1;
  440.                     if (expand_carre2)
  441.                              expand_carre2 = 0;
  442.                     else
  443.                              expand_carre2 = 1;
  444.                     flag_motion_command = motion_carre2;
  445.          }*/
  446.          
  447.          // if... DO NOT draw the transparent carre2.  
  448.         /*  if (x>sb_c2->x_r_min && x<sb_c2->x_r_max && 
  449.                  y>sb_c2->y_r_min && y<sb_c2->y_r_max) 
  450.                     DRAW_CARRE2     = 0; */
  451.  
  452.          // if... draw the transparent carre3.
  453.          if (x>sb_c3->x_g_min  && x<sb_c3->x_g_max 
  454.                  && y>sb_c3->y_g_min && y<sb_c3->y_g_max){
  455.                     DRAW_CARRE3 = 1;
  456.                     if (expand_carre3)
  457.                              expand_carre3 = 0;
  458.                     else
  459.                              expand_carre3 = 1;
  460.                     flag_motion_command = motion_carre3;
  461.          }
  462.  
  463.          // if... DO NOT draw the transparent carre3.
  464.          if (x>sb_c3->x_r_min && x<sb_c3->x_r_max 
  465.                  && y>sb_c3->y_r_min && y<sb_c3->y_r_max) 
  466.                     DRAW_CARRE3 = 0;
  467.  
  468.          // if... Baseline_zoom = stereo_zoom
  469.          if (x > stereo_zoom_rect->xmin && x < stereo_zoom_rect->xmax && 
  470.                  y > stereo_zoom_rect->ymin && y < stereo_zoom_rect->ymax )
  471.                     flag_motion_command = baseline_zoom;
  472.  
  473.  
  474.          // if... scaling = 3D Zoom
  475.          if (x > scaling_rect->xmin && x < scaling_rect->xmax && 
  476.                  y > scaling_rect->ymin && y < scaling_rect->ymax )
  477.                     flag_motion_command = scaling;
  478.  
  479.          // if... Animation
  480.          if (x > animation_rect->xmin && x < animation_rect->xmax && 
  481.                  y > animation_rect->ymin && y < animation_rect->ymax )
  482.                     animation_window2();
  483.          
  484.          // if... vertical_adj
  485.          if (x > vertical_adj_rect->xmin && x < vertical_adj_rect->xmax && 
  486.                  y > vertical_adj_rect->ymin && y < vertical_adj_rect->ymax )
  487.                     flag_motion_command = vertical_adj;
  488.  
  489.          // if... translate_mirror
  490.          if (x > mirror_translate_rect->xmin && x < mirror_translate_rect->xmax && 
  491.                  y > mirror_translate_rect->ymin && y < mirror_translate_rect->ymax )
  492.                     flag_motion_command = mirror_translate;
  493.  
  494.          // if... translate_mirrorZ
  495.          if (x > mirror_translateZ_rect->xmin && x < mirror_translateZ_rect->xmax && 
  496.                  y > mirror_translateZ_rect->ymin && y < mirror_translateZ_rect->ymax )
  497.                     flag_motion_command = mirror_translateZ; 
  498.          
  499.          // if... translate_mirrorZ
  500.          if (x > top_view_comm->xmin && x < top_view_comm->xmax && 
  501.                  y > top_view_comm->ymin && y < top_view_comm->ymax )
  502.                     flag_motion_win = top_view_com;   
  503.  
  504.                   // if... translate_mirrorZ
  505.          if (x > big_win_comm->xmin && x < big_win_comm->xmax && 
  506.                  y > big_win_comm->ymin && y < big_win_comm->ymax )
  507.                     flag_motion_win = big_win_com;   
  508.  
  509.          // if... rotate_mirror
  510.          if (x > mirror_rotate_rect->xmin && x < mirror_rotate_rect->xmax && 
  511.                  y > mirror_rotate_rect->ymin && y < mirror_rotate_rect->ymax )
  512.                     flag_motion_command = flag_mirror_rotate;
  513.  
  514.          //if zooming y:
  515.          if (x > zoom_y_rect->xmin && x < zoom_y_rect->xmax && 
  516.                  y > zoom_y_rect->ymin && y < zoom_y_rect->ymax )
  517.                     flag_motion_command = flag_zoom_y;
  518.          redraw();
  519. }
  520. void
  521. animation_window2() //fanimation_window
  522. {
  523.    void draw_elevator();
  524.    void myReshape2(int, int);
  525.    void mouse2(int, int, int, int);
  526.    void motion2(int, int);
  527.          cout << "Animation window activated" << endl;
  528.          // glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH | GLUT_MULTISAMPLE | GLUT_STEREO); 
  529.          // glutCreateSubWindow (win, 0,0,150,H);
  530.          glutCreateWindow("a second window");
  531.          glutPositionWindow(0,175);
  532.          glutReshapeWindow (90,350);
  533.          glutDisplayFunc(draw_elevator);
  534.          //gfxinit();
  535.          glutReshapeFunc(myReshape2);
  536.          glutMouseFunc(mouse2);
  537.          glutMotionFunc(motion2);
  538.          // glutPassiveMotionFunc(passive_motion);
  539.          // create_menus();
  540.  
  541. }
  542. void  
  543. mouse(int button, int state, int x, int y) //fmouse
  544. {
  545.    // cout << x << " " << y << endl; // this prooves that the upper-left corner is the (0,0).
  546.          // if button down
  547.          if (button == GLUT_MIDDLE_BUTTON && state == GLUT_DOWN ) {
  548.                     // if commande board exist and mouse in it
  549.                     if (viewport && x<CDW) {
  550.                              commande_de_bord(x,y);
  551.                     }
  552.                     // if y>150 or viewport do not exist
  553.                     else{
  554.                              beginx = x;
  555.                              beginy = y;
  556.                              APPLY_MOUSE_MOTION = 1;
  557.                              flag_motion = flag_motion_command;
  558.                     }
  559.          }
  560.          else {
  561.             // Translation / Rotation
  562.             if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN) {
  563.                 APPLY_MOUSE_MOTION = 1;
  564.                 if (flag_motion != rotating_Geye)
  565.                     flag_motion = rotating;
  566.                 beginx = x;
  567.                 beginy = y;        
  568.                 if(glutGetModifiers() & GLUT_ACTIVE_SHIFT) {
  569.                          flag_motion = translating;
  570.                 }
  571.                 if(glutGetModifiers() & GLUT_ACTIVE_CTRL) {
  572.                          flag_motion = translatingz;
  573.                 }
  574.             }     
  575.          }
  576.          // if button up
  577.          if (state == GLUT_UP) {
  578.                     APPLY_MOUSE_MOTION =0;
  579.          }
  580.          
  581.          /*                     translating = rotating =scaling = baseline_zoom = 0;
  582.                                     DRAW_CARRE1 = DRAW_CARRE2 = DRAW_CARRE3 = 0; */         
  583.          
  584. }
  585.  
  586. void
  587. mouse2(int button, int state, int x, int y) //fmouse
  588. {
  589.          float thresh2;
  590.          void draw_elevator();
  591.          void redraw();
  592.  
  593.          // if left button down highlight some points
  594.          if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN) {
  595.                     thresh= (var_animation_min - var_animation_max) * (H2-y) / H2 + var_animation_max;
  596.                     Y = y;
  597.                     draw_elevator();
  598.  
  599.                     glutSetWindow(win);
  600.                     // highlightint points in the band
  601.                     if (flag_elevator == bandflag){
  602.                              // Recompiling the list.
  603.                              glNewList(28, GL_COMPILE_AND_EXECUTE);
  604.                              thresh2 = thresh + band;
  605.                              glPointSize(pt_size);
  606.                              glBegin(GL_POINTS);
  607.                              for (i=0; i<dim[0]; i=i+fraction){
  608.                                         if (var_animation[i] < thresh && var_animation[i] > thresh2 ) {
  609.                                                  glColor3f (cxx[i], cyy[i], czz[i]);
  610.                                                  glVertex3f(xc[i],yc[i],zc[i]);
  611.                                         }
  612.                              }
  613.                              glEnd();
  614.                              glPointSize(pt_size+2);
  615.                              glBegin(GL_POINTS);
  616.                              for (i=0; i<dim[0]; i=i+fraction){
  617.                                         if (var_animation[i] >= thresh && var_animation[i] <= thresh2 ) {
  618.                                                  glColor3f (cxx[i], cyy[i], czz[i]);
  619.                                                  glVertex3f(xc[i],yc[i],zc[i]);
  620.                                         }
  621.                              }
  622.                              glEnd();
  623.                     }
  624.                     else {
  625.                              // Highlighting point in the upper or lower part of the elevator.
  626.                              glNewList(28, GL_COMPILE_AND_EXECUTE);
  627.                              if (flag_elevator == upp)
  628.                                         glPointSize (pt_size);
  629.                              else if (flag_elevator == down)
  630.                                         glPointSize (pt_size+2);
  631.                              glBegin(GL_POINTS);
  632.                              for (i=0; i<dim[0]; i=i+fraction){
  633.                                         if (var_animation[i] <= thresh ) {
  634.                                                  glColor3f (cxx[i], cyy[i], czz[i]);
  635.                                                  glVertex3f(xc[i],yc[i],zc[i]);
  636.                                         }
  637.                              }
  638.                              glEnd();
  639.                     
  640.                              if (flag_elevator == upp)
  641.                                         glPointSize (pt_size+2);
  642.                              else if (flag_elevator == down)
  643.                                         glPointSize (pt_size);
  644.                              glBegin(GL_POINTS);
  645.                              for (i=0; i<dim[0]; i=i+fraction){
  646.                                         if (var_animation[i] > thresh ) {
  647.                                                  glColor3f (cxx[i], cyy[i], czz[i]);
  648.                                                  glVertex3f(xc[i],yc[i],zc[i]);
  649.                                         }
  650.                              }
  651.                              glEnd();
  652.                              
  653.                              glEndList();
  654.                              displayListInited = 1;
  655.                     }
  656.                     redraw();
  657.          }
  658.          
  659.          // if middle button down
  660.          if (button == GLUT_MIDDLE_BUTTON && state == GLUT_DOWN) {
  661.                     if (x > up_rect->xmin && x < up_rect->xmax && 
  662.                             y > up_rect->ymin && y < up_rect->ymax )
  663.                              flag_elevator = upp;
  664.  
  665.                     if (x > down_rect->xmin && x < down_rect->xmax && 
  666.                             y > down_rect->ymin && y < down_rect->ymax )
  667.                              flag_elevator = down;
  668.  
  669.                     if (x > band_rect->xmin && x < band_rect->xmax && 
  670.                             y > band_rect->ymin && y < band_rect->ymax )
  671.                              flag_elevator = bandflag;
  672.          }
  673. }
  674. void
  675. passive_motion(int x, int y) //fpassive_motion
  676. {
  677.    X = x;
  678.    Y = y;
  679.    /* if ((x>TOP_V_X) && (x<TOP_V_X+TOP_W) && (y>TOP_V_Y) && (FLAG_DROP_MENU!=3)) {
  680.       FLAG_DROP_MENU =3;
  681.       glutSetMenu(Menu3_id);
  682.       glutAttachMenu(GLUT_RIGHT_BUTTON);
  683.    }
  684.    else */
  685.       if ((x>CDW) && (FLAG_DROP_MENU!=1)) {
  686.             FLAG_DROP_MENU=1;
  687.             glutSetMenu(Menu1_id);
  688.             glutAttachMenu(GLUT_RIGHT_BUTTON);
  689.       }
  690.       else {
  691.          if ((x<CDW) && (FLAG_DROP_MENU!=2) && (y<H/2)) {
  692.                   FLAG_DROP_MENU =2;
  693.                   glutSetMenu(Menu2_id);
  694.                  glutAttachMenu(GLUT_RIGHT_BUTTON);
  695.          }
  696.          else  if ((x<CDW) && (FLAG_DROP_MENU!=3) && (y>H/2)) {
  697.                      FLAG_DROP_MENU =2;
  698.                         glutSetMenu(Menu3_id);
  699.                      glutAttachMenu(GLUT_RIGHT_BUTTON);
  700.                }
  701.       }
  702. }
  703.  
  704. void
  705. motion2(int x, int y) //f02
  706. {
  707.          float thresh; // threshhold
  708.          float thresh2;
  709.          void draw_elevator();
  710.          void redraw();
  711.  
  712.          Y = y;
  713.          draw_elevator();
  714.          // highlight some pts.
  715.          if (1){
  716.                     thresh= (var_animation_min - var_animation_max) * (H2-y) / H2 + var_animation_max;
  717.                     glutSetWindow(win);
  718.                     
  719.                     // highlightint points in the band
  720.                     if (flag_elevator == bandflag){
  721.                              // Recompiling the list.
  722.                              glNewList(28, GL_COMPILE_AND_EXECUTE);
  723.                              thresh2 = thresh + band;
  724.                              glPointSize(pt_size);
  725.                              glBegin(GL_POINTS);
  726.                              for (i=0; i<dim[0]; i=i+fraction){
  727.                                         if (var_animation[i] < thresh && var_animation[i] > thresh2 ) {
  728.                                                  glColor3f (cxx[i], cyy[i], czz[i]);
  729.                                                  glVertex3f(xc[i],yc[i],zc[i]);
  730.                                         }
  731.                              }
  732.                              glEnd();
  733.                              glPointSize(pt_size+2);
  734.                              glBegin(GL_POINTS);
  735.                              for (i=0; i<dim[0]; i=i+fraction){
  736.                                         if (var_animation[i] >= thresh && var_animation[i] <= thresh2 ) {
  737.                                                  glColor3f (cxx[i], cyy[i], czz[i]);
  738.                                                  glVertex3f(xc[i],yc[i],zc[i]);
  739.                                         }
  740.                              }
  741.                              glEnd();
  742.                     }
  743.                     else {
  744.                              // Highlighting point in the upper or lower part of the elevator.
  745.                              glNewList(28, GL_COMPILE_AND_EXECUTE);
  746.                              if (flag_elevator == upp)
  747.                                         glPointSize (pt_size);
  748.                              else if (flag_elevator == down)
  749.                                         glPointSize  (pt_size+2);
  750.                              glBegin(GL_POINTS);
  751.                              for (i=0; i<dim[0]; i=i+fraction){
  752.                                         if (var_animation[i] <= thresh ) {
  753.                                                  glColor3f (cxx[i], cyy[i], czz[i]);
  754.                                                  glVertex3f(xc[i],yc[i],zc[i]);
  755.                                         }
  756.                              }
  757.                              glEnd();
  758.                     
  759.                              if (flag_elevator == upp)
  760.                                         glPointSize (pt_size+2);
  761.                              else if (flag_elevator == down)
  762.                                         glPointSize  (pt_size);
  763.                              glBegin(GL_POINTS);
  764.                              for (i=0; i<dim[0]; i=i+fraction){
  765.                                         if (var_animation[i] > thresh ) {
  766.                                                  glColor3f (cxx[i], cyy[i], czz[i]);
  767.                                                  glVertex3f(xc[i],yc[i],zc[i]);
  768.                                         }
  769.                              }
  770.                              glEnd();
  771.                              
  772.                              glEndList();
  773.                              displayListInited = 1;
  774.                     }
  775.                     redraw();
  776.          }
  777. }
  778. void 
  779. UpdateVelocity_backup()
  780. {
  781.     if (Throttle > 0)
  782.         // Gazf is a positive number
  783.         Gazf  =  Throttle * MaxAccel / 30; // /30 because Throttle goes from 0 --> 30 in that case).
  784.     else // then it's a break and the Throttle goes from -33 --> 0.
  785.         // Gazf is a negative number
  786.         Gazf  = Throttle * MaxDecel /33;
  787.     //Force = mul_vect_par_nbr_reel (lk_rt, Gazf);
  788.     Acceleration = mul_vect_par_nbr_reel (lk_rt, Gazf);
  789.     //Gravity.x = Gravity.z =0; Gravity.y = -VoxelY; 
  790.     //Force = add_vect_to_pt (Force, Gravity);
  791.     Friction = mul_vect_par_nbr_reel (Velocity,- Friction_coef); // to damp the inertia.
  792.     //Force = add_vect_to_pt (Force, Friction);
  793.     Acceleration = add_vect_to_pt (Acceleration, Friction);
  794.     // Acceleration = div_vect_par_nbrd (Force,Masse);
  795.     Velocity = add_vect_to_pt (Velocity, mul_vect_par_nbr_reel(Acceleration, DTime)); // V = Vo + A*dt
  796.     if (scalairv(Velocity, lk_rt) < 0) 
  797.         Velocity.x = Velocity.y = Velocity.z = 0;
  798. }
  799. UpdateVelocity()
  800. {
  801.     if (Throttle > 0)
  802.         // Gazf is a positive number
  803.         Gazf  =  Throttle * MaxAccel / 30; // /30 because Throttle goes from 0 --> 30 in that case).
  804.     else // then it's a break and the Throttle goes from -33 --> 0.
  805.         // Gazf is a negative number
  806.         Gazf  = Throttle * MaxDecel /33;
  807.  
  808.     AccelScalar = Gazf - Speed * Friction_coef;
  809.     Speed = Speed + AccelScalar * DTime;
  810.     if (Speed < 0) Speed = 0;
  811. }
  812. float Time = 0;
  813. float TranslationFreq = 1;
  814. float TransVel = 10;
  815. void HenryTranslation()
  816. {
  817.   Time = Time + DTime;
  818.   Speed = TransVel*fabs(cos (6.28318*TranslationFreq*Time));
  819.   eye.x = eye.x + Speed*DTime;
  820.   if (eye.x > 90.590) eye.x = -75;
  821.   glutPostRedisplay();
  822. }
  823. #define PI 3.14159
  824. float PitchFreq = 0.5;
  825. float PitchAng = PI - 2.5; // This is the maximum angle of oscillation.
  826. float HenryMaxAngVelPitch = 1.256; // rd/s
  827. void HenryPitch()
  828. {
  829.   //HenryMaxAngVelPitch = -PitchAng * 2*PI * PitchFreq;
  830.   Time = Time + DTime;
  831.   Speed = HenryMaxAngVelPitch*cos (6.28318*PitchFreq*Time);
  832.   teta = Speed*DTime;
  833.  
  834.   axis_to_quat (axishor ,teta,lastquat);
  835.   add_quats(lastquat, curquat, curquat);
  836.  
  837.   build_rotmatrix(m, curquat);
  838.   lk_rt  = mult_matrix_vector(m,lk);  // lk is (0,0,1) lk_rt  is the lk  after the quaternion rotation
  839.   up_rt  = mult_matrix_vector(m,up ); // up  is (0,1,0) up_rt  is up      after the quaternion rotation.
  840.   hor_rt = mult_matrix_vector(m,hor); // hor is (1,0,0) hor_rt is hor     after the quaternion rotation.
  841.   //fprintf (fileJohn, "%f , %f , %f , %f\n", Time, Speed, teta, lk_rt.z);
  842.  
  843.   glutPostRedisplay();
  844. }
  845.  
  846. float YawFreq = 0.5;
  847. float YawAng = PI - 2.5;
  848. float HenryMaxAngVelYaw = 1.256; //rd/s
  849. void HenryYaw()
  850. {
  851.   //HenryMaxAngVelYaw = -YawAng * 2*PI * YawFreq;
  852.   Time = Time + DTime;
  853.   Speed = HenryMaxAngVelYaw*cos (6.28318*YawFreq*Time);
  854.   teta = Speed*DTime;
  855.  
  856.   axis_to_quat (axisup ,teta,lastquat);
  857.   add_quats(lastquat, curquat, curquat);
  858.  
  859.   build_rotmatrix(m, curquat);
  860.   lk_rt  = mult_matrix_vector(m,lk);  // lk is (0,0,1) lk_rt  is the lk  after the quaternion rotation
  861.   up_rt  = mult_matrix_vector(m,up ); // up  is (0,1,0) up_rt  is up      after the quaternion rotation.
  862.   hor_rt = mult_matrix_vector(m,hor); // hor is (1,0,0) hor_rt is hor     after the quaternion rotation.
  863.  
  864.   glutPostRedisplay();
  865. }
  866. float RollFreq = 0.5;
  867. float RollAng = PI - 2.5;
  868. float HenryMaxAngVelRoll = 1.256; //rd/s
  869. void HenryRoll()
  870. {
  871.   //HenryMaxAngVelRoll = -RollAng * 2*PI * RollFreq;
  872.   Time = Time + DTime;
  873.   Speed = HenryMaxAngVelRoll*cos (6.28318*RollFreq*Time);
  874.   teta = Speed*DTime;
  875.  
  876.   axis_to_quat (axislk ,teta,lastquat);
  877.   add_quats(lastquat, curquat, curquat);
  878.  
  879.   build_rotmatrix(m, curquat);
  880.   lk_rt  = mult_matrix_vector(m,lk);  // lk is (0,0,1) lk_rt  is the lk  after the quaternion rotation
  881.   up_rt  = mult_matrix_vector(m,up ); // up  is (0,1,0) up_rt  is up      after the quaternion rotation.
  882.   hor_rt = mult_matrix_vector(m,hor); // hor is (1,0,0) hor_rt is hor     after the quaternion rotation.
  883.   //fprintf (fileJohn, "%f , %f , %f , %f\n", Time, Speed, teta, lk_rt.z);
  884.  
  885.   glutPostRedisplay();
  886. }
  887. void HenryTranslationPitch()
  888. {
  889.   Time = Time + DTime;
  890.   Speed = TransVel*fabs(cos (6.28318*TranslationFreq*Time));
  891.   eye.x = eye.x + Speed*DTime;
  892.   if (eye.x > 90.590) eye.x = -75;
  893.  
  894.   HenryMaxAngVelPitch = -PitchAng * 2*PI * PitchFreq;
  895.   Speed = HenryMaxAngVelPitch*cos (6.28318*PitchFreq*Time);
  896.   teta = Speed*DTime;
  897.  
  898.   axis_to_quat (axishor ,teta,lastquat);
  899.   add_quats(lastquat, curquat, curquat);
  900.  
  901.   build_rotmatrix(m, curquat);
  902.   lk_rt  = mult_matrix_vector(m,lk);  // lk is (0,0,1) lk_rt  is the lk  after the quaternion rotation
  903.   up_rt  = mult_matrix_vector(m,up ); // up  is (0,1,0) up_rt  is up      after the quaternion rotation.
  904.   hor_rt = mult_matrix_vector(m,hor); // hor is (1,0,0) hor_rt is hor     after the quaternion rotation.
  905.  
  906.   glutPostRedisplay();
  907. }
  908.  
  909. void HenryTranslationYaw()
  910. {
  911.   Time = Time + DTime;
  912.   Speed = TransVel*fabs(cos (6.28318*TranslationFreq*Time));
  913.   eye.x = eye.x + Speed*DTime;
  914.   if (eye.x > 90.590) eye.x = -75;
  915.  
  916.   HenryMaxAngVelYaw = -YawAng * 2*PI * YawFreq;
  917.   Speed = HenryMaxAngVelYaw*cos (6.28318*YawFreq*Time);
  918.   teta = Speed*DTime;
  919.  
  920.   axis_to_quat (axisup ,teta,lastquat);
  921.   add_quats(lastquat, curquat, curquat);
  922.  
  923.   build_rotmatrix(m, curquat);
  924.   lk_rt  = mult_matrix_vector(m,lk);  // lk is (0,0,1) lk_rt  is the lk  after the quaternion rotation
  925.   up_rt  = mult_matrix_vector(m,up ); // up  is (0,1,0) up_rt  is up      after the quaternion rotation.
  926.   hor_rt = mult_matrix_vector(m,hor); // hor is (1,0,0) hor_rt is hor     after the quaternion rotation.
  927.   glutPostRedisplay();
  928. }
  929.  
  930.  
  931. void HenryTranslationRoll()
  932. {
  933.   Time = Time + DTime;
  934.   Speed = TransVel*fabs(cos (6.28318*TranslationFreq*Time));
  935.   eye.x = eye.x + Speed*DTime;
  936.   if (eye.x > 90.590) eye.x = -75;
  937.  
  938.   if (DTime > 1) DTime = 0.05;
  939.   HenryMaxAngVelRoll = -RollAng * 2*PI * RollFreq;
  940.   Speed = HenryMaxAngVelRoll*cos (6.28318*RollFreq*Time);
  941.   teta = Speed*DTime;
  942.  
  943.   axis_to_quat (axislk ,teta,lastquat);
  944.   add_quats(lastquat, curquat, curquat);
  945.  
  946.   build_rotmatrix(m, curquat);
  947.   lk_rt  = mult_matrix_vector(m,lk);  // lk is (0,0,1) lk_rt  is the lk  after the quaternion rotation
  948.   up_rt  = mult_matrix_vector(m,up ); // up  is (0,1,0) up_rt  is up      after the quaternion rotation.
  949.   hor_rt = mult_matrix_vector(m,hor); // hor is (1,0,0) hor_rt is hor     after the quaternion rotation.
  950.  
  951.   glutPostRedisplay();
  952. }
  953. void SpaceOrb()  //WinUnix
  954. {    
  955.  extern void Calc_Car_pos2 ();
  956.  extern int read_orb(int *, int *);
  957.  extern struct Virtual_Espace espace[DimX][DimY][DimZ];
  958.  extern double XmaxVrmlCity, YmaxVrmlCity, ZmaxVrmlCity;
  959.  extern double XminVrmlCity, YminVrmlCity, ZminVrmlCity;
  960.  extern float VoxelX, VoxelY, VoxelZ; // Dimention of a voxel.
  961.  double step1, step2,step3,sgnx,sgny,sgnz;
  962.  struct point dv1,dv2,dv3;
  963.  int i, bb,b, t[3], r[3];
  964.  t[0]=t[1]=t[2]=0;
  965.  r[0]=r[1]=r[2]=0;
  966.  // tin1 = tout2=clock();
  967.  //cout << "time to render is : " << tout2-tout1 << endl; 
  968.  //tin1 = clock();
  969.  for (i=0; i<50; i++){
  970.   bb = read_orb (t,r); // reads the translation / rotation of spaceorb!
  971.   if (bb!=-1) b= bb; // if at least one value is read from the space orb buffer
  972.                      // then memorize this value in b which will be the last value
  973.                      // read from the buffer stream. r and t are the last value read.
  974.  }
  975.  //b=2;
  976.  //r[2]=400;
  977.  //tin2 = clock();
  978.  //if (b!=-1) cout << "    " << tin2-tin1 <<"->" << b;
  979.  // cout << "read" << endl;
  980.  if ((b!=-1) ) {
  981.   if (b==1) flag_motion = mirror_translate;
  982.   if (b==2) flag_motion = flag_mirror_rotate; 
  983.   switch (flag_motion){
  984.    case mirror_translate:
  985.     if ((abs(t[0]) > abs(t[1])) && (abs(t[0]) > abs(t[2]))) {
  986.      step1 = t[0]/10000.0;
  987.      dv1 = mul_vect_par_nbr_reel (m1[FLAG_SELECTED_MIRROR].side,step1);
  988.      m1[FLAG_SELECTED_MIRROR].cr = add_vect_to_pt (m1[FLAG_SELECTED_MIRROR].cr, dv1);
  989.     }
  990.     else
  991.      if ((abs(t[1]) > abs(t[0])) && (abs(t[1]) > abs(t[2]))) {
  992.       step2 = -t[1]/10000.0;
  993.       dv2 = mul_vect_par_nbr_reel (m1[FLAG_SELECTED_MIRROR].nl  ,step2);
  994.       m1[FLAG_SELECTED_MIRROR].cr = add_vect_to_pt (m1[FLAG_SELECTED_MIRROR].cr, dv2);
  995.      }
  996.      else {
  997.       step3 = -t[2]/10000.0;
  998.       dv3 = mul_vect_par_nbr_reel (m1[FLAG_SELECTED_MIRROR].up,step3);
  999.       m1[FLAG_SELECTED_MIRROR].cr = add_vect_to_pt (m1[FLAG_SELECTED_MIRROR].cr, dv3);
  1000.      }
  1001.     //cout<<t[0]<<" "<<t[1]<<" "<<t[2]<<" "<<r[0]<<" "<<r[1]<<" "<<r[2]<<" "<<b<<endl;
  1002.     calc_corners_of_mirror(FLAG_SELECTED_MIRROR);
  1003.     glutPostRedisplay();
  1004.     break;
  1005.    case flag_mirror_rotate:
  1006.     //if (abs(r[0])<abs(r[2]) ){
  1007.     //sgnx = -r[2];
  1008.     //sgny = 0;
  1009.     //}else {
  1010.     //sgnx = 0;
  1011.     //sgny = -r[0];
  1012.     //}
  1013.     sgnx = -r[2];
  1014.     sgny = -r[0];
  1015.     if (  abs(sgnx)>abs(sgny)  ) 
  1016.      Habib_trackball_mirror(lastquat_mirror,0,0, sgnx*0.00003, 0,FLAG_SELECTED_MIRROR);
  1017.     else  
  1018.      Habib_trackball_mirror(lastquat_mirror,0,0, 0,sgny*0.0001, FLAG_SELECTED_MIRROR);
  1019.     // opp_trackball(lastquat_mirror,
  1020.     //(deux*beginx - W) / W,
  1021.     //(H - deux*beginy) / H,
  1022.     //(deux*x - W) / W,
  1023.     //(H - deux*y) / H
  1024.     //); 
  1025.     // add_quats(lastquat_mirror, curquat_mirror, curquat_mirror);
  1026.     build_rotmatrix(m, lastquat_mirror);
  1027.     //rotate mirror.
  1028.     m1[FLAG_SELECTED_MIRROR].side = mult_matrix_vector(m,m1[FLAG_SELECTED_MIRROR].side); //vx);
  1029.     m1[FLAG_SELECTED_MIRROR].up   = mult_matrix_vector(m,m1[FLAG_SELECTED_MIRROR].up  ); //vy);
  1030.     m1[FLAG_SELECTED_MIRROR].nl = mult_matrix_vector(m,m1[FLAG_SELECTED_MIRROR].nl    ); //vz);
  1031.     // cout<<t[0]<<" "<<t[1]<<" "<<t[2]<<" "<<r[0]<<" "<<r[1]<<" "<<r[2]<<" "<<b<<"habib"<<endl;
  1032.     calc_corners_of_mirror(FLAG_SELECTED_MIRROR);
  1033.     glutPostRedisplay();
  1034.     break;
  1035.   }
  1036.  }
  1037.  //tin2=clock();
  1038.  // cout << "Time in space orb orb orb orb orb : " << tin2-tin1 << endl;
  1039.  //tout1=clock(); 
  1040.  // Now Read the Joystick. Wedhachou.
  1041. #if 1
  1042.  LPJOYCAPS myjoy;
  1043.  LPJOYINFOEX myjoyinfo = new JOYINFOEX;
  1044.     
  1045.  myjoyinfo->dwFlags = JOY_RETURNALL ;
  1046.  joyGetPosEx (JOYSTICKID1, myjoyinfo);
  1047.  if ((myjoyinfo->dwButtons == 1) && (myjoyinfoDwPreviousButtons ==0)) {
  1048.   FLAG_MOVE_CAR = 1; // Button A of the steeringwheel.
  1049.   PlaySound("WalkingMode.wav", NULL, SND_ASYNC); 
  1050.  }
  1051.  if ((myjoyinfo->dwButtons ==2 ) && (myjoyinfoDwPreviousButtons ==0)) {
  1052.   FLAG_MOVE_CAR = 2; // Button B of the steeringwheel.
  1053.   // Calculating coord of eye in the (lkc_rt, upc_rt, horc_rt) coordinate system.
  1054.    struct point v   = sous_vect_to_pt (eye , eyec);
  1055.    eyeP.x = v.x * horc_rt.x  +  v.y * horc_rt.y  +  v.z * horc_rt.z;
  1056.    eyeP.y = v.x *  upc_rt.x  +  v.y *  upc_rt.y  +  v.z *  upc_rt.z;
  1057.    eyeP.z = v.x *  lkc_rt.x  +  v.y *  lkc_rt.y  +  v.z *  lkc_rt.z;
  1058.  
  1059.    upP.x = up_rt.x * horc_rt.x  +  up_rt.y * horc_rt.y  +  up_rt.z * horc_rt.z;
  1060.    upP.y = up_rt.x *  upc_rt.x  +  up_rt.y *  upc_rt.y  +  up_rt.z *  upc_rt.z;
  1061.    upP.z = up_rt.x *  lkc_rt.x  +  up_rt.y *  lkc_rt.y  +  up_rt.z *  lkc_rt.z;
  1062.  
  1063.    lkP.x = lk_rt.x * horc_rt.x  +  lk_rt.y * horc_rt.y  +  lk_rt.z * horc_rt.z;
  1064.    lkP.y = lk_rt.x *  upc_rt.x  +  lk_rt.y *  upc_rt.y  +  lk_rt.z *  upc_rt.z;
  1065.    lkP.z = lk_rt.x *  lkc_rt.x  +  lk_rt.y *  lkc_rt.y  +  lk_rt.z *  lkc_rt.z;
  1066.  
  1067.    horP.x = hor_rt.x * horc_rt.x  +  hor_rt.y * horc_rt.y  +  hor_rt.z * horc_rt.z;
  1068.    horP.y = hor_rt.x *  upc_rt.x  +  hor_rt.y *  upc_rt.y  +  hor_rt.z *  upc_rt.z;
  1069.    horP.z = hor_rt.x *  lkc_rt.x  +  hor_rt.y *  lkc_rt.y  +  hor_rt.z *  lkc_rt.z;
  1070.  
  1071.   //DriverPos.x = eyec.x - eye.x;
  1072.   //DriverPos.y = eyec.y - eye.y;
  1073.   //DriverPos.z = eyec.z - eye.z;
  1074.   PlaySound("DrivingMode.wav", NULL, SND_ASYNC);
  1075.  }
  1076.  if ((myjoyinfo->dwButtons == 4) && (myjoyinfoDwPreviousButtons ==0)) {
  1077.   PlaySound("FlyingMode.wav", NULL, SND_ASYNC);
  1078.   FLAG_MOVE_CAR = 4; // Button C of the steeringwheel.
  1079.   curquat[0] = curquatc[0];
  1080.   curquat[1] = curquatc[1];
  1081.   curquat[2] = curquatc[2];
  1082.   curquat[3] = curquatc[3];
  1083.  }
  1084.  if ((myjoyinfo->dwButtons == 8) && (myjoyinfoDwPreviousButtons ==0)) {
  1085.   FLAG_MOVE_CAR = 8; // Button X of the steeringwheel.
  1086.   PlaySound("MovingCarMode.wav",NULL,SND_ASYNC);
  1087.  }
  1088.  if ((myjoyinfo->dwButtons == 64) && (myjoyinfoDwPreviousButtons == 0)) // The C SideWinder Botton has been pushed
  1089.   (FLAG_HORIZ = !FLAG_HORIZ);
  1090.  
  1091.  myjoyinfoDwPreviousButtons = myjoyinfo->dwButtons;
  1092.  //if (0)//(myjoyinfo->dwXpos > 37736) || (myjoyinfo->dwXpos < 27736))
  1093.  //sgnx = (myjoyinfo->dwXpos - 32736.0)/6400.0; 
  1094.  sgnx = sgny = 0;
  1095.  
  1096.  // Throttle Goes from 0 to 63 (0-30 for the Gas) and (30-63 for the break)
  1097.  Throttle =  myjoyinfo->dwYpos >> 10;  // The myjoyinfo->dwYpos has a 6 bit precision the 10 last bits are
  1098.                                       // Always zero.
  1099.  // Throttle goes fom -30 ... 33
  1100.  Throttle = 30 - Throttle;
  1101.  int Angleint;
  1102.  Angleint = myjoyinfo->dwXpos >> 6;  // Steering is 10 bits precision.
  1103.  // cout << Angleint << endl;
  1104.  Angleint = 509 - Angleint;  // Angleint goes from -512 to +511.
  1105.  //teta = Angleint * Speed * DTime / 4000.0;
  1106.  // imitate variable ratio steering.
  1107.  teta = Angleint/ 4000.0 * (1 + Angleint*Angleint/ 250000) * Speed * DTime ; 
  1108.  
  1109. #endif
  1110.  
  1111.  //Walking Mode: Button A: MOVES THE EYE WITHOUT THE CAR.
  1112.  if (FLAG_MOVE_CAR==1) { // Equations of a real car, see Written Doc.
  1113.   //rotate the 3D up,lk,hor system.
  1114.   Habib_trackball(lastquat,0,0, teta, 0);
  1115.   add_quats(lastquat, curquat, curquat);
  1116.   build_rotmatrix(m, curquat);
  1117.   lk_rt = mult_matrix_vector(m,lk);   // lk is (0,0,1)      lk_rt  is the lk  after the quaternion rotation
  1118.   up_rt  = mult_matrix_vector(m,up ); // up  is (0,1,0)     up_rt  is up      after the quaternion rotation.
  1119.   hor_rt = mult_matrix_vector(m,hor); // hor is (1,0,0)     hor_rt is hor     after the quaternion rotation.
  1120.  
  1121.   // Calculate Forces => Velocity => Position
  1122.   Gazf = -Gazf;
  1123.   UpdateVelocity();
  1124.   Velocity = mul_vect_par_nbr_reel (lk_rt, Speed);
  1125.   eye = add_vect_to_pt (eye,mul_vect_par_nbr_reel(Velocity,DTime)); // Calculate new eye position.            // P = Po + V*dt
  1126.  
  1127. #if 0
  1128.   // Collision detection.
  1129.   ii = (eye.x - XminVrmlCity) * DimX / (XmaxVrmlCity - XminVrmlCity);
  1130.   if (ii<0) ii = 0;
  1131.   if (ii>=DimX) ii = DimX-1;
  1132.   jj = (eye.y-HauteurEye - YminVrmlCity) * DimY / (YmaxVrmlCity - YminVrmlCity);
  1133.   //jj1= (eye.y-HauteurEye+VoxelY - YminVrmlCity) * DimY / (YmaxVrmlCity - YminVrmlCity);
  1134.   if (jj<0) jj = 0;
  1135.   if (jj>=DimY) ii = DimY-1;
  1136.   //    if (jj1<0) ii = 0;
  1137.   //    if (jj1>=DimY) ii = DimY-1;
  1138.   kk = (eye.z - ZminVrmlCity) * DimZ / (ZmaxVrmlCity - ZminVrmlCity); 
  1139.   if (kk<0) kk = 0;
  1140.   if (kk>=DimZ) kk = DimZ-1;
  1141.   //if (espace[ii][jj][kk].FULL==1) { // For stability of the image.
  1142.   //eye.y = eye.y-Gravity.y;  // Cancels gravity at any collision
  1143.   // scalair = scalairv (espace[ii][jj][kk].N[0],Velocity);
  1144.   //if (scalair < 0){
  1145.   //vecttt = mul_vect_par_nbr_reel (espace[ii][jj][kk].N[0], scalair);
  1146.   //Velocity = sous_vect_to_pt (Velocity, vecttt);
  1147.   //}
  1148.   //}
  1149.   if (espace[ii][jj][kk].FULL>=1) 
  1150.    eye.y = eye.y+(VoxelY) * (espace[ii][jj][kk].FULL);
  1151. #endif
  1152.   Velocity.y = 0;
  1153.  }
  1154.  // Driving Car Mode
  1155.  if (FLAG_MOVE_CAR == 2){
  1156.   //rotate the 3D up,lk,hor system.
  1157.   //Habib_trackball(lastquat,0,0, teta, 0);
  1158.   axis_to_quat (axisup ,teta,lastquat);
  1159.   add_quats(lastquat, curquatc, curquatc);
  1160.  
  1161.   build_rotmatrix(mc, curquatc);
  1162.   lkc_rt  = mult_matrix_vector(mc,lk);  // lk is (0,0,1) lk_rt  is the lk  after the quaternion rotation
  1163.   upc_rt  = mult_matrix_vector(mc,up ); // up  is (0,1,0) up_rt  is up      after the quaternion rotation.
  1164.   horc_rt = mult_matrix_vector(mc,hor); // hor is (1,0,0) hor_rt is hor     after the quaternion rotation.
  1165.  
  1166.   // Calculate Forces => Velocity => Position
  1167.   Gazf = -Gazf;
  1168.   /* Force = mul_vect_par_nbr_reel (lkc_rt, Gazf);
  1169.   Gravity.x = Gravity.z =0; Gravity.y = -VoxelY; 
  1170.   Force = add_vect_to_pt (Force, Gravity);
  1171.   Friction = mul_vect_par_nbr_reel (Velocity,Friction_coef);
  1172.   Force = add_vect_to_pt (Force, Friction);
  1173.   Acceleration = div_vect_par_nbrd (Force,Masse);
  1174.   Velocity = add_vect_to_pt (Velocity, Acceleration);  */
  1175.   UpdateVelocity();
  1176.   Velocity = mul_vect_par_nbr_reel (lkc_rt, Speed);
  1177.   eyec = add_vect_to_pt (eyec,mul_vect_par_nbr_reel(Velocity,DTime)); // Calculate new eye position.            // P = Po + V*dt  
  1178.   // Collision detection.
  1179.   ii = (eyec.x - XminVrmlCity) * DimX / (XmaxVrmlCity - XminVrmlCity);
  1180.   if (ii<0) ii = 0;
  1181.   if (ii>=DimX) ii = DimX-1;
  1182.   jj = (eyec.y-HauteurEye - YminVrmlCity) * DimY / (YmaxVrmlCity - YminVrmlCity);
  1183.   //jj1= (eye.y-HauteurEye+VoxelY - YminVrmlCity) * DimY / (YmaxVrmlCity - YminVrmlCity);
  1184.   if (jj<0) jj = 0;
  1185.   if (jj>=DimY) ii = DimY-1;
  1186.   //    if (jj1<0) ii = 0;
  1187.   //    if (jj1>=DimY) ii = DimY-1;
  1188.   kk = (eyec.z - ZminVrmlCity) * DimZ / (ZmaxVrmlCity - ZminVrmlCity); 
  1189.   if (kk<0) kk = 0;
  1190.   if (kk>=DimZ) kk = DimZ-1;
  1191.   if (espace[ii][jj][kk].FULL>=1) 
  1192.    eyec.y = eyec.y+VoxelY * (espace[ii][jj][kk].FULL);
  1193.   Velocity.y = 0;
  1194.   // Calculates the eye and lk_rt, up_rt, hor_rt.
  1195.   lk_rt.x = lkP.x * horc_rt.x  +  lkP.y * upc_rt.x  +  lkP.z * lkc_rt.x;
  1196.   lk_rt.y = lkP.x * horc_rt.y  +  lkP.y * upc_rt.y  +  lkP.z * lkc_rt.y;
  1197.   lk_rt.z = lkP.x * horc_rt.z  +  lkP.y * upc_rt.z  +  lkP.z * lkc_rt.z;
  1198.  
  1199.   up_rt.x = upP.x * horc_rt.x  +  upP.y * upc_rt.x  +  upP.z * lkc_rt.x;
  1200.   up_rt.y = upP.x * horc_rt.y  +  upP.y * upc_rt.y  +  upP.z * lkc_rt.y;
  1201.   up_rt.z = upP.x * horc_rt.z  +  upP.y * upc_rt.z  +  upP.z * lkc_rt.z;
  1202.  
  1203.   hor_rt.x = horP.x * horc_rt.x  +  horP.y * upc_rt.x  +  horP.z * lkc_rt.x;
  1204.   hor_rt.y = horP.x * horc_rt.y  +  horP.y * upc_rt.y  +  horP.z * lkc_rt.y;
  1205.   hor_rt.z = horP.x * horc_rt.z  +  horP.y * upc_rt.z  +  horP.z * lkc_rt.z;
  1206.  
  1207.   eye.x = eyeP.x * horc_rt.x  +  eyeP.y * upc_rt.x  +  eyeP.z * lkc_rt.x;
  1208.   eye.y = eyeP.x * horc_rt.y  +  eyeP.y * upc_rt.y  +  eyeP.z * lkc_rt.y;
  1209.   eye.z = eyeP.x * horc_rt.z  +  eyeP.y * upc_rt.z  +  eyeP.z * lkc_rt.z;
  1210.   eye   = add_vect_to_pt (eye , eyec);
  1211.  
  1212.   // Record the car mvmt.
  1213.   if (RECORD_CAR_MVMT) {
  1214.       //Allocates CarLocationRec
  1215.       if (IndexCarLocRec[RecRouteNum] == CarLocAllocated[RecRouteNum]){
  1216.           CarLocAllocated[RecRouteNum] = CarLocAllocated[RecRouteNum]+100;
  1217.               if ( (CarLocationRec[RecRouteNum] = (struct car_location*) realloc (CarLocationRec[RecRouteNum],CarLocAllocated[RecRouteNum]*sizeof (struct car_location)) ) ==NULL) 
  1218.                 cout << "realloc error 1341 " << endl;
  1219.       }
  1220.       // Reads in the location and orientation of the car.
  1221.       CarLocationRec[RecRouteNum][IndexCarLocRec[RecRouteNum]].x = eyec.x;
  1222.       CarLocationRec[RecRouteNum][IndexCarLocRec[RecRouteNum]].y = eyec.y;
  1223.       CarLocationRec[RecRouteNum][IndexCarLocRec[RecRouteNum]].z = eyec.z;
  1224.       CarLocationRec[RecRouteNum][IndexCarLocRec[RecRouteNum]].quat[0] = curquatc[0];
  1225.       CarLocationRec[RecRouteNum][IndexCarLocRec[RecRouteNum]].quat[1] = curquatc[1];
  1226.       CarLocationRec[RecRouteNum][IndexCarLocRec[RecRouteNum]].quat[2] = curquatc[2];
  1227.       CarLocationRec[RecRouteNum][IndexCarLocRec[RecRouteNum]].quat[3] = curquatc[3];
  1228.       IndexCarLocRec[RecRouteNum]++;
  1229.   }
  1230.  }
  1231.  
  1232.  // Flying Mode.. Botton C: MOVES THE EYE WITHOUT COLLISION DETECTION.
  1233.  if (FLAG_MOVE_CAR == 4) {
  1234.   Habib_trackball(lastquat,0,0, teta, 0);
  1235.   add_quats(lastquat, curquat, curquat);
  1236.   build_rotmatrix(m, curquat);
  1237.   eye.x = eye.x - up_rt.x*sgny - hor_rt.x*sgnx -  lk_rt.x*sgnz;
  1238.   eye.z = eye.z - up_rt.z*sgny - hor_rt.z*sgnx -  lk_rt.z*sgnz; 
  1239.   if (!FLAG_HORIZ)
  1240.    eye.y = eye.y - up_rt.y*sgny - hor_rt.y*sgnx -  lk_rt.y*sgnz;
  1241.   //rotate the 3D up,lk,hor system.
  1242.   lk_rt = mult_matrix_vector(m,lk);   // lk is (0,0,1)      lk_rt  is the lk  after the quaternion rotation
  1243.   up_rt  = mult_matrix_vector(m,up ); // up  is (0,1,0)     up_rt  is up      after the quaternion rotation.
  1244.   hor_rt = mult_matrix_vector(m,hor); // hor is (1,0,0)     hor_rt is hor     after the quaternion rotation.
  1245.  }
  1246.  
  1247.  // Moving Car Mode. Botton X: MOVES THE CAR WITHOUT THE EYE.
  1248.  if (FLAG_MOVE_CAR==8) { //move car like in Netscape.
  1249.   Gazf  =  Throttle * MaxAccel / 30; // /30 because Throttle goes from 0 --> 30 in that case).
  1250.   teta = Angleint/ 4000.0; 
  1251.   if (WALK_SLOWLY){
  1252.      sgnz = Gazf = Gazf / SlowIt;
  1253.      teta = teta / SlowIt;
  1254.   }
  1255.   Habib_trackball(lastquat,0,0, teta, 0);
  1256.   add_quats(lastquat, curquatc, curquatc);
  1257.   build_rotmatrix(mc, curquatc);
  1258.   eyec.x = eyec.x - upc_rt.x*sgny - horc_rt.x*sgnx -  lkc_rt.x*sgnz;
  1259.   eyec.z = eyec.z - upc_rt.z*sgny - horc_rt.z*sgnx -  lkc_rt.z*sgnz; 
  1260.   if (!FLAG_HORIZ)
  1261.    eyec.y = eyec.y - upc_rt.y*sgny - horc_rt.y*sgnx -  lkc_rt.y*sgnz;
  1262.    //rotate the 3D up,lk,hor system.
  1263.    lkc_rt = mult_matrix_vector(mc,lk);   // lk is (0,0,1)      lk_rt  is the lk  after the quaternion rotation
  1264.    upc_rt  = mult_matrix_vector(mc,up ); // up  is (0,1,0)     up_rt  is up      after the quaternion rotation.
  1265.    horc_rt = mult_matrix_vector(mc,hor); // hor is (1,0,0)     hor_rt is hor     after the quaternion rotation.
  1266.  }
  1267.  
  1268.  // Place the Cars in the scene (next step).
  1269.  for (i=0;i<10;i++)
  1270.      if (RouteNum[i])
  1271.         if (IndexCarLocRec[i] < MaxIndexCarLocRec[i])
  1272.             IndexCarLocRec[i]++;
  1273.         else 
  1274.             IndexCarLocRec[i] = 0;
  1275.  //Calc_Car_pos2();
  1276.  glutPostRedisplay();
  1277.  
  1278.  //ii = (eye.x - XminVrmlCity) * DimX / (XmaxVrmlCity - XminVrmlCity);
  1279.  //jj = (eye.y - YminVrmlCity) * DimY / (YmaxVrmlCity - YminVrmlCity);
  1280.  //kk = (eye.z - ZminVrmlCity) * DimZ / (ZmaxVrmlCity - ZminVrmlCity); 
  1281.  //cout << (int) espace[ii][jj][kk].FULL << endl; 
  1282.  //cout << eye.x << " " << eye.y << " " << eye.z << " " << ii << " " << jj << " " << kk << endl;
  1283.  //cout << (int) espace[ii][jj][kk].FULL << endl;
  1284. }
  1285. void 
  1286. motion(int x, int y) //fmotion
  1287. // Handles the motion of the mouse in the big black window. get called when
  1288. // the a mouse button is pressed and the mouse is in motion.
  1289. {
  1290.    void redraw();
  1291.    void calc_corners_of_mirror(int i);
  1292.    struct point add_vect_to_pt (struct point, struct point);
  1293.    struct point mul_vect_par_nbr_reel(struct point, float);
  1294.  
  1295.    if (APPLY_MOUSE_MOTION) {
  1296.       double deux;
  1297.       int sgnx, sgny;
  1298.       double step1, step2;
  1299.       float stepx, stepy, stepz;
  1300.       struct point dv1,dv2;
  1301.       int stepo,steppss,stepppi;
  1302.       switch (flag_motion) {
  1303.       case motion_carre1:
  1304.          stepo = (y-beginy);
  1305.          carre1 = carre1 + stepo*(deltaz/10000); 
  1306.          //cout << "carre1 = " << carre1 << endl;
  1307.          beginy = y;
  1308.          break;
  1309.       case motion_carre2:
  1310.          steppss = (y-beginy);
  1311.          carre2 = carre2 + steppss*(deltay/20000); 
  1312.          beginy = y;
  1313.          break;
  1314.       case motion_carre3:
  1315.          stepppi = (y-beginy);
  1316.          carre3 = carre3 + stepppi*(deltax/1000); 
  1317.          beginy = y;
  1318.          break;
  1319.       case flag_change_light_intensity:
  1320.          if (beginy!=y) {
  1321.             int sgnn = (y-beginy); 
  1322.             step1 = 0.01;
  1323.             lightZeroColor[0] = lightZeroColor[0] + sgnn * step1;
  1324.             if (lightZeroColor[0] > 1) lightZeroColor[0] = 1;
  1325.             if (lightZeroColor[0] < 0) lightZeroColor[0] = 0;
  1326.             lightZeroColor[2] = lightZeroColor[1] = lightZeroColor[0];
  1327.             lightOneColor[0]=lightOneColor[1]=lightOneColor[2]=lightZeroColor[0];
  1328.             cout << "lightIntensity" << lightZeroColor[0] << endl;
  1329.             cout << "delta pixels = " << sgnn << endl;
  1330.             beginy = y;
  1331.             newModel = 1;
  1332.                //glutPostRedisplay();
  1333.          }
  1334.          break;    
  1335.       case scaling:
  1336.          if (beginy!=y) {
  1337.             // scalefactor = scalefactor * (1.0 + (((float) (beginy - y)) / H));
  1338.             int sgnn = (y-beginy); 
  1339.             step1 = (LEFT-RIGHT)/200.0;
  1340.             step2 = (BOTTOM-TOP)/200.0;
  1341.             if (flag_motion_win == top_view_com) {
  1342.                LEFT   = LEFT  + sgnn*step1;
  1343.                RIGHT  = RIGHT - sgnn*step1;
  1344.                BOTTOM = BOTTOM+ sgnn*step2;
  1345.                TOP    = TOP   - sgnn*step2;
  1346.             }
  1347.             else {
  1348.                cam_angle = cam_angle + sgnn*0.1;
  1349.             }
  1350.             beginy = y;
  1351.             newModel = 1;
  1352.                //glutPostRedisplay();
  1353.          }
  1354.          break;    
  1355.       case flag_zoom_y:
  1356.              if (beginy!=y) {
  1357.             // scalefactor = scalefactor * (1.0 + (((float) (beginy - y)) / H));
  1358.             int sgnn = (y-beginy); 
  1359.             step2 = (BOTTOM-TOP)/200.0;
  1360.             if (flag_motion_win == top_view_com) { 
  1361.                BOTTOM = BOTTOM+ sgnn*step2;
  1362.                TOP    = TOP   - sgnn*step2;
  1363.             }
  1364.             else {
  1365.                aspect_ratio = aspect_ratio + sgnn*0.01;
  1366.             }
  1367.             beginy = y;
  1368.             newModel = 1;
  1369.             }
  1370.       case baseline_zoom:
  1371.          if (beginy!=y) {
  1372.             int sgnn = (beginy-y); //abs((beginx-x));
  1373.             baseline = baseline + sgnn*0.001;
  1374.             beginy = y;
  1375.             //glutPostRedisplay();
  1376.          }
  1377.          break;
  1378.       case vertical_adj:
  1379.          vav = vav + (beginy - y); // vav = vertical adjustment value.
  1380.          mz[FLAG_SELECTED_MIRROR] = mz[FLAG_SELECTED_MIRROR] + (beginy - y);
  1381.          beginy=y;
  1382.          break;                     
  1383.       case translating: // TRANSLATING THE CAMERA.
  1384.         sgnx = sgny =0;
  1385.         if (beginx != x) sgnx = (beginx-x); //abs(beginx-x);
  1386.         if (beginy != y) sgny = (beginy-y); //abs(beginy-y);
  1387.         if (flag_motion_win == top_view_com) {
  1388.             step1 = -(LEFT-RIGHT)/800.0;
  1389.             step2 = (BOTTOM-TOP)/500.0;
  1390.             step1 = step1 / SlowIt;
  1391.             step2 = step2 / SlowIt;
  1392.             TRANSLATE_X = TRANSLATE_X - sgnx*step1;
  1393.             TRANSLATE_Y = TRANSLATE_Y - sgny*step2;
  1394.             /*LEFT   = LEFT  - sgnx*step1;
  1395.             RIGHT  = RIGHT - sgnx*step1;
  1396.             BOTTOM = BOTTOM+ sgny*step2;
  1397.             TOP    = TOP   + sgny*step2; */
  1398.          }
  1399.         else { // If I am moving the and my eye is fix with the scene, then
  1400.                // Translate the car, when shift motion is applied. Do not translate
  1401.                // the scene when I am in the moving CAR mode.
  1402.             if (FLAG_MOVE_CAR==8){ // This is the moving car mode.
  1403.               sgny = sgny / SlowIt;
  1404.               sgnx = sgnx / SlowIt;
  1405.               eyec.x = eyec.x + upc_rt.x*sgny*0.1 - horc_rt.x*sgnx*0.05;
  1406.                 eyec.z = eyec.z + upc_rt.z*sgny*0.1 - horc_rt.z*sgnx*0.05; 
  1407.               if (!FLAG_HORIZ)
  1408.                  eyec.y = eyec.y + upc_rt.y*sgny*0.1 - horc_rt.y*sgnx*0.05;
  1409.              }else{
  1410.                eye.x = eye.x - up_rt.x*sgny*0.1 - hor_rt.x*sgnx*0.05;
  1411.                  eye.z = eye.z - up_rt.z*sgny*0.1 - hor_rt.z*sgnx*0.05; 
  1412.                if (!FLAG_HORIZ)
  1413.                   eye.y = eye.y - up_rt.y*sgny*0.1 - hor_rt.y*sgnx*0.05;
  1414.              }
  1415.          }
  1416.       beginx = x;
  1417.       beginy = y;
  1418.       newModel = 1;
  1419.  
  1420.          //glutPostRedisplay();
  1421.          break;            
  1422.          // translating the camera in the z direction.
  1423.       case translatingz:
  1424.          sgny = 0;
  1425.          if (beginy != y) sgny = (beginy-y);
  1426.             eye.x = eye.x + lk_rt.x*sgny*0.05 ;
  1427.               eye.z = eye.z + lk_rt.z*sgny*0.05 ; 
  1428.             if (!FLAG_HORIZ)
  1429.                   eye.y = eye.y + lk_rt.y*sgny*0.05;
  1430.          beginy = y;
  1431.          newModel = 1;
  1432.          break;
  1433.       case rotating_Geye:
  1434.              deux = 2.0;
  1435.           trackball(lastquat_Geye,
  1436.                  (deux*beginx - W) / W,
  1437.                  (H - deux*beginy) / H,
  1438.                  (deux*x - W) / W,
  1439.                  (H - deux*y) / H
  1440.                                  );
  1441.          beginx = x;
  1442.          beginy = y;
  1443.          add_quats(lastquat_Geye, curquat_Geye, curquat_Geye);
  1444.          break;
  1445.       case rotating: 
  1446.          deux = 2.0;
  1447.          if (flag_motion_win == top_view_com)
  1448.             trackball(lastquat_top_view,
  1449.                  (deux*beginx - W) / W,
  1450.                  (H - deux*beginy) / H,
  1451.                  (deux*x - W) / W,
  1452.                  (H - deux*y) / H
  1453.                                  );
  1454.          else  {
  1455.             sgnx = beginx-x;
  1456.             sgny = beginy-y;
  1457.             if (  abs(sgnx)>abs(sgny)  ) 
  1458.                   Habib_trackball(lastquat,0,0, sgnx*0.001, 0);
  1459.             else  
  1460.                   Habib_trackball(lastquat,0,0, 0,sgny*0.001 );
  1461.          } 
  1462.          beginx = x;
  1463.          beginy = y;
  1464.          spinning = 0;
  1465.          if (flag_motion_win == top_view_com)
  1466.             add_quats(lastquat_top_view, curquat_top_view, curquat_top_view);
  1467.          else {
  1468.             add_quats(lastquat, curquat, curquat);
  1469.             build_rotmatrix(m, curquat);
  1470.            //rotate the 3D up,lk,hor system.
  1471.            lk_rt = mult_matrix_vector(m,lk);   // lk is (0,0,1)      lk_rt  is the lk  after the quaternion rotation
  1472.            up_rt  = mult_matrix_vector(m,up ); // up  is (0,1,0)     up_rt  is up      after the quaternion rotation.
  1473.            hor_rt = mult_matrix_vector(m,hor); // hor is (1,0,0)     hor_rt is hor     after the quaternion rotation.
  1474.          } 
  1475.          newModel = 1;
  1476.          //glutPostRedisplay();
  1477.          break;
  1478.       case mirror_translate:
  1479.          sgnx = sgny =0;
  1480.          if (beginx != x) sgnx = (x-beginx)*0.01; //abs(beginx-x);
  1481.          if (beginy != y) sgny = (beginy-y)*0.01; //abs(beginy-y);
  1482.          step1 = sgnx;
  1483.          step2 = sgny;
  1484.          dv1 = mul_vect_par_nbr_reel (m1[FLAG_SELECTED_MIRROR].side,step1);
  1485.          dv2 = mul_vect_par_nbr_reel (m1[FLAG_SELECTED_MIRROR].up  ,step2);
  1486.          m1[FLAG_SELECTED_MIRROR].cr = add_vect_to_pt (m1[FLAG_SELECTED_MIRROR].cr, dv1);
  1487.          m1[FLAG_SELECTED_MIRROR].cr = add_vect_to_pt (m1[FLAG_SELECTED_MIRROR].cr, dv2);
  1488.          calc_corners_of_mirror(FLAG_SELECTED_MIRROR);
  1489.          beginx = x;
  1490.          beginy = y;
  1491.          break;
  1492.       case mirror_translateZ:
  1493.          sgnx = sgny =0;
  1494.          if (beginx != x) sgnx = (beginx-x)*0.01; //abs(beginx-x);
  1495.          if (beginy != y) sgny = (beginy-y)*0.01; //abs(beginy-y);
  1496.          step1 = sgnx ;
  1497.          step2 = sgny ;
  1498.          dv1 = mul_vect_par_nbr_reel (m1[FLAG_SELECTED_MIRROR].nl,step1);
  1499.          dv2 = mul_vect_par_nbr_reel (m1[FLAG_SELECTED_MIRROR].nl  ,step2);
  1500.          m1[FLAG_SELECTED_MIRROR].cr = add_vect_to_pt (m1[FLAG_SELECTED_MIRROR].cr, dv1);
  1501.          m1[FLAG_SELECTED_MIRROR].cr = add_vect_to_pt (m1[FLAG_SELECTED_MIRROR].cr, dv2);
  1502.          calc_corners_of_mirror(FLAG_SELECTED_MIRROR);
  1503.          beginx = x;
  1504.          beginy = y;
  1505.          break;
  1506.       case flag_mirror_rotate:
  1507.         deux = 2.0;
  1508.             sgnx = beginx-x;
  1509.             sgny = beginy-y;
  1510.             if (  abs(sgnx)>abs(sgny)  ) 
  1511.                   Habib_trackball_mirror(lastquat_mirror,0,0, sgnx*0.001, 0,FLAG_SELECTED_MIRROR);
  1512.             else  
  1513.                   Habib_trackball_mirror(lastquat_mirror,0,0, 0,sgny*0.001, FLAG_SELECTED_MIRROR);
  1514.         /* opp_trackball(lastquat_mirror,
  1515.                  (deux*beginx - W) / W,
  1516.                  (H - deux*beginy) / H,
  1517.                  (deux*x - W) / W,
  1518.                  (H - deux*y) / H
  1519.                                  ); */
  1520.          beginx = x;
  1521.          beginy = y;
  1522.          // add_quats(lastquat_mirror, curquat_mirror, curquat_mirror);
  1523.          build_rotmatrix(m, lastquat_mirror);
  1524.          //rotate mirror.
  1525.          m1[FLAG_SELECTED_MIRROR].side = mult_matrix_vector(m,m1[FLAG_SELECTED_MIRROR].side); //vx);
  1526.          m1[FLAG_SELECTED_MIRROR].up   = mult_matrix_vector(m,m1[FLAG_SELECTED_MIRROR].up  ); //vy);
  1527.          m1[FLAG_SELECTED_MIRROR].nl = mult_matrix_vector(m,m1[FLAG_SELECTED_MIRROR].nl);//vz);
  1528.          calc_corners_of_mirror(FLAG_SELECTED_MIRROR);
  1529.          break;
  1530.       case flag_expand_mirror1_x:
  1531.          step2 =0;
  1532.          if (beginx != x) step2 = 0.1*(beginx-x); //abs(beginx-x);
  1533.          m1[FLAG_SELECTED_MIRROR].width=m1[FLAG_SELECTED_MIRROR].width+step2;
  1534.          calc_corners_of_mirror(FLAG_SELECTED_MIRROR);
  1535.          m1[FLAG_SELECTED_MIRROR].cr.x = (m1[FLAG_SELECTED_MIRROR].c1.x+m1[FLAG_SELECTED_MIRROR].c3.x)/2.0;
  1536.          m1[FLAG_SELECTED_MIRROR].cr.y = (m1[FLAG_SELECTED_MIRROR].c1.y+m1[FLAG_SELECTED_MIRROR].c3.y)/2.0;
  1537.          m1[FLAG_SELECTED_MIRROR].cr.z = (m1[FLAG_SELECTED_MIRROR].c1.z+m1[FLAG_SELECTED_MIRROR].c3.z)/2.0;
  1538.          beginx = x;
  1539.          break;
  1540.       case flag_expand_mirror1_y:
  1541.          step1 =0;
  1542.          if (beginy != y) step1 = 0.1*(beginy-y); 
  1543.          m1[FLAG_SELECTED_MIRROR].height=m1[FLAG_SELECTED_MIRROR].height+step1;
  1544.          calc_corners_of_mirror(FLAG_SELECTED_MIRROR);
  1545.          m1[FLAG_SELECTED_MIRROR].cr.x = (m1[FLAG_SELECTED_MIRROR].c1.x+m1[FLAG_SELECTED_MIRROR].c3.x)/2.0;
  1546.          m1[FLAG_SELECTED_MIRROR].cr.y = (m1[FLAG_SELECTED_MIRROR].c1.y+m1[FLAG_SELECTED_MIRROR].c3.y)/2.0;
  1547.          beginy = y;
  1548.          break;
  1549.       case flag_expand_mirror1_xy:
  1550.          step1 = step2 =0;
  1551.          if (beginx != x) step1 = 0.001*(beginx-x); 
  1552.          if (beginy != y) step2 = 0.001*(beginy-y); 
  1553.          m1[FLAG_SELECTED_MIRROR].width =fabs(m1[FLAG_SELECTED_MIRROR].width +step1);
  1554.          m1[FLAG_SELECTED_MIRROR].height=fabs(m1[FLAG_SELECTED_MIRROR].height+step2);
  1555.          calc_corners_of_mirror(FLAG_SELECTED_MIRROR);
  1556.          m1[FLAG_SELECTED_MIRROR].cr.x = (m1[FLAG_SELECTED_MIRROR].c1.x+m1[FLAG_SELECTED_MIRROR].c3.x)/2.0;
  1557.          m1[FLAG_SELECTED_MIRROR].cr.y = (m1[FLAG_SELECTED_MIRROR].c1.y+m1[FLAG_SELECTED_MIRROR].c3.y)/2.0;
  1558.          beginx = x;
  1559.          beginy = y;
  1560.          break;
  1561.       case flag_top_expand_xy:
  1562.          sgny = sgnx =0;
  1563.          if (beginx != x) sgnx = (beginx-x); 
  1564.          if (beginy != y) sgny = (beginy-y); 
  1565.          TOP_W = TOP_W + sgnx;
  1566.          TOP_H = TOP_H + sgny;
  1567.          TOP_V_Y= H-TOP_H; // It's the lower left corner of the TOP_VIEW_WINDOW
  1568.          beginx = x;
  1569.          beginy = y;
  1570.          break;
  1571.       case flag_move_light0:
  1572.          sgny = 0;
  1573.          if (beginy != y) sgny = (beginy-y); 
  1574.           stepx = (lightZeroPosition[0] - Center_Of_Rot_Of_Lights.x)/200.0;
  1575.           stepy = (lightZeroPosition[1] - Center_Of_Rot_Of_Lights.y)/200.0;
  1576.           stepz = (lightZeroPosition[2] - Center_Of_Rot_Of_Lights.z)/200.0;
  1577.           lightZeroPosition[0] = lightZeroPosition[0] + stepx*sgny;
  1578.           lightZeroPosition[1] = lightZeroPosition[1] + stepy*sgny;
  1579.           lightZeroPosition[2] = lightZeroPosition[2] + stepz*sgny;
  1580.           beginx = x;
  1581.           beginy = y;
  1582.           break;
  1583.       case flag_move_light1:
  1584.          sgny = 0;
  1585.          if (beginy != y) sgny = (beginy-y); 
  1586.           stepx = (lightOnePosition[0] - Center_Of_Rot_Of_Lights.x)/200.0;
  1587.           stepy = (lightOnePosition[1] - Center_Of_Rot_Of_Lights.y)/200.0;
  1588.           stepz = (lightOnePosition[2] - Center_Of_Rot_Of_Lights.z)/200.0;
  1589.           lightOnePosition[0] = lightOnePosition[0] + stepx*sgny;
  1590.           lightOnePosition[1] = lightOnePosition[1] + stepy*sgny;
  1591.           lightOnePosition[2] = lightOnePosition[2] + stepz*sgny;
  1592.           beginx = x;
  1593.           beginy = y;
  1594.           break;
  1595.       case flag_rotate_light0:
  1596.             pos_light0.x = lightZeroPosition[0];
  1597.             pos_light0.y = lightZeroPosition[1];
  1598.             pos_light0.z = lightZeroPosition[2];
  1599.             trackball(lastquat_light0,
  1600.                  (2.0*beginx - W) / W,
  1601.                  (H - 2.0*beginy) / H,
  1602.                  (2.0*x - W) / W,
  1603.                  (H - 2.0*y) / H );
  1604.             //add_quats(lastquat_light0, curquat_light0, curquat_light0);
  1605.             build_rotmatrix (m, lastquat_light0);
  1606.             pos_light0 = mult_matrix_vector(m,pos_light0);
  1607.             lightZeroPosition[0]=pos_light0.x ;
  1608.             lightZeroPosition[1]=pos_light0.y ;
  1609.             lightZeroPosition[2]=pos_light0.z ;
  1610.             beginx = x;
  1611.             beginy = y;
  1612.             break;
  1613.       case flag_rotate_light1:
  1614.             pos_light1.x = lightOnePosition[0];
  1615.             pos_light1.y = lightOnePosition[1];
  1616.             pos_light1.z = lightOnePosition[2];
  1617.             trackball(lastquat_light1,
  1618.                  (2.0*beginx - W) / W,
  1619.                  (H - 2.0*beginy) / H,
  1620.                  (2.0*x - W) / W,
  1621.                  (H - 2.0*y) / H );
  1622.             //add_quats(lastquat_light0, curquat_light0, curquat_light0);
  1623.             build_rotmatrix (m, lastquat_light1);
  1624.             pos_light1 = mult_matrix_vector(m,pos_light1);
  1625.             lightOnePosition[0]=pos_light1.x ;
  1626.             lightOnePosition[1]=pos_light1.y ;
  1627.             lightOnePosition[2]=pos_light1.z ;
  1628.             beginx = x;
  1629.             beginy = y;
  1630.             break;
  1631.             }
  1632.     }
  1633.       glutPostRedisplay();
  1634. }
  1635.  
  1636. inline
  1637. void
  1638. DropMenu3(int value)
  1639. {
  1640.    void redraw();
  1641.    /*switch (value)   {
  1642.       case 1: */
  1643.    FLAG_SELECTED_MIRROR = value;
  1644. }
  1645.  
  1646. GLboolean lightZeroSwitch = GL_TRUE, lightOneSwitch = GL_TRUE;
  1647. void
  1648. DropMenu2(int value)
  1649. {
  1650.    void redraw();
  1651.    if (FLAG_TOGGLE_MIRROR[value]==1)
  1652.        FLAG_TOGGLE_MIRROR[value] =0 ;
  1653.    else
  1654.        FLAG_TOGGLE_MIRROR[value] =1 ;
  1655.  
  1656.    //displayListInited = 0;
  1657.    // redraw();
  1658.    glutPostRedisplay();
  1659. }
  1660.  
  1661. //fdropmenu1
  1662. void
  1663. DropMenu1(int value)
  1664. {
  1665.    extern void    calc_coord_mirror_rel_to_camera(int i);
  1666.    void add_to_the_menus_a_mirror(int i);
  1667.    void redraw();
  1668.    void fog();
  1669.          switch (value) {
  1670.          case 1: // Toggle Light.
  1671.              if (FLAG_TOGGLE_MENU1){
  1672.                  FLAG_TOGGLE_MENU1 = 0;
  1673.                  cout << "Light Disabled" << endl;
  1674.                  glDisable(GL_LIGHTING); 
  1675.              }
  1676.              else{
  1677.                  FLAG_TOGGLE_MENU1 = 1;
  1678.                  cout << "Light Enabled" << endl;
  1679.                  glEnable(GL_LIGHTING);
  1680.              }
  1681.                     break;
  1682.          case 2:
  1683.              if (FLAG_TOGGLE_TEXTURE_MAP){
  1684.                  FLAG_TOGGLE_TEXTURE_MAP = 0;
  1685.                  glDisable(GL_LIGHTING); 
  1686.              }
  1687.              else{
  1688.                  FLAG_TOGGLE_TEXTURE_MAP = 1;
  1689.                  glEnable(GL_LIGHTING);
  1690.              }                    
  1691.                     
  1692.                     break;
  1693.          case 3:
  1694. /* workaround hack */
  1695. #if 0
  1696.                     if(glIsEnabled(GL_MULTISAMPLE_SGIS)) {
  1697.                              glDisable(GL_MULTISAMPLE_SGIS);
  1698.                     } else {
  1699.                              glEnable(GL_MULTISAMPLE_SGIS);
  1700.                     }
  1701. #endif
  1702.                     break;
  1703.          case 4:
  1704.                     glutFullScreen();
  1705.                     break;
  1706.          case 5:
  1707.                     cout << "Baseline = " << baseline << endl  ;
  1708.                     cout << "Give new Baseline : " ;
  1709.                     cin >> baseline;
  1710.                     break;
  1711.          case 6:
  1712.                     displayListInited=0;
  1713.                     for (i=0; i<dim[0]; i++){
  1714.                              cxx[i]=1.0;
  1715.                              cyy[i]=1.0;
  1716.                              czz[i]=1.0;
  1717.                     }
  1718.                     break;
  1719.          case 7:
  1720.                     displayListInited=0;
  1721.                     for (i=0; i<dim[0]; i++){
  1722.                              switch (col1[i]){
  1723.                              case 1:
  1724.                                         cxx[i]=0.0; cyy[i]=1.0; czz[i]=1.0;
  1725.                                         break;
  1726.                              case 2:
  1727.                                         cxx[i]=1.0; cyy[i]=0.0; czz[i]=1.0;
  1728.                                         break;
  1729.                              case 3:
  1730.                                         cxx[i]=1.0; cyy[i]=1.0; czz[i]=0.0;
  1731.                                         break;
  1732.                              case 4:
  1733.                                         cxx[i]=1.0; cyy[i]=0.0; czz[i]=0.0;
  1734.                                         break;
  1735.                              case 5:
  1736.                                         cxx[i]=0.0; cyy[i]=1.0; czz[i]=0.0;
  1737.                                         break;
  1738.                              case 6:
  1739.                                         cxx[i]=0.0; cyy[i]=0.0; czz[i]=1.0;
  1740.                                         break;
  1741.                              case 7:
  1742.                                         cxx[i]=1.0; cyy[i]=0.5; czz[i]=0.25;
  1743.                                         break;
  1744.                              case 8:
  1745.                                         cxx[i]=1.0; cyy[i]=1.0; czz[i]=1.0;
  1746.                                         break;
  1747.                              }
  1748.                     }
  1749.                     break;
  1750.          case 8:
  1751.                     displayListInited=0;
  1752.                     for (i=0; i<dim[0]; i++){
  1753.                              switch (col4[i]){ 
  1754.                              case 1:
  1755.                                         cxx[i]=1.0; cyy[i]=0.5; czz[i]=0.25;
  1756.                                         break;
  1757.                              case -1:
  1758.                                         cxx[i]=0.25; cyy[i]=0.9; czz[i]=0.75;
  1759.                                         break;
  1760.                              }
  1761.                     }
  1762.                     break;
  1763.          case 9:
  1764.                     TRANSLATE_TO_GRAVITY = 0; 
  1765.                     TRANSLATE_TO_MIDDLE  = 0;
  1766.                     break;
  1767.          case 10:
  1768.                     TRANSLATE_TO_GRAVITY = 1; 
  1769.                     TRANSLATE_TO_MIDDLE  = 0;
  1770.                     break;
  1771.          case 11:
  1772.                     TRANSLATE_TO_GRAVITY = 0; 
  1773.                     TRANSLATE_TO_MIDDLE  = 1;
  1774.                     break;
  1775.          case 12: // normal scaling (1,1,1)
  1776.                     SCALE_SIGMA   = 0 ;
  1777.                     SCALE_MIDDLE  = 0 ;
  1778.                     break;
  1779.          case 13: // sigma scaling
  1780.                     SCALE_SIGMA   = 1 ;
  1781.                     SCALE_MIDDLE  = 0 ;
  1782.                     break;
  1783.          case 14: // middle scaling 
  1784.                     SCALE_SIGMA   = 0 ;
  1785.                     SCALE_MIDDLE  = 1 ;
  1786.                     break;
  1787.          case 15:
  1788.                     cout << "Give the pixel size : " << endl;
  1789.                     cin >> pt_size;
  1790.                     displayListInited = 0;
  1791.                     break;
  1792.          case 16:
  1793.                     cout << "What fraction of the points would you like to display ?" ;
  1794.                     cin >> fraction;
  1795.                     displayListInited = 0;
  1796.                     break;
  1797.          case 17:
  1798.                     if (TOGGLE_BOX == 1 ) TOGGLE_BOX = 0;
  1799.                     else TOGGLE_BOX = 1;
  1800.                     redraw();
  1801.                     break;
  1802.          case 18:
  1803.                     baseline = -baseline;
  1804.                     redraw();
  1805.                     break;
  1806.          case 19:
  1807.                     //fog();
  1808.                     redraw();
  1809.                     break;
  1810.          case 20:
  1811.                     glDisable(GL_FOG);
  1812.                     redraw();
  1813.                     break;
  1814.          case 21:
  1815.                     if (viewport == 0)
  1816.                              viewport = 1; 
  1817.                     else{
  1818.                              viewport = 0;
  1819.                     }
  1820.                     redraw();
  1821.                     break;
  1822.          case 22:
  1823.                     if (Draw_relative_axe == 0)
  1824.                              Draw_relative_axe = 1; 
  1825.                     else{
  1826.                              Draw_relative_axe = 0;
  1827.                     }
  1828.                     redraw();
  1829.                     break;
  1830.          case 23:
  1831.                     if (FLAG_TOP_VIEW == 0)
  1832.                              FLAG_TOP_VIEW = 1; 
  1833.                     else{
  1834.                              FLAG_TOP_VIEW = 0;
  1835.                     }
  1836.                     redraw();
  1837.                     break;
  1838.          case 24:
  1839.                     if (FLAG_FRONT_VIEW == 0)
  1840.                              FLAG_FRONT_VIEW = 1; 
  1841.                     else{
  1842.                              FLAG_FRONT_VIEW = 0;
  1843.                     }
  1844.                     redraw();
  1845.                     break;
  1846.          case 25:
  1847.                     if (FLAG_ORTHO_PERSP == 0)
  1848.                              FLAG_ORTHO_PERSP = 1; 
  1849.                     else{
  1850.                              FLAG_ORTHO_PERSP = 0;
  1851.                     }
  1852.                     redraw();
  1853.                     break;
  1854.          case 26:
  1855.             if (FLAG_HORIZ == 0)
  1856.                              FLAG_HORIZ = 1; 
  1857.             else
  1858.                      FLAG_HORIZ = 0;
  1859.                     break;
  1860.          case 27:   if (FLAG_FIX_MIRROR ==0){
  1861.                         FLAG_FIX_MIRROR =1;
  1862.                         for (i=0;i<number_of_mirrors;i++){
  1863.                            calc_coord_mirror_rel_to_camera(i);
  1864.                         }
  1865.                     }
  1866.                     else
  1867.                        FLAG_FIX_MIRROR = 0;
  1868.                     break;
  1869.          case 28:  
  1870.                     add_to_the_menus_a_mirror(number_of_mirrors);
  1871.                     number_of_mirrors++;
  1872.                     break;
  1873.          case 29:
  1874.                     if (Draw_light_position == 0)
  1875.                              Draw_light_position = 1; 
  1876.                     else{
  1877.                              Draw_light_position = 0;
  1878.                     }
  1879.                     redraw();
  1880.                     break;
  1881.          case 99:
  1882.                     exit(0);
  1883.                     break;
  1884.          }
  1885.          glutPostRedisplay();
  1886. }
  1887.  
  1888.  
  1889. //fcreate_menus
  1890. void
  1891. create_menus()
  1892. {                    
  1893.     glutCreateMenu(DropMenu1); html // Drop Menu1 is the function where you implement
  1894.                                     // the menu id's. 
  1895.     Menu1_id = glutGetMenu();
  1896.     glutAddMenuEntry("Toggle lights"                     , 1);
  1897.     // glutAddMenuEntry("Toggel Mirror 1"                , 2);
  1898.     glutAddMenuEntry("Full screen"                       , 4);
  1899.     //glutAddMenuEntry("Set baseline"                    , 5);
  1900.     //glutAddMenuEntry("Remove color "                   , 6);
  1901.     //glutAddMenuEntry("Put color col1"                  , 7);
  1902.     //glutAddMenuEntry("Put color col4"                  , 8);
  1903.     //glutAddMenuEntry("Origine at 0"                    , 9);
  1904.     //glutAddMenuEntry("Origine at mean"                 , 10);
  1905.     //glutAddMenuEntry("Origine at mid-range"            , 11);
  1906.     //glutAddMenuEntry("Scaling unity"                   , 12);
  1907. //    glutAddMenuEntry("Scaling sigma"                     , 13);
  1908.     //glutAddMenuEntry("Scaling range"                   , 14);
  1909.     //glutAddMenuEntry("Size_pt = "                      , 15);
  1910.     //glutAddMenuEntry("Number_points = "                , 16);
  1911. //    glutAddMenuEntry("Toggle box"                        , 17);
  1912.     //glutAddMenuEntry("Toggle cameras left-right"       , 18);
  1913.     //glutAddMenuEntry("Add some Fog..."                 , 19);
  1914. //    glutAddMenuEntry("Remove the Fog..."                 , 20);
  1915.     glutAddMenuEntry("Toggle viewport"                   , 21);
  1916.     glutAddMenuEntry("Toggle axes "                      , 22);
  1917.     glutAddMenuEntry("Toggle TOP VIEW "                  , 23);
  1918.     // glutAddMenuEntry("Toggle FRONT VIEW"                 , 24);
  1919.     glutAddMenuEntry("Toggle Ortho-Persp."               , 25);
  1920.     glutAddMenuEntry("Toggle Move Horizontally."         , 26);
  1921.     glutAddMenuEntry("FIX_MIRROR_TO_CAMERA"              , 27);
  1922.     glutAddMenuEntry("ADD A MIRROR TO THE SCENE"         , 28);
  1923.     glutAddMenuEntry("Show the position of the lights"   , 29);
  1924.  
  1925.     if(glutGet(GLUT_WINDOW_NUM_SAMPLES) > 0) {
  1926.         glutAddMenuEntry("Toggle multisampling", 3);
  1927.         glutSetWindowTitle("dinospin (multisample capable)");
  1928.     }
  1929.     glutAddMenuEntry("Quit", 99);
  1930.  
  1931.     // Drop Menu2.
  1932.     glutCreateMenu(DropMenu2);
  1933.     Menu2_id = glutGetMenu();
  1934.     glutSetMenu(Menu2_id);
  1935.     // int i;
  1936.     // glutAddMenuEntry ("None",1);
  1937.     /*for (i=0;i<nbr_of_col; i++){
  1938.             glutAddMenuEntry(var_name[i],i+2);
  1939.     }*/
  1940.  
  1941.     // Drop Menu3.
  1942.     glutCreateMenu(DropMenu3);
  1943.     Menu3_id = glutGetMenu();
  1944.     glutSetMenu(Menu3_id);
  1945.     // glutAddMenuEntry ("None",1);
  1946.  
  1947. }
  1948. void
  1949. add_to_the_menus_a_mirror(int i)
  1950. {
  1951.    void initialize_a_mirror(int );
  1952.    char buffer[20];
  1953.    char b2[20];
  1954.  
  1955.    glutSetMenu(Menu2_id);
  1956.    strcpy (buffer,"Toggle mirror ");
  1957.    strcat (buffer, itoa(i,b2,10)); // WinUnix Just Comment this for now...
  1958.    glutAddMenuEntry(buffer,i); // the Id of the first mirror[0] is 2 in the menu.
  1959.    glutSetMenu(Menu3_id);
  1960.    strcpy (buffer,"Select mirror ");
  1961.    strcat (buffer, b2);   // WinUnix Just Comment this for now...
  1962.    glutAddMenuEntry(buffer,i);
  1963.    initialize_a_mirror(i); 
  1964. }
  1965.  
  1966. void
  1967. draw_elevator() //fdraw_elevator
  1968. /* draws the background of the window2 the elevator window. */
  1969. {
  1970.          int len;
  1971.          char string1[] = "Up";
  1972.          char string2[] = "Do";
  1973.          char string3[] = "Ba";
  1974.          char string4[] = "9.11";
  1975.  
  1976.  
  1977.          glDrawBuffer(GL_BACK);
  1978.          glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  1979.  
  1980.          // Set Projection Matrix
  1981.          glMatrixMode(GL_PROJECTION);/* set up projection transform */
  1982.      glLoadIdentity();
  1983.      glOrtho (0,W2, H2,0 ,-1 ,1);
  1984.  
  1985.          // Set ModelView Matrix.
  1986.          glMatrixMode (GL_MODELVIEW);
  1987.          glLoadIdentity();
  1988.  
  1989.          // Drawing the up box.
  1990.          up_rect->xmin = 0 ;
  1991.          up_rect->xmax = 20;
  1992.          up_rect->ymin = 0 ;
  1993.          up_rect->ymax = 10 ;
  1994.          glBegin (GL_POLYGON);
  1995.          glColor3f (0.9f,0.8f,0.7f);
  1996.          glVertex2i (up_rect->xmin,up_rect->ymin);
  1997.          glVertex2i (up_rect->xmin,up_rect->ymax);
  1998.          glVertex2i (up_rect->xmax,up_rect->ymax);
  1999.          glVertex2i (up_rect->xmax,up_rect->ymin);
  2000.          glEnd();
  2001.          glColor3f (0.15f,0.15f,1.0f);
  2002.          glRasterPos2i(up_rect->xmin, up_rect->ymax);
  2003.          len = (int) strlen(string1);
  2004.          for (i = 0; i < len; i++) 
  2005.                     glutBitmapCharacter(GLUT_BITMAP_8_BY_13, string1[i]);
  2006.  
  2007.          // Drawing the down box.
  2008.          down_rect->xmin = 30 ;
  2009.          down_rect->xmax = 50;
  2010.          down_rect->ymin = 0 ;
  2011.          down_rect->ymax = 10 ;
  2012.          glBegin (GL_POLYGON);
  2013.          glColor3f (0.7f,0.9f,0.8f);
  2014.          glVertex2i (down_rect->xmin,down_rect->ymin);
  2015.          glVertex2i (down_rect->xmin,down_rect->ymax);
  2016.          glVertex2i (down_rect->xmax,down_rect->ymax);
  2017.          glVertex2i (down_rect->xmax,down_rect->ymin);
  2018.          glEnd();
  2019.          glColor3f (0.2f,0.15f,0.1f);
  2020.          glRasterPos2i(down_rect->xmin, down_rect->ymax);
  2021.          len = (int) strlen(string2);
  2022.          for (i = 0; i < len; i++) 
  2023.                     glutBitmapCharacter(GLUT_BITMAP_8_BY_13, string2[i]);
  2024.  
  2025.          // Drawing the Band box.
  2026.          band_rect->xmin = 60 ;
  2027.          band_rect->xmax = 80;
  2028.          band_rect->ymin = 0 ;
  2029.          band_rect->ymax = 10 ;
  2030.          glBegin (GL_POLYGON);
  2031.          glColor3f (0.76f,0.9f,0.6f);
  2032.          glVertex2i (band_rect->xmin,band_rect->ymin);
  2033.          glVertex2i (band_rect->xmin,band_rect->ymax);
  2034.          glVertex2i (band_rect->xmax,band_rect->ymax);
  2035.          glVertex2i (band_rect->xmax,band_rect->ymin);
  2036.          glEnd();
  2037.          glColor3f (0.15f,0.15f,0.3f);
  2038.          glRasterPos2i(band_rect->xmin, band_rect->ymax);
  2039.          len = (int) strlen(string3);
  2040.          for (i = 0; i < len; i++) 
  2041.                     glutBitmapCharacter(GLUT_BITMAP_8_BY_13, string3[i]);
  2042.  
  2043.          // Draw the line indicating where you are in the window.
  2044.          glBegin (GL_LINES);
  2045.          glColor3f (0.15f,1.0f,0.3f);
  2046.          glVertex2i (0,Y);
  2047.          glVertex2i (90,Y);
  2048.          glEnd();
  2049.          glColor3f (1,1,1);
  2050.          glRasterPos2i(3,Y);
  2051.          len = (int) strlen(string4);
  2052.          for (i = 0; i < len; i++) 
  2053.                     glutBitmapCharacter(GLUT_BITMAP_8_BY_13, string4[i]);        
  2054.          
  2055.  
  2056.          glutSwapBuffers();
  2057. }
  2058. char
  2059. inline
  2060. ItoA (int i){
  2061.  switch (i){
  2062.  case 0: return '0';break;
  2063.  case 1: return '1';break;
  2064.  case 2: return '2';break;
  2065.  case 3: return '3';break;
  2066.  case 4: return '4';break;
  2067.  case 5: return '5';break;
  2068.  case 6: return '6';break;
  2069.  case 7: return '7';break;
  2070.  case 8: return '8';break;
  2071.  case 9: return '9';break;
  2072.  }
  2073.  return 'e';
  2074. }
  2075.  
  2076. void
  2077. inline
  2078. LoadCarNum(int p){
  2079.  FILE *tmp;
  2080.  char CarFileName [15];
  2081.  char t;
  2082.  t = ItoA (p);
  2083.  strcpy (CarFileName,"CarRoute");
  2084.  strncat (CarFileName, &t,1);
  2085.  
  2086.  if ((tmp=fopen(CarFileName,"rb"))==NULL)
  2087.     printf ("CarRouteEEEEt file not opened paw!!!\n");
  2088.  fread (&MaxIndexCarLocRec[p],sizeof(int),1,tmp);
  2089.  CarLocAllocated[p] = MaxIndexCarLocRec[p];
  2090.  if ( (CarLocationRec[p] = (struct car_location*) realloc (CarLocationRec[p],CarLocAllocated[p]*sizeof (struct car_location)) ) ==NULL) 
  2091.    cout << "realloc error 134341 " << endl;
  2092.  for (i=0;i<MaxIndexCarLocRec[p];i++)
  2093.    fread (&CarLocationRec[p][i],sizeof(struct car_location),1,tmp);
  2094.  fclose(tmp);
  2095.  cout << "MaxIndexCarLocRec[p] = " << MaxIndexCarLocRec[p] << endl;
  2096. }
  2097.  
  2098. char commandLineChar[100];
  2099. int  commandLineInd = 0;
  2100. static void 
  2101. Key(unsigned char key, int x, int y)
  2102. {
  2103.     void load_configuration(char );
  2104.     void save_configurations (char );
  2105.  
  2106.     int jyu;
  2107.          switch (key) {
  2108.          case 'z':     FLAG_WHICH_KEY_NEXT = save_configuration;
  2109.              break;
  2110.          case 'h': FLAG_WHICH_KEY_NEXT = henry;
  2111.                    break;
  2112.          case 'n': FLAG_WHICH_KEY_NEXT = empty;
  2113.          case '`' :
  2114.                  if (FLAG_WHICH_KEY_NEXT == configurations){
  2115.                         load_configuration('`');
  2116.                         PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2117.                   }
  2118.                   if (FLAG_WHICH_KEY_NEXT == save_configuration){
  2119.                         save_configurations('``');
  2120.                         PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2121.                     }
  2122.                   break;
  2123.          case '~' :
  2124.                  if (FLAG_WHICH_KEY_NEXT == configurations){
  2125.                         load_configuration('~');
  2126.                         PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2127.                   }
  2128.                   if (FLAG_WHICH_KEY_NEXT == save_configuration){
  2129.                         save_configurations('~');
  2130.                         PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2131.                     }
  2132.                   break;
  2133.          case '!' :
  2134.                  if (FLAG_WHICH_KEY_NEXT == configurations){
  2135.                         load_configuration('!');
  2136.                         PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2137.                   }
  2138.                   if (FLAG_WHICH_KEY_NEXT == save_configuration){
  2139.                         save_configurations('!');
  2140.                         PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2141.                     }
  2142.                   break;
  2143.          case '@' :
  2144.                  if (FLAG_WHICH_KEY_NEXT == configurations){
  2145.                         load_configuration('@');
  2146.                         PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2147.                   }
  2148.                   if (FLAG_WHICH_KEY_NEXT == save_configuration){
  2149.                         save_configurations('@');
  2150.                         PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2151.                     }
  2152.                   break;
  2153.          case '#' :
  2154.                  if (FLAG_WHICH_KEY_NEXT == configurations){
  2155.                         load_configuration('#');
  2156.                         PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2157.                   }
  2158.                   if (FLAG_WHICH_KEY_NEXT == save_configuration){
  2159.                         save_configurations('#');
  2160.                         PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2161.                     }
  2162.                   break;
  2163.          case '$' :
  2164.                  if (FLAG_WHICH_KEY_NEXT == configurations){
  2165.                         load_configuration('$');
  2166.                         PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2167.                   }
  2168.                   if (FLAG_WHICH_KEY_NEXT == save_configuration){
  2169.                         save_configurations('$');
  2170.                         PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2171.                     }
  2172.                   break;
  2173.          case '%' :
  2174.                  if (FLAG_WHICH_KEY_NEXT == configurations){
  2175.                         load_configuration('%');
  2176.                         PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2177.                   }
  2178.                   if (FLAG_WHICH_KEY_NEXT == save_configuration){
  2179.                         save_configurations('%');
  2180.                         PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2181.                     }
  2182.                   break;
  2183.          case '^' :
  2184.                  if (FLAG_WHICH_KEY_NEXT == configurations){
  2185.                         load_configuration('^');
  2186.                         PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2187.                   }
  2188.                   if (FLAG_WHICH_KEY_NEXT == save_configuration){
  2189.                         save_configurations('^');
  2190.                         PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2191.                     }
  2192.                   break;
  2193.          case '&' :
  2194.                  if (FLAG_WHICH_KEY_NEXT == configurations){
  2195.                         load_configuration('&');
  2196.                         PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2197.                   }
  2198.                   if (FLAG_WHICH_KEY_NEXT == save_configuration){
  2199.                         save_configurations('&');
  2200.                         PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2201.                     }
  2202.                   break;
  2203.          case '(' :
  2204.                  if (FLAG_WHICH_KEY_NEXT == configurations){
  2205.                         load_configuration('(');
  2206.                         PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2207.                   }
  2208.                   if (FLAG_WHICH_KEY_NEXT == save_configuration){
  2209.                         save_configurations('(');
  2210.                         PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2211.                     }
  2212.                   break;
  2213.          case ')' :
  2214.                  if (FLAG_WHICH_KEY_NEXT == configurations){
  2215.                         load_configuration(')');
  2216.                         PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2217.                   }
  2218.                   if (FLAG_WHICH_KEY_NEXT == save_configuration){
  2219.                         save_configurations(')');
  2220.                         PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2221.                     }
  2222.                   break;
  2223.          case '-' :
  2224.                  if (FLAG_WHICH_KEY_NEXT == configurations){
  2225.                         load_configuration('-');
  2226.                         PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2227.                   }
  2228.                   if (FLAG_WHICH_KEY_NEXT == save_configuration){
  2229.                         save_configurations('-');
  2230.                         PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2231.                     }
  2232.                   break;
  2233.          case '_' :
  2234.                  if (FLAG_WHICH_KEY_NEXT == configurations){
  2235.                         load_configuration('_');
  2236.                         PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2237.                   }
  2238.                   if (FLAG_WHICH_KEY_NEXT == save_configuration){
  2239.                         save_configurations('_');
  2240.                         PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2241.                     }
  2242.                   break;
  2243.          case '+' :
  2244.                  if (FLAG_WHICH_KEY_NEXT == configurations){
  2245.                         load_configuration('+');
  2246.                         PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2247.                   }
  2248.                   if (FLAG_WHICH_KEY_NEXT == save_configuration){
  2249.                         save_configurations('+');
  2250.                         PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2251.                     }
  2252.                   break;
  2253.          case '=' :
  2254.                  if (FLAG_WHICH_KEY_NEXT == configurations){
  2255.                         load_configuration('=');
  2256.                         PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2257.                   }
  2258.                   if (FLAG_WHICH_KEY_NEXT == save_configuration){
  2259.                         save_configurations('=');
  2260.                         PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2261.                     }
  2262.                   break;
  2263.          case '{' :
  2264.                  if (FLAG_WHICH_KEY_NEXT == configurations){
  2265.                         load_configuration('{');
  2266.                         PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2267.                   }
  2268.                   if (FLAG_WHICH_KEY_NEXT == save_configuration){
  2269.                         save_configurations('{');
  2270.                         PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2271.                     }
  2272.                   break;
  2273.          case '[' :
  2274.                  if (FLAG_WHICH_KEY_NEXT == configurations){
  2275.                         load_configuration('[');
  2276.                         PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2277.                   }
  2278.                   if (FLAG_WHICH_KEY_NEXT == save_configuration){
  2279.                         save_configurations('[');
  2280.                         PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2281.                     }
  2282.                   break;
  2283.          case '}' :
  2284.                  if (FLAG_WHICH_KEY_NEXT == configurations){
  2285.                         load_configuration('}');
  2286.                         PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2287.                   }
  2288.                   if (FLAG_WHICH_KEY_NEXT == save_configuration){
  2289.                         save_configurations('}');
  2290.                         PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2291.                     }
  2292.                   break;
  2293.          case ']' :
  2294.                  if (FLAG_WHICH_KEY_NEXT == configurations){
  2295.                         load_configuration(']');
  2296.                         PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2297.                   }
  2298.                   if (FLAG_WHICH_KEY_NEXT == save_configuration){
  2299.                         save_configurations(']');
  2300.                         PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2301.                     }
  2302.                   break;
  2303. #if 0
  2304.          case 'p' :
  2305.                  if (FLAG_WHICH_KEY_NEXT == configurations){
  2306.                         load_configuration('p');
  2307.                         PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2308.                   }
  2309.                   if (FLAG_WHICH_KEY_NEXT == save_configuration){
  2310.                         save_configurations('p');
  2311.                         PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2312.                     }
  2313.                   break;
  2314.          case 'P' :
  2315.                  if (FLAG_WHICH_KEY_NEXT == configurations){
  2316.                         load_configuration('P');
  2317.                         PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2318.                   }
  2319.                   if (FLAG_WHICH_KEY_NEXT == save_configuration){
  2320.                         save_configurations('P');
  2321.                         PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2322.                     }
  2323.                   break;
  2324.          case 'c':
  2325.                     /*if (flag_motion == motion_carre1); 
  2326.                              carre1_trans = carre1_trans -0.05;
  2327.                     if (flag_motion == motion_carre2); 
  2328.                              carre2_trans = carre2_trans -0.05;
  2329.                     if (flag_motion == motion_carre3); 
  2330.                              carre3_trans = carre3_trans -0.05;*/
  2331.                     eyec.x = eye.x;
  2332.                     eyec.y = eye.y;
  2333.                     eyec.z = eye.z;
  2334.                     glutPostRedisplay();
  2335.                     break;
  2336.          case ' ': if (flag_motion_win == top_view_com)   
  2337.                      flag_motion_win = big_win_com; 
  2338.                    else
  2339.                         flag_motion_win = top_view_com;
  2340.                    break;
  2341.          case 's':  if (SHOW_LOCATION_DIRECTION_OF_LIGHTS) {
  2342.                         SHOW_LOCATION_DIRECTION_OF_LIGHTS = 0;
  2343.                         cout << "lights are hidden " << endl;
  2344.                     } else {
  2345.                         SHOW_LOCATION_DIRECTION_OF_LIGHTS = 1;
  2346.                         cout << "lights are shown" << endl;
  2347.                     }
  2348.                     break;
  2349.          case 'l': FLAG_WHICH_KEY_NEXT = lights;
  2350.                    break;
  2351.          case 'L': FLAG_WHICH_KEY_NEXT = load_car_num;
  2352.                    break;
  2353.          case 'w': FLAG_WHICH_KEY_NEXT = walk_slowly;
  2354.                    break;
  2355.          case 't': if (FLAG_WHICH_KEY_NEXT == lights)
  2356.                        FLAG_WHICH_KEY_NEXT = lights_translate;
  2357.                     break;
  2358.          case 'r': if (FLAG_WHICH_KEY_NEXT == lights)
  2359.                        FLAG_WHICH_KEY_NEXT = lights_rotate;
  2360.                     break;
  2361.          case 'R': FLAG_WHICH_KEY_NEXT = recordCarMvmt; 
  2362.                    RECORD_CAR_MVMT = 0;
  2363.                    // Write to file if RecRouteNum !=999
  2364.                    if (RecRouteNum != 999){
  2365.                         PlaySound ("WritingCoordinateToFile.wav",NULL,SND_ASYNC);
  2366.                         FILE *tmp;
  2367.                         char CarFileName [15];
  2368.                         char t;
  2369.                         t = ItoA (RecRouteNum);
  2370.                         strcpy (CarFileName,"CarRoute");
  2371.                         strncat (CarFileName, &t,1);
  2372.                         if ((tmp=fopen(CarFileName,"wb"))==NULL)
  2373.                             printf ("CarPath file not opened \n");
  2374.                         fwrite (&IndexCarLocRec[RecRouteNum],sizeof(int),1,tmp);
  2375.                         for (jyu=0;jyu<IndexCarLocRec[RecRouteNum];jyu++)
  2376.                             fwrite (&CarLocationRec[RecRouteNum][jyu],sizeof(struct car_location),1,tmp);
  2377.                         fclose(tmp);
  2378.                         cout << "IndexCarLocRec[RecRouteNum] = " << IndexCarLocRec[RecRouteNum] << endl;
  2379.                     }
  2380.                    // We are not recording any route anymore.
  2381.                    RecRouteNum =999; // The RecRouteNum is the Route Number that is being Recorde.
  2382.                                      // If RecRouteNum == 999 => we are not recording any route...
  2383.                     break;
  2384.          case '0': if (FLAG_WHICH_KEY_NEXT == lights_translate)
  2385.                        flag_motion_command = flag_move_light0; else
  2386.                    if (FLAG_WHICH_KEY_NEXT == lights_rotate)
  2387.                        flag_motion_command = flag_rotate_light0;
  2388.                    if (FLAG_WHICH_KEY_NEXT == save_configuration){
  2389.                         save_configurations('0');
  2390.                         PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2391.                     }
  2392.                     if (FLAG_WHICH_KEY_NEXT == configurations){
  2393.                         load_configuration('0');
  2394.                         PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2395.                     }
  2396.                     if (FLAG_WHICH_KEY_NEXT == load_car_num){
  2397.                        LoadCarNum(0);
  2398.                        RouteNum[0]=1; // Activates the Route num 0
  2399.                     }
  2400.                     if (FLAG_WHICH_KEY_NEXT == recordCarMvmt){
  2401.                         RECORD_CAR_MVMT = 1; // Flag to say that we are recording a route #
  2402.                         RecRouteNum = 1;  // The RecRouteNum is the Route Number that is being Recorde.
  2403.                                           // If RecRouteNum == 999 => we are not recording any route...
  2404.                         PlaySound ("ReadingCoordinateToMemory.wav",NULL,SND_ASYNC);
  2405.                     }
  2406.                     break;
  2407.          case 'G' : flag_motion = rotating_Geye;
  2408.                     PlaySound("RotatingGodsVehicleCentricEye.wav", NULL, SND_ASYNC);                     
  2409.                     break;
  2410.          case 'g' : FLAG_MOVE_GODS_EYE = 1;
  2411.              break;
  2412.          case 'v' : if ( FLAG_WHICH_KEY_NEXT == henry ) {
  2413.                         cout << "give Frequency TransVel = ";
  2414.                         cin >> TransVel;
  2415.                     }else
  2416.                     FLAG_MOVE_GODS_EYE = 2;
  2417.                     break;
  2418.          case 'V' : FLAG_MOVE_GODS_EYE = 3;
  2419.              break;
  2420.          case 'S' : FLAG_MOVE_GODS_EYE =4;
  2421.                     break;
  2422. #endif
  2423.          case 'C': FLAG_WHICH_KEY_NEXT = configurations;
  2424.                    Time = 0; // to reset Henry's oscillation to 0.
  2425.              break;
  2426.          case '1': if (FLAG_WHICH_KEY_NEXT == lights_translate)
  2427.                        flag_motion_command = flag_move_light1; else
  2428.                    if (FLAG_WHICH_KEY_NEXT == lights_rotate)
  2429.                        flag_motion_command = flag_rotate_light1; else 
  2430.                        if (FLAG_WHICH_KEY_NEXT == lights) {
  2431.                        glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
  2432.                        glEnable(GL_LIGHTING);
  2433.                        }
  2434.                     if (FLAG_WHICH_KEY_NEXT == walk_slowly){
  2435.                         WALK_SLOWLY = 0; // does not affect the rate of walking.
  2436.                         SlowIt = 1.0;
  2437.                         PlaySound ("NoSlowing.wav",NULL,SND_ASYNC); //WinUnix
  2438.                     }
  2439.                     if (FLAG_WHICH_KEY_NEXT == configurations){
  2440.                         load_configuration('1');
  2441.                         PlaySound ("configuration1.wav",NULL,SND_ASYNC); //WinUnix
  2442.                     }
  2443.                     if (FLAG_WHICH_KEY_NEXT == save_configuration){
  2444.                         save_configurations('1');
  2445.                         // PlaySound ("configuration1Saved.wav",NULL,SND_ASYNC); //WinUnix
  2446.                     }
  2447.                     if (FLAG_WHICH_KEY_NEXT == load_car_num){
  2448.                        LoadCarNum(1);
  2449.                        RouteNum[1]=1; // Activates the Route num 1
  2450.                     }
  2451.                     if (FLAG_WHICH_KEY_NEXT == recordCarMvmt){
  2452.                         RECORD_CAR_MVMT = 1; // Flag to say that we are recording a route #
  2453.                         RecRouteNum = 1;  // The RecRouteNum is the Route Number that is being Recorde.
  2454.                                           // If RecRouteNum == 999 => we are not recording any route...
  2455.                         PlaySound ("ReadingCoordinateToMemory.wav",NULL,SND_ASYNC);
  2456.                     }
  2457.                     Time = 0; // to reset Henry's oscillation to 0.
  2458.                     break;
  2459.          case '2': 
  2460.                                  Time = 0; // to reset Henry's oscillation to 0.
  2461.              if (FLAG_WHICH_KEY_NEXT == lights) {
  2462.                        glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
  2463.                        glEnable (GL_LIGHTING);
  2464.                    }
  2465.              if (FLAG_WHICH_KEY_NEXT == walk_slowly){
  2466.                     WALK_SLOWLY = 1; //start walking slower.
  2467.                     SlowIt = 2.0;
  2468.                     PlaySound ("SlowingTwice.wav",NULL,SND_ASYNC); //WinUnix
  2469.              }
  2470.              if (FLAG_WHICH_KEY_NEXT == save_configuration){
  2471.                         save_configurations('2');
  2472.                         PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2473.                     }
  2474.              if (FLAG_WHICH_KEY_NEXT == configurations){
  2475.                         load_configuration('2');
  2476.                         PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2477.                     }
  2478.              if (FLAG_WHICH_KEY_NEXT == load_car_num){
  2479.                   LoadCarNum(2);
  2480.                   RouteNum[2]=1; // Activates the Route num 2
  2481.              }
  2482.              if (FLAG_WHICH_KEY_NEXT == recordCarMvmt){
  2483.                 RECORD_CAR_MVMT = 1; // Flag to say that we are recording a route #
  2484.                 RecRouteNum = 2;  // The RecRouteNum is the Route Number that is being Recorde.
  2485.                                   // If RecRouteNum == 999 => we are not recording any route...
  2486.                 PlaySound ("ReadingCoordinateToMemory.wav",NULL,SND_ASYNC);
  2487.              }
  2488.              Time = 0; // to reset Henry's oscillation to 0.
  2489.              break;
  2490.          case '3': 
  2491.                                  Time = 0; // to reset Henry's oscillation to 0.
  2492.              if (FLAG_WHICH_KEY_NEXT == lights) {
  2493.                        glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
  2494.                        glEnable (GL_LIGHTING);
  2495.                    }
  2496.              if (FLAG_WHICH_KEY_NEXT == walk_slowly){
  2497.                     WALK_SLOWLY = 1; //start walking slower.
  2498.                     SlowIt = 3.0;
  2499.                     PlaySound ("Slowing3times.wav",NULL,SND_ASYNC); //WinUnix
  2500.              }
  2501.              if (FLAG_WHICH_KEY_NEXT == save_configuration){
  2502.                         save_configurations('3');
  2503.                         PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2504.                     }
  2505.              if (FLAG_WHICH_KEY_NEXT == configurations){
  2506.                         load_configuration('3');
  2507.                         PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2508.                     }
  2509.              if (FLAG_WHICH_KEY_NEXT == recordCarMvmt){
  2510.                 RECORD_CAR_MVMT = 1; // Flag to say that we are recording a route #
  2511.                 RecRouteNum = 3;  // The RecRouteNum is the Route Number that is being Recorde.
  2512.                                   // If RecRouteNum == 999 => we are not recording any route...
  2513.                 PlaySound ("ReadingCoordinateToMemory.wav",NULL,SND_ASYNC);
  2514.              }
  2515.              if (FLAG_WHICH_KEY_NEXT == load_car_num){
  2516.                   LoadCarNum(3);
  2517.                   RouteNum[3]=3; // Activates the Route num 3
  2518.              }
  2519.              Time = 0; // to reset Henry's oscillation to 0.
  2520.              break;
  2521.          case '4': 
  2522.                                  Time = 0; // to reset Henry's oscillation to 0.
  2523.              if (FLAG_WHICH_KEY_NEXT == lights) {
  2524.                        glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
  2525.                        glEnable (GL_LIGHTING);
  2526.                    }
  2527.              if (FLAG_WHICH_KEY_NEXT == walk_slowly){
  2528.                     WALK_SLOWLY = 1; //start walking slower.
  2529.                     PlaySound ("Slowing4times.wav",NULL,SND_ASYNC); //WinUnix
  2530.                     SlowIt = 4.0;
  2531.              }
  2532.              if (FLAG_WHICH_KEY_NEXT == save_configuration){
  2533.                         save_configurations('4');
  2534.                         PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2535.                     }
  2536.               if (FLAG_WHICH_KEY_NEXT == configurations){
  2537.                         load_configuration('4');
  2538.                         PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2539.                     }
  2540.              if (FLAG_WHICH_KEY_NEXT == load_car_num){
  2541.                   LoadCarNum(4);
  2542.                   RouteNum[4]=1; // Activates the Route num 4
  2543.              }
  2544.              if (FLAG_WHICH_KEY_NEXT == recordCarMvmt){
  2545.                 RECORD_CAR_MVMT = 1; // Flag to say that we are recording a route #
  2546.                 RecRouteNum = 4;  // The RecRouteNum is the Route Number that is being Recorde.
  2547.                                   // If RecRouteNum == 999 => we are not recording any route...
  2548.                 PlaySound ("ReadingCoordinateToMemory.wav",NULL,SND_ASYNC);
  2549.              }
  2550.              break;
  2551.          case '5': 
  2552.                                  Time = 0; // to reset Henry's oscillation to 0.
  2553.              if (FLAG_WHICH_KEY_NEXT == lights) {
  2554.                        glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
  2555.                        glEnable (GL_LIGHTING);
  2556.                    }
  2557.              if (FLAG_WHICH_KEY_NEXT == walk_slowly){
  2558.                     WALK_SLOWLY = 1; //start walking slower.
  2559.                     SlowIt = 5.0;
  2560.                     PlaySound ("Slowing5times.wav",NULL,SND_ASYNC); //WinUnix
  2561.              }
  2562.              if (FLAG_WHICH_KEY_NEXT == save_configuration){
  2563.                         save_configurations('5');
  2564.                         PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2565.                     }
  2566.              if (FLAG_WHICH_KEY_NEXT == configurations){
  2567.                         load_configuration('5');
  2568.                         PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2569.                     }
  2570.              if (FLAG_WHICH_KEY_NEXT == load_car_num){
  2571.                   LoadCarNum(5);
  2572.                   RouteNum[5]=5; // Activates the Route num 5
  2573.              }
  2574.              if (FLAG_WHICH_KEY_NEXT == recordCarMvmt){
  2575.                 RECORD_CAR_MVMT = 1; // Flag to say that we are recording a route #
  2576.                 RecRouteNum = 5;  // The RecRouteNum is the Route Number that is being Recorde.
  2577.                                   // If RecRouteNum == 999 => we are not recording any route...
  2578.                 PlaySound ("ReadingCoordinateToMemory.wav",NULL,SND_ASYNC);
  2579.              }
  2580.              break;
  2581.          case '6': 
  2582.                                  Time = 0; // to reset Henry's oscillation to 0.
  2583.              if (FLAG_WHICH_KEY_NEXT == lights) {
  2584.                        glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
  2585.                        glEnable (GL_LIGHTING);
  2586.                    }
  2587.              if (FLAG_WHICH_KEY_NEXT == walk_slowly){
  2588.                     WALK_SLOWLY = 1; //start walking slower.
  2589.                     SlowIt = 6.0;
  2590.                     PlaySound ("Slowing6times.wav",NULL,SND_ASYNC); //WinUnix
  2591.              }
  2592.              if (FLAG_WHICH_KEY_NEXT == save_configuration){
  2593.                         save_configurations('6');
  2594.                         PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2595.                     }
  2596.              if (FLAG_WHICH_KEY_NEXT == configurations){
  2597.                         load_configuration('6');
  2598.                         PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2599.                     }
  2600.              if (FLAG_WHICH_KEY_NEXT == load_car_num){
  2601.                   LoadCarNum(6);
  2602.                   RouteNum[6]=1; // Activates the Route num 6
  2603.              }
  2604.              if (FLAG_WHICH_KEY_NEXT == recordCarMvmt){
  2605.                 RECORD_CAR_MVMT = 1; // Flag to say that we are recording a route #
  2606.                 RecRouteNum = 6;  // The RecRouteNum is the Route Number that is being Recorde.
  2607.                                   // If RecRouteNum == 999 => we are not recording any route...
  2608.                 PlaySound ("ReadingCoordinateToMemory.wav",NULL,SND_ASYNC);
  2609.              }
  2610.              break;
  2611.          case '7': 
  2612.                                  Time = 0; // to reset Henry's oscillation to 0.
  2613.              if (FLAG_WHICH_KEY_NEXT == lights) {
  2614.                        glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
  2615.                        glEnable (GL_LIGHTING);
  2616.                    }
  2617.              if (FLAG_WHICH_KEY_NEXT == walk_slowly){
  2618.                     WALK_SLOWLY = 1; //start walking slower.
  2619.                     SlowIt = 7.0;
  2620.                     PlaySound ("Slowing7times.wav",NULL,SND_ASYNC); //WinUnix
  2621.              }
  2622.              if (FLAG_WHICH_KEY_NEXT == save_configuration){
  2623.                         save_configurations('7');
  2624.                         PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2625.                     }
  2626.              if (FLAG_WHICH_KEY_NEXT == configurations){
  2627.                         load_configuration('7');
  2628.                         PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2629.                     }
  2630.              if (FLAG_WHICH_KEY_NEXT == load_car_num){
  2631.                   LoadCarNum(7);
  2632.                   RouteNum[7]=1; // Activates the Route num 7
  2633.              }
  2634.              if (FLAG_WHICH_KEY_NEXT == recordCarMvmt){
  2635.                 RECORD_CAR_MVMT = 1; // Flag to say that we are recording a route #
  2636.                 RecRouteNum = 7;  // The RecRouteNum is the Route Number that is being Recorde.
  2637.                                   // If RecRouteNum == 999 => we are not recording any route...
  2638.                 PlaySound ("ReadingCoordinateToMemory.wav",NULL,SND_ASYNC);
  2639.              }
  2640.              break;
  2641.          case '8': 
  2642.                                  Time = 0; // to reset Henry's oscillation to 0.
  2643.              if (FLAG_WHICH_KEY_NEXT == lights) {
  2644.                        glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
  2645.                        glEnable (GL_LIGHTING);
  2646.                    }
  2647.              if (FLAG_WHICH_KEY_NEXT == walk_slowly){
  2648.                     WALK_SLOWLY = 1; //start walking slower.
  2649.                     SlowIt = 8.0;
  2650.                     PlaySound ("Slowing8times.wav",NULL,SND_ASYNC); //WinUnix
  2651.              }
  2652.              if (FLAG_WHICH_KEY_NEXT == save_configuration){
  2653.                         save_configurations('8');
  2654.                         PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2655.                     }
  2656.              if (FLAG_WHICH_KEY_NEXT == configurations){
  2657.                         load_configuration('8');
  2658.                         PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2659.                     }
  2660.              if (FLAG_WHICH_KEY_NEXT == load_car_num){
  2661.                   LoadCarNum(8);
  2662.                   RouteNum[8]=1; // Activates the Route num 8
  2663.              }
  2664.              if (FLAG_WHICH_KEY_NEXT == recordCarMvmt){
  2665.                 RECORD_CAR_MVMT = 1; // Flag to say that we are recording a route #
  2666.                 RecRouteNum = 8;  // The RecRouteNum is the Route Number that is being Recorde.
  2667.                                   // If RecRouteNum == 999 => we are not recording any route...
  2668.                 PlaySound ("ReadingCoordinateToMemory.wav",NULL,SND_ASYNC);
  2669.              }
  2670.              break;
  2671.          case '9': 
  2672.                                  Time = 0; // to reset Henry's oscillation to 0.
  2673.              if (FLAG_WHICH_KEY_NEXT == lights) {
  2674.                        glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
  2675.                        glEnable (GL_LIGHTING);
  2676.                    }
  2677.              if (FLAG_WHICH_KEY_NEXT == walk_slowly){
  2678.                     WALK_SLOWLY = 1; //start walking slower.
  2679.                     SlowIt = 35.0;
  2680.                     PlaySound ("Slowing9times.wav",NULL,SND_ASYNC); //WinUnix
  2681.              }
  2682.              if (FLAG_WHICH_KEY_NEXT == save_configuration){
  2683.                         save_configurations('9');
  2684.                         PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2685.                     }
  2686.              if (FLAG_WHICH_KEY_NEXT == configurations){
  2687.                         load_configuration('9');
  2688.                         PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
  2689.                     }
  2690.              if (FLAG_WHICH_KEY_NEXT == load_car_num){
  2691.                   LoadCarNum(9);
  2692.                   RouteNum[9]=1; // Activates the route num 9.
  2693.              }
  2694.              if (FLAG_WHICH_KEY_NEXT == recordCarMvmt){
  2695.                 RECORD_CAR_MVMT = 1; // Flag to say that we are recording a route #
  2696.                 RecRouteNum = 9;  // The RecRouteNum is the Route Number that is being Recorde.
  2697.                                   // If RecRouteNum == 999 => we are not recording any route...
  2698.                 PlaySound ("ReadingCoordinateToMemory.wav",NULL,SND_ASYNC);
  2699.              }
  2700.              break;
  2701.          case 27:
  2702.                     exit(0);
  2703.          }
  2704.  
  2705. }
  2706.  
  2707. static void 
  2708. SpecialKey(int key, int x, int y)
  2709. {
  2710.          switch (key) {
  2711.          case GLUT_KEY_UP:
  2712.                     DRAW_CARRE1 = 1;
  2713.                     carre1 = carre1 + (deltaz/100);
  2714.                     glutPostRedisplay();
  2715.                     break;
  2716.          case GLUT_KEY_DOWN:
  2717.                     DRAW_CARRE1 = 1;
  2718.                     carre1 = carre1 - (deltaz/100);
  2719.                     glutPostRedisplay();
  2720.                     break;
  2721.          case GLUT_KEY_LEFT:
  2722.                     carre1_trans = carre1_trans-0.03;
  2723.                     glutPostRedisplay();
  2724.                     break;
  2725.          case GLUT_KEY_RIGHT:
  2726.                     carre1_trans = carre1_trans+0.03;
  2727.                     glutPostRedisplay();
  2728.                     break;
  2729.          case GLUT_KEY_INSERT: // Expand carre.
  2730.                     if (expand_carre1) 
  2731.                              expand_carre1 = 0;
  2732.                     else
  2733.                              expand_carre1 = 1;
  2734.                     glutPostRedisplay();
  2735.                     break;
  2736.          }
  2737. }
  2738.  
  2739. /* Keyboard menu:
  2740.                            // LIGHTS
  2741. s:  shows and hides (Toggles) the lights. It does not turn them on 
  2742.     and off, rather it only shows their location / or orientation.
  2743. z# : Saves configuration number #.
  2744.  
  2745. C# : Puts us in Configuration number #.
  2746.  
  2747. G  : rotates Rotating Gods Vehicle Centric Eye (symbolic or non symbolic).
  2748. g  : Move and rotate God's eye camera.          (on mirror 0)
  2749. v  : Switches on the vehicle centric display.   (on mirror 0)
  2750. V  : Switches on the Vehicle symbolic gods eye. (on mirror 0)
  2751. S  : Switches to the Green Sensors gods eye.
  2752.  
  2753. lt0: Lights Translate 0 Translates light number Zero towards or away
  2754.      from the Center_Of_Rot_Of_Lights which is a code variable.
  2755.  
  2756. lt1: Lights Translate 1 Translates light number One towards or away
  2757.      from the Center_Of_Rot_Of_Lights which is a code variable.
  2758.  
  2759. lr0: Lights rotate 0 rotates light number Zero around
  2760.      the Center_Of_Rot_Of_Lights which is a code variable.
  2761.  
  2762. lr1: Lights rotate 1 rotates light number One around
  2763.      the Center_Of_Rot_Of_Lights which is a code variable.
  2764.  
  2765. l1 : turns glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
  2766. l2 : turns glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
  2767.  
  2768. li : makes the intensity of the light more or less.
  2769.  
  2770. L#     : Loads CarRoot # into memory and Activates rendering it.
  2771. R#    R: Record Route #. Then pressing R again writes it on disk, and stop
  2772.          Recording
  2773. d  : Toggles Dom mode with Normal mode.
  2774. f  : Toggles between fixing the lights t the camera or to the scene.
  2775. w?  : Slows the translationS ? times.
  2776.  
  2777. c   : Shows the car wherever it is...
  2778. n   : resets the FLAG_WHICH_NEXT_KEY TO nothing.
  2779.  
  2780. q   : gives you just a dummy variable that you can change interactively using the middle mouse buuton
  2781.       This dummy variable is used now for making the angle of the camera looking at the dome bigger or smaller
  2782. Q   : Same as q but makes the camera cames towards or away from the dome. (dummy variable carre2.)
  2783. Joystick interface.
  2784.  
  2785. Stick button right: walk in the city.
  2786. Stick button right down: Adjust car.
  2787. Stick button left : Drive.
  2788.  
  2789.  
  2790.   */
  2791.