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

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