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 >
Wrap
C/C++ Source or Header
|
2000-04-18
|
93KB
|
2,758 lines
#define DimX 400
#define DimY 150
#define DimZ 400
#include "orb.h"
OrbHandle MyOrbHandle;
struct Virtual_Espace{
char FULL;
//struct point *N;
} ;
void
rectangle(int x1,int y1,int x2,int y2, float r, float g, float b, rect *re) //frectangle
// x1 , y1 are the upper left corner
// x2 , y2 are the low right corner
{
glBegin(GL_POLYGON);
glColor3f (r,g,b);
glVertex2f(x1 , y1 );
glVertex2f(x1 , y2 );
glVertex2f(x2 , y2 );
glVertex2f(x2 , y1 );
glEnd();
re->xmin = x1;
re->xmax = x2;
re->ymin = y1;
re->ymax = y2;
}
void
scrollbar(int x,int y,int w,scr_bar *s) //fscrollbar
// (x,y) is the upper left corner
// w is the width of the scroll bar.
// The scrollbar is 88 pixel long
{
// Create a srall bar.
// Drawing the green squar up
glBegin(GL_POLYGON);
glColor3f (0,1,0);
glVertex2f(x ,y );
glVertex2f(x ,y+10);
glVertex2f(x+w,y+10);
glVertex2f(x+w,y );
glEnd();
s->x_g_min = x;
s->x_g_max = x+w;
s->y_g_min = y;
s->y_g_max = y+10;
// Drawing the red squar down
glBegin(GL_POLYGON);
glColor3f (1,0,0);
glVertex2f(x ,y+78);
glVertex2f(x ,y+88);
glVertex2f(x+w,y+88);
glVertex2f(x+w,y+78);
glEnd();
s->x_r_min = x;
s->x_r_max = x+w;
s->y_r_min = y+78;
s->y_r_max = y+88;
// Drawing upper triangle
glBegin (GL_TRIANGLES);
glColor3f (0.7f,0.6f,0.5f);
glVertex2f(x+w/2, y+12);
glVertex2f(x , y+22);
glVertex2f(x+w , y+22);
glEnd();
s->x_ht_min = x;
s->x_ht_max = x+w;
s->y_ht_min = y+12;
s->y_ht_max = y+22;
// Drawing lower triangle
glBegin (GL_TRIANGLES);
glColor3f (0.7f,0.6f,0.5f);
glVertex2f(x ,y+66);
glVertex2f(x+w/2,y+76);
glVertex2f(x+w ,y+66);
glEnd();
s->x_lt_min = x;
s->x_lt_max = x+w;
s->y_lt_min = y+66;
s->y_lt_max = y+76;
// Drawing the middle rectangle.
glBegin (GL_POLYGON);
glColor3f (0.7f,0.9f,0.6f);
glVertex2f(x ,y+24 );
glVertex2f(x ,y+24+40);
glVertex2f(x+w ,y+24+40);
glVertex2f(x+w ,y+24 );
glEnd();
s->x_m_min = x;
s->x_m_max = x+w;
s->y_m_min = y+24;
s->y_m_max = y+64;
}
void
draw_carre1() //fdraw_carre1
{
glEnable (GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// glDepthMask(GL_FALSE);
// glMateriali (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE,1);
double z = zmin+carre1;
if (expand_carre1){
glBegin (GL_POLYGON);
glColor4f (0.0f, 0.0f, 0.9f,carre1_trans);
// glShadeModel (GL_FLAT);
glVertex3f (xmin_e,ymin_e,z);
glVertex3f (xmax_e,ymin_e,z);
glVertex3f (xmax_e,ymax_e,z);
glVertex3f (xmin_e,ymax_e,z);
glEnd();
glBegin (GL_POLYGON);
glColor4f (0.0f, 0.0f, 0.9f,carre1_trans);
glVertex3f (xmin_e,ymax_e,z);
glVertex3f (xmax_e,ymax_e,z);
glVertex3f (xmax_e,ymin_e,z);
glVertex3f (xmin_e,ymin_e,z);
glEnd();
}
else{
glBegin (GL_POLYGON);
glColor4f (0, 0, 0.9f,carre1_trans);
glVertex3f (xmin,ymin,z);
glVertex3f (xmax,ymin,z);
glVertex3f (xmax,ymax,z);
glVertex3f (xmin,ymax,z);
glEnd();
glBegin (GL_POLYGON);
glColor4f (0, 0, 0.9f,carre1_trans);
glVertex3f (xmin,ymax,z);
glVertex3f (xmax,ymax,z);
glVertex3f (xmax,ymin,z);
glVertex3f (xmin,ymin,z);
glEnd();
}
glDisable(GL_BLEND);
// glDepthMask(GL_TRUE);
}
void
draw_carre2() //fdraw_carre2
{
glEnable (GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// glDepthMask(GL_FALSE);
double y = ymin+carre2;
if (expand_carre2){
glBegin (GL_POLYGON);
glColor4f (0, 0.9f, 0.0f,carre2_trans);
glVertex3f (xmin_e,y,zmin_e);
glVertex3f (xmax_e,y,zmin_e);
glVertex3f (xmax_e,y,zmax_e);
glVertex3f (xmin_e,y,zmax_e);
glEnd();
glBegin (GL_POLYGON);
glColor4f (0, 0.9f, 0.0f,carre1_trans);
glVertex3f (xmin_e,y,zmax_e);
glVertex3f (xmax_e,y,zmax_e);
glVertex3f (xmax_e,y,zmin_e);
glVertex3f (xmin_e,y,zmin_e);
glEnd();
}
else{
glBegin (GL_POLYGON);
glColor4f (0, 0.9f, 0.0f,carre1_trans);
glVertex3f (xmin ,y,zmin );
glVertex3f (xmax ,y,zmin );
glVertex3f (xmax ,y,zmax );
glVertex3f (xmin ,y,zmax );
glEnd();
glBegin (GL_POLYGON);
glColor4f (0, 0.9f, 0.0f,carre1_trans);
glVertex3f (xmin ,y,zmax );
glVertex3f (xmax ,y,zmax );
glVertex3f (xmax ,y,zmin );
glVertex3f (xmin ,y,zmin );
glEnd();
}
glDisable(GL_BLEND);
// glDepthMask(GL_TRUE);
}
void
draw_carre3() //fdraw_carre3
{
glEnable (GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// glDepthMask(GL_FALSE);
double x = xmin+carre3;
if (expand_carre3){
glBegin (GL_POLYGON);
glColor4f (0.9f, 0.0f, 0.0f,carre3_trans);
glVertex3f (x,ymin_e,zmax_e);
glVertex3f (x,ymin_e,zmin_e);
glVertex3f (x,ymax_e,zmin_e);
glVertex3f (x,ymax_e,zmax_e);
glEnd();
glBegin (GL_POLYGON);
glColor4f (0.9f, 0, 0.0f,carre3_trans);
glVertex3f (x,ymax_e,zmax_e);
glVertex3f (x,ymax_e,zmin_e);
glVertex3f (x,ymin_e,zmin_e);
glVertex3f (x,ymin_e,zmax_e);
glEnd();
}
else{
glBegin (GL_POLYGON);
glColor4f (0.9f, 0.0f, 0.0f,carre3_trans);
glVertex3f (x,ymin,zmax);
glVertex3f (x,ymin,zmin);
glVertex3f (x,ymax,zmin);
glVertex3f (x,ymax,zmax);
glEnd();
glBegin (GL_POLYGON);
glColor4f (0.9f, 0, 0.0f,carre3_trans);
glVertex3f (x,ymax,zmax);
glVertex3f (x,ymax,zmin);
glVertex3f (x,ymin,zmin);
glVertex3f (x,ymin,zmax);
glEnd();
}
glDisable(GL_BLEND);
// glDepthMask(GL_TRUE);
}
inline void
draw_commande_de_bord() //fdraw_commande_de
// Draws the commande de bord Glut Menu.
{
// Draw The Vertical Control Menu.
glDisable (GL_LIGHTING);
// Set View Port.
glViewport (0,0,CDW,H);
// Set Projection Matrix
glMatrixMode(GL_PROJECTION);/* set up projection transform */
glLoadIdentity();
glOrtho (0,CDW, H,0, -1,1);
// Set ModelView Matrix.
glMatrixMode (GL_MODELVIEW);
glLoadIdentity();
// Draw Menu.
glBegin (GL_POLYGON);
glColor3f (0.25f,0.2f,0.1f);
glVertex3f (0 ,H,-0.5);
glColor3f (0.25f,0.2f,0.1f);
glVertex3f (CDW,H,-0.5);
glColor3f (0.3f,0.1f,0.15f);
glVertex3f (CDW, 0.0f,-0.5f);
glColor3f (0.3f, 0.1f,0.15f);
glVertex3f(0.0f, 0.0f,-0.5f);
glEnd();
// writing on the window characters Blue -->X...
int i;
glColor3f (0.75f,0.75f,1.0f);
glRasterPos3f(0,10,0.5f);
int len;
len = (int) strlen(string3);
for (i = 0; i < len; i++)
glutBitmapCharacter(GLUT_BITMAP_8_BY_13, string3[i]);
glColor3f (0.75f,1.0f,0.75f);
glRasterPos3f(0,20,0.5f);
len = (int) strlen(string2);
for (i = 0; i < len; i++)
glutBitmapCharacter(GLUT_BITMAP_8_BY_13, string2[i]);
glColor3f (1.0f,0.75f,0.75f);
glRasterPos3f(0,30,0.5);
len = (int) strlen(string1);
for (i = 0; i < len; i++)
glutBitmapCharacter(GLUT_BITMAP_8_BY_13, string1[i]);
// Drawing the scrollbar for carre1.
scrollbar (10,40,20,m1_expand);
scrollbar (40,40,20,top_expand);
scrollbar (70,40,20,sb_c3);
// Drawing rectanle Stereo_Zoom
rectangle (10,130,90,143,0.9f,0.3f,0.7f,stereo_zoom_rect);
glColor3f (0,0,0);
glRasterPos3f(10,142,0.5);
len = (int) strlen(string4);
for (i = 0; i < len; i++)
glutBitmapCharacter(GLUT_BITMAP_8_BY_13, string4[i]);
// Drawing rectanle Scaling
rectangle (10,145,90,158,0.7f,0.9f,0.4f,scaling_rect);
glColor3f (0,0,0);
glRasterPos3f(10,157,0.5);
len = (int) strlen(string5);
for (i = 0; i < len; i++)
glutBitmapCharacter(GLUT_BITMAP_8_BY_13, string5[i]);
// Drawing rectanle Animation.
rectangle (10,160,90,173,0.7f,0.9f,0.4f,animation_rect);
glColor3f (0,0,0);
glRasterPos3f(10,172,0.5);
len = (int) strlen(string6);
for (i = 0; i < len; i++)
glutBitmapCharacter(GLUT_BITMAP_8_BY_13, string6[i]);
// Drawing rectanle Vertical Adjustment..
rectangle (10,175,90,188,0.9f,0.9f,0.4f,vertical_adj_rect);
glColor3f (0,0,0);
glRasterPos3f(10,187,0.5);
len = (int) strlen(string7);
for (i = 0; i < len; i++)
glutBitmapCharacter(GLUT_BITMAP_8_BY_13, string7[i]);
// Drawing rectanle Color mapping...
rectangle (10,191,90,204,0.9f,0.3f,0.4f,color_rect);
glColor3f (0.0f,0.0f,0.0f);
glRasterPos3f(10,203,0.5f);
len = (int) strlen(string8);
for (i = 0; i < len; i++)
glutBitmapCharacter(GLUT_BITMAP_8_BY_13, string8[i]);
// Drawing rectanle change pt_size...
rectangle (10,207,90,220,0.5f,0.3f,0.8f,pt_size_rect);
glColor3f (0,0,0);
glRasterPos3f(10,219,0.5f);
len = (int) strlen(string9);
for (i = 0; i < len; i++)
glutBitmapCharacter(GLUT_BITMAP_8_BY_13, string9[i]);
// Drawing rectanle Mirror translate
rectangle (10,223,90,236,0.1f,0.6f,0.5f,mirror_translate_rect);
glColor3f (0,0,0);
glRasterPos3f(10,236,0.5);
len = (int) strlen(string10);
for (i = 0; i < len; i++)
glutBitmapCharacter(GLUT_BITMAP_8_BY_13, string10[i]);
// Drawing rectanle Mirror translate
rectangle (10,239,90,252,0.3f,0.1f,0.9f,mirror_translateZ_rect);
glColor3f (0,0,0);
glRasterPos3f(10,252,0.5);
len = (int) strlen(string11);
for (i = 0; i < len; i++)
glutBitmapCharacter(GLUT_BITMAP_8_BY_13, string11[i]);
// Drawing rectanle top_view_comm
rectangle (10,255,90,268,0.6f,0.0f,0.0f,top_view_comm);
glColor3f (0.0f,0.0f,0.6f);
glRasterPos3f(10,268,0.5);
len = (int) strlen(string11);
for (i = 0; i < len; i++)
glutBitmapCharacter(GLUT_BITMAP_8_BY_13, string12[i]);
// Drawing rectanle big_win_comm
rectangle (10,271,90,284,0.6f,0.0f,0.2f,big_win_comm);
glColor3f (0,0.5,0);
glRasterPos3f(10,284,0.5);
len = (int) strlen(string13);
for (i = 0; i < len; i++)
glutBitmapCharacter(GLUT_BITMAP_8_BY_13, string13[i]);
if (!FLAG_TOGGLE_MENU1) glDisable(GL_LIGHTING);
// Drawing rectanle Mirror rotate
rectangle (10,287,90,300,0.5,0.5,0.0,mirror_rotate_rect);
glColor3f (1.0,0,0);
glRasterPos3f(10,300,0.5);
len = (int) strlen(string14);
for (i = 0; i < len; i++)
glutBitmapCharacter(GLUT_BITMAP_8_BY_13, string14[i]);
// Drawing rectanle Zoom y.
rectangle (10,303,90,316,0.2f,0.5f,0.2f,zoom_y_rect);
glColor3f (1.0,0,1.0);
glRasterPos3f(10,316,0.5);
len = (int) strlen(string15);
for (i = 0; i < len; i++)
glutBitmapCharacter(GLUT_BITMAP_8_BY_13, string15[i]);
char string_zoomx[10];
char buffer[10];
strcpy (string_zoomx,"X:");
// strcat (string_zoomx,itoa( LEFT, buffer, 10 )); //WinUnix just comment this for now...
glColor3f (0.75f,0.75f,0.8f);
glRasterPos3f(0,400,0.5f);
len = (int) strlen(string_zoomx);
for (i = 0; i < len; i++)
glutBitmapCharacter(GLUT_BITMAP_8_BY_13, string_zoomx[i]);
if (!FLAG_TOGGLE_MENU1) glDisable(GL_LIGHTING);
}
inline void
// looks where you did hit the mous on the commande_de_bord and sets accordingly the flag.
commande_de_bord(int x, int y) //fcommand_de_bord
{
void redraw();
void animation_window2();
// if you are in the green square one, expand mirror1 in the x direction.
if (x>m1_expand->x_g_min && x<m1_expand->x_g_max // if you are in the green square.
&& y>m1_expand->y_g_min && y<m1_expand->y_g_max){
flag_motion_command = flag_expand_mirror1_x;
}
// if you are in the red square one, expand mirror1 in the y direction.
if (x>m1_expand->x_r_min && x<m1_expand->x_r_max
&& y>m1_expand->y_r_min && y<m1_expand->y_r_max)
flag_motion_command = flag_expand_mirror1_y;
// if you are in the middle square one, expand mirror1 in the y direction.
if (x>m1_expand->x_m_min && x<m1_expand->x_m_max
&& y>m1_expand->y_m_min && y<m1_expand->y_m_max)
flag_motion_command = flag_expand_mirror1_xy;
// if you are in the middle square one, expand mirror1 in the y direction.
if (x>top_expand->x_m_min && x<top_expand->x_m_max
&& y>top_expand->y_m_min && y<top_expand->y_m_max)
flag_motion_command = flag_top_expand_xy;
/* // if... draw the transparent carre2.
if (x>sb_c2->x_g_min && x<sb_c2->x_g_max
&& y>sb_c2->y_g_min && y<sb_c2->y_g_max){
DRAW_CARRE2 = 1;
if (expand_carre2)
expand_carre2 = 0;
else
expand_carre2 = 1;
flag_motion_command = motion_carre2;
}*/
// if... DO NOT draw the transparent carre2.
/* if (x>sb_c2->x_r_min && x<sb_c2->x_r_max &&
y>sb_c2->y_r_min && y<sb_c2->y_r_max)
DRAW_CARRE2 = 0; */
// if... draw the transparent carre3.
if (x>sb_c3->x_g_min && x<sb_c3->x_g_max
&& y>sb_c3->y_g_min && y<sb_c3->y_g_max){
DRAW_CARRE3 = 1;
if (expand_carre3)
expand_carre3 = 0;
else
expand_carre3 = 1;
flag_motion_command = motion_carre3;
}
// if... DO NOT draw the transparent carre3.
if (x>sb_c3->x_r_min && x<sb_c3->x_r_max
&& y>sb_c3->y_r_min && y<sb_c3->y_r_max)
DRAW_CARRE3 = 0;
// if... Baseline_zoom = stereo_zoom
if (x > stereo_zoom_rect->xmin && x < stereo_zoom_rect->xmax &&
y > stereo_zoom_rect->ymin && y < stereo_zoom_rect->ymax )
flag_motion_command = baseline_zoom;
// if... scaling = 3D Zoom
if (x > scaling_rect->xmin && x < scaling_rect->xmax &&
y > scaling_rect->ymin && y < scaling_rect->ymax )
flag_motion_command = scaling;
// if... Animation
if (x > animation_rect->xmin && x < animation_rect->xmax &&
y > animation_rect->ymin && y < animation_rect->ymax )
animation_window2();
// if... vertical_adj
if (x > vertical_adj_rect->xmin && x < vertical_adj_rect->xmax &&
y > vertical_adj_rect->ymin && y < vertical_adj_rect->ymax )
flag_motion_command = vertical_adj;
// if... translate_mirror
if (x > mirror_translate_rect->xmin && x < mirror_translate_rect->xmax &&
y > mirror_translate_rect->ymin && y < mirror_translate_rect->ymax )
flag_motion_command = mirror_translate;
// if... translate_mirrorZ
if (x > mirror_translateZ_rect->xmin && x < mirror_translateZ_rect->xmax &&
y > mirror_translateZ_rect->ymin && y < mirror_translateZ_rect->ymax )
flag_motion_command = mirror_translateZ;
// if... translate_mirrorZ
if (x > top_view_comm->xmin && x < top_view_comm->xmax &&
y > top_view_comm->ymin && y < top_view_comm->ymax )
flag_motion_win = top_view_com;
// if... translate_mirrorZ
if (x > big_win_comm->xmin && x < big_win_comm->xmax &&
y > big_win_comm->ymin && y < big_win_comm->ymax )
flag_motion_win = big_win_com;
// if... rotate_mirror
if (x > mirror_rotate_rect->xmin && x < mirror_rotate_rect->xmax &&
y > mirror_rotate_rect->ymin && y < mirror_rotate_rect->ymax )
flag_motion_command = flag_mirror_rotate;
//if zooming y:
if (x > zoom_y_rect->xmin && x < zoom_y_rect->xmax &&
y > zoom_y_rect->ymin && y < zoom_y_rect->ymax )
flag_motion_command = flag_zoom_y;
redraw();
}
void
animation_window2() //fanimation_window
{
void draw_elevator();
void myReshape2(int, int);
void mouse2(int, int, int, int);
void motion2(int, int);
cout << "Animation window activated" << endl;
// glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH | GLUT_MULTISAMPLE | GLUT_STEREO);
// glutCreateSubWindow (win, 0,0,150,H);
glutCreateWindow("a second window");
glutPositionWindow(0,175);
glutReshapeWindow (90,350);
glutDisplayFunc(draw_elevator);
//gfxinit();
glutReshapeFunc(myReshape2);
glutMouseFunc(mouse2);
glutMotionFunc(motion2);
// glutPassiveMotionFunc(passive_motion);
// create_menus();
}
void
mouse(int button, int state, int x, int y) //fmouse
{
// cout << x << " " << y << endl; // this prooves that the upper-left corner is the (0,0).
// if button down
if (button == GLUT_MIDDLE_BUTTON && state == GLUT_DOWN ) {
// if commande board exist and mouse in it
if (viewport && x<CDW) {
commande_de_bord(x,y);
}
// if y>150 or viewport do not exist
else{
beginx = x;
beginy = y;
APPLY_MOUSE_MOTION = 1;
flag_motion = flag_motion_command;
}
}
else {
// Translation / Rotation
if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN) {
APPLY_MOUSE_MOTION = 1;
if (flag_motion != rotating_Geye)
flag_motion = rotating;
beginx = x;
beginy = y;
if(glutGetModifiers() & GLUT_ACTIVE_SHIFT) {
flag_motion = translating;
}
if(glutGetModifiers() & GLUT_ACTIVE_CTRL) {
flag_motion = translatingz;
}
}
}
// if button up
if (state == GLUT_UP) {
APPLY_MOUSE_MOTION =0;
}
/* translating = rotating =scaling = baseline_zoom = 0;
DRAW_CARRE1 = DRAW_CARRE2 = DRAW_CARRE3 = 0; */
}
void
mouse2(int button, int state, int x, int y) //fmouse
{
float thresh2;
void draw_elevator();
void redraw();
// if left button down highlight some points
if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN) {
thresh= (var_animation_min - var_animation_max) * (H2-y) / H2 + var_animation_max;
Y = y;
draw_elevator();
glutSetWindow(win);
// highlightint points in the band
if (flag_elevator == bandflag){
// Recompiling the list.
glNewList(28, GL_COMPILE_AND_EXECUTE);
thresh2 = thresh + band;
glPointSize(pt_size);
glBegin(GL_POINTS);
for (i=0; i<dim[0]; i=i+fraction){
if (var_animation[i] < thresh && var_animation[i] > thresh2 ) {
glColor3f (cxx[i], cyy[i], czz[i]);
glVertex3f(xc[i],yc[i],zc[i]);
}
}
glEnd();
glPointSize(pt_size+2);
glBegin(GL_POINTS);
for (i=0; i<dim[0]; i=i+fraction){
if (var_animation[i] >= thresh && var_animation[i] <= thresh2 ) {
glColor3f (cxx[i], cyy[i], czz[i]);
glVertex3f(xc[i],yc[i],zc[i]);
}
}
glEnd();
}
else {
// Highlighting point in the upper or lower part of the elevator.
glNewList(28, GL_COMPILE_AND_EXECUTE);
if (flag_elevator == upp)
glPointSize (pt_size);
else if (flag_elevator == down)
glPointSize (pt_size+2);
glBegin(GL_POINTS);
for (i=0; i<dim[0]; i=i+fraction){
if (var_animation[i] <= thresh ) {
glColor3f (cxx[i], cyy[i], czz[i]);
glVertex3f(xc[i],yc[i],zc[i]);
}
}
glEnd();
if (flag_elevator == upp)
glPointSize (pt_size+2);
else if (flag_elevator == down)
glPointSize (pt_size);
glBegin(GL_POINTS);
for (i=0; i<dim[0]; i=i+fraction){
if (var_animation[i] > thresh ) {
glColor3f (cxx[i], cyy[i], czz[i]);
glVertex3f(xc[i],yc[i],zc[i]);
}
}
glEnd();
glEndList();
displayListInited = 1;
}
redraw();
}
// if middle button down
if (button == GLUT_MIDDLE_BUTTON && state == GLUT_DOWN) {
if (x > up_rect->xmin && x < up_rect->xmax &&
y > up_rect->ymin && y < up_rect->ymax )
flag_elevator = upp;
if (x > down_rect->xmin && x < down_rect->xmax &&
y > down_rect->ymin && y < down_rect->ymax )
flag_elevator = down;
if (x > band_rect->xmin && x < band_rect->xmax &&
y > band_rect->ymin && y < band_rect->ymax )
flag_elevator = bandflag;
}
}
void
passive_motion(int x, int y) //fpassive_motion
{
X = x;
Y = y;
/* if ((x>TOP_V_X) && (x<TOP_V_X+TOP_W) && (y>TOP_V_Y) && (FLAG_DROP_MENU!=3)) {
FLAG_DROP_MENU =3;
glutSetMenu(Menu3_id);
glutAttachMenu(GLUT_RIGHT_BUTTON);
}
else */
if ((x>CDW) && (FLAG_DROP_MENU!=1)) {
FLAG_DROP_MENU=1;
glutSetMenu(Menu1_id);
glutAttachMenu(GLUT_RIGHT_BUTTON);
}
else {
if ((x<CDW) && (FLAG_DROP_MENU!=2) && (y<H/2)) {
FLAG_DROP_MENU =2;
glutSetMenu(Menu2_id);
glutAttachMenu(GLUT_RIGHT_BUTTON);
}
else if ((x<CDW) && (FLAG_DROP_MENU!=3) && (y>H/2)) {
FLAG_DROP_MENU =2;
glutSetMenu(Menu3_id);
glutAttachMenu(GLUT_RIGHT_BUTTON);
}
}
}
void
motion2(int x, int y) //f02
{
float thresh; // threshhold
float thresh2;
void draw_elevator();
void redraw();
Y = y;
draw_elevator();
// highlight some pts.
if (1){
thresh= (var_animation_min - var_animation_max) * (H2-y) / H2 + var_animation_max;
glutSetWindow(win);
// highlightint points in the band
if (flag_elevator == bandflag){
// Recompiling the list.
glNewList(28, GL_COMPILE_AND_EXECUTE);
thresh2 = thresh + band;
glPointSize(pt_size);
glBegin(GL_POINTS);
for (i=0; i<dim[0]; i=i+fraction){
if (var_animation[i] < thresh && var_animation[i] > thresh2 ) {
glColor3f (cxx[i], cyy[i], czz[i]);
glVertex3f(xc[i],yc[i],zc[i]);
}
}
glEnd();
glPointSize(pt_size+2);
glBegin(GL_POINTS);
for (i=0; i<dim[0]; i=i+fraction){
if (var_animation[i] >= thresh && var_animation[i] <= thresh2 ) {
glColor3f (cxx[i], cyy[i], czz[i]);
glVertex3f(xc[i],yc[i],zc[i]);
}
}
glEnd();
}
else {
// Highlighting point in the upper or lower part of the elevator.
glNewList(28, GL_COMPILE_AND_EXECUTE);
if (flag_elevator == upp)
glPointSize (pt_size);
else if (flag_elevator == down)
glPointSize (pt_size+2);
glBegin(GL_POINTS);
for (i=0; i<dim[0]; i=i+fraction){
if (var_animation[i] <= thresh ) {
glColor3f (cxx[i], cyy[i], czz[i]);
glVertex3f(xc[i],yc[i],zc[i]);
}
}
glEnd();
if (flag_elevator == upp)
glPointSize (pt_size+2);
else if (flag_elevator == down)
glPointSize (pt_size);
glBegin(GL_POINTS);
for (i=0; i<dim[0]; i=i+fraction){
if (var_animation[i] > thresh ) {
glColor3f (cxx[i], cyy[i], czz[i]);
glVertex3f(xc[i],yc[i],zc[i]);
}
}
glEnd();
glEndList();
displayListInited = 1;
}
redraw();
}
}
void
UpdateVelocity_backup()
{
if (Throttle > 0)
// Gazf is a positive number
Gazf = Throttle * MaxAccel / 30; // /30 because Throttle goes from 0 --> 30 in that case).
else // then it's a break and the Throttle goes from -33 --> 0.
// Gazf is a negative number
Gazf = Throttle * MaxDecel /33;
// Beep (Throttle * 10, 100);
//Force = mul_vect_par_nbr_reel (lk_rt, Gazf);
Acceleration = mul_vect_par_nbr_reel (lk_rt, Gazf);
//Gravity.x = Gravity.z =0; Gravity.y = -VoxelY;
//Force = add_vect_to_pt (Force, Gravity);
Friction = mul_vect_par_nbr_reel (Velocity,- Friction_coef); // to damp the inertia.
//Force = add_vect_to_pt (Force, Friction);
Acceleration = add_vect_to_pt (Acceleration, Friction);
// Acceleration = div_vect_par_nbrd (Force,Masse);
Velocity = add_vect_to_pt (Velocity, mul_vect_par_nbr_reel(Acceleration, DTime)); // V = Vo + A*dt
if (scalairv(Velocity, lk_rt) < 0)
Velocity.x = Velocity.y = Velocity.z = 0;
}
UpdateVelocity()
{
if (Throttle > 0)
// Gazf is a positive number
Gazf = Throttle * MaxAccel / 30; // /30 because Throttle goes from 0 --> 30 in that case).
else // then it's a break and the Throttle goes from -33 --> 0.
// Gazf is a negative number
Gazf = Throttle * MaxDecel /33;
AccelScalar = Gazf - Speed * Friction_coef;
Speed = Speed + AccelScalar * DTime;
if (Speed < 0) Speed = 0;
}
void
SpaceOrb() //WinUnix
{
extern void Calc_Car_pos2 ();
// extern int read_orb(int *, int *);
extern struct Virtual_Espace espace[DimX][DimY][DimZ];
extern double XmaxVrmlCity, YmaxVrmlCity, ZmaxVrmlCity;
extern double XminVrmlCity, YminVrmlCity, ZminVrmlCity;
extern float VoxelX, VoxelY, VoxelZ; // Dimention of a voxel.
double step1, step2,step3,sgnx,sgny,sgnz;
struct point dv1,dv2,dv3;
int i, bb[1],b, t[3], r[3];
t[0]=t[1]=t[2]=0;
r[0]=r[1]=r[2]=0;
orb_getstatus ( MyOrbHandle, &t[0], &t[1], &t[2], &r[0], &r[1], &r[2], bb); // reads the translation / rotation of spaceorb!
if (0) { //(b!=-1) ) {
if (b==1) flag_motion = mirror_translate;
if (b==2) flag_motion = flag_mirror_rotate;
switch (flag_motion){
case mirror_translate:
if ((abs(t[0]) > abs(t[1])) && (abs(t[0]) > abs(t[2]))) {
step1 = t[0]/10000.0;
dv1 = mul_vect_par_nbr_reel (m1[FLAG_SELECTED_MIRROR].side,step1);
m1[FLAG_SELECTED_MIRROR].cr = add_vect_to_pt (m1[FLAG_SELECTED_MIRROR].cr, dv1);
}
else
if ((abs(t[1]) > abs(t[0])) && (abs(t[1]) > abs(t[2]))) {
step2 = -t[1]/1000.0;
dv2 = mul_vect_par_nbr_reel (m1[FLAG_SELECTED_MIRROR].nl ,step2);
m1[FLAG_SELECTED_MIRROR].cr = add_vect_to_pt (m1[FLAG_SELECTED_MIRROR].cr, dv2);
}
else {
step3 = -t[2]/10000.0;
dv3 = mul_vect_par_nbr_reel (m1[FLAG_SELECTED_MIRROR].up,step3);
m1[FLAG_SELECTED_MIRROR].cr = add_vect_to_pt (m1[FLAG_SELECTED_MIRROR].cr, dv3);
}
calc_corners_of_mirror(FLAG_SELECTED_MIRROR);
glutPostRedisplay();
break;
case flag_mirror_rotate:
sgnx = -r[2];
sgny = -r[0];
if ( abs(sgnx)>abs(sgny) )
Habib_trackball_mirror(lastquat_mirror,0,0, sgnx*0.00003, 0,FLAG_SELECTED_MIRROR);
else
Habib_trackball_mirror(lastquat_mirror,0,0, 0,sgny*0.0001, FLAG_SELECTED_MIRROR);
build_rotmatrix(m, lastquat_mirror);
//rotate mirror.
m1[FLAG_SELECTED_MIRROR].side = mult_matrix_vector(m,m1[FLAG_SELECTED_MIRROR].side); //vx);
m1[FLAG_SELECTED_MIRROR].up = mult_matrix_vector(m,m1[FLAG_SELECTED_MIRROR].up ); //vy);
m1[FLAG_SELECTED_MIRROR].nl = mult_matrix_vector(m,m1[FLAG_SELECTED_MIRROR].nl ); //vz);
calc_corners_of_mirror(FLAG_SELECTED_MIRROR);
glutPostRedisplay();
break;
}
}
#if 1
if (1) {
FLAG_MOVE_CAR = 1; // Button A of the steeringwheel.
//PlaySound("WalkingMode.wav", NULL, SND_ASYNC);
}
if (0){
FLAG_MOVE_CAR = 2; // Button B of the steeringwheel.
// Calculating coord of eye in the (lkc_rt, upc_rt, horc_rt) coordinate system.
struct point v = sous_vect_to_pt (eye , eyec);
eyeP.x = v.x * horc_rt.x + v.y * horc_rt.y + v.z * horc_rt.z;
eyeP.y = v.x * upc_rt.x + v.y * upc_rt.y + v.z * upc_rt.z;
eyeP.z = v.x * lkc_rt.x + v.y * lkc_rt.y + v.z * lkc_rt.z;
upP.x = up_rt.x * horc_rt.x + up_rt.y * horc_rt.y + up_rt.z * horc_rt.z;
upP.y = up_rt.x * upc_rt.x + up_rt.y * upc_rt.y + up_rt.z * upc_rt.z;
upP.z = up_rt.x * lkc_rt.x + up_rt.y * lkc_rt.y + up_rt.z * lkc_rt.z;
lkP.x = lk_rt.x * horc_rt.x + lk_rt.y * horc_rt.y + lk_rt.z * horc_rt.z;
lkP.y = lk_rt.x * upc_rt.x + lk_rt.y * upc_rt.y + lk_rt.z * upc_rt.z;
lkP.z = lk_rt.x * lkc_rt.x + lk_rt.y * lkc_rt.y + lk_rt.z * lkc_rt.z;
horP.x = hor_rt.x * horc_rt.x + hor_rt.y * horc_rt.y + hor_rt.z * horc_rt.z;
horP.y = hor_rt.x * upc_rt.x + hor_rt.y * upc_rt.y + hor_rt.z * upc_rt.z;
horP.z = hor_rt.x * lkc_rt.x + hor_rt.y * lkc_rt.y + hor_rt.z * lkc_rt.z;
//DriverPos.x = eyec.x - eye.x;
//DriverPos.y = eyec.y - eye.y;
//DriverPos.z = eyec.z - eye.z;
// PlaySound("DrivingMode.wav", NULL, SND_ASYNC);
}
if (0){
// PlaySound("FlyingMode.wav", NULL, SND_ASYNC);
FLAG_MOVE_CAR = 4; // Button C of the steeringwheel.
curquat[0] = curquatc[0];
curquat[1] = curquatc[1];
curquat[2] = curquatc[2];
curquat[3] = curquatc[3];
}
if (0){
FLAG_MOVE_CAR = 8; // Button X of the steeringwheel.
//PlaySound("MovingCarMode.wav",NULL,SND_ASYNC);
}
if (0) // The C SideWinder Botton has been pushed
(FLAG_HORIZ = !FLAG_HORIZ);
sgnx = sgny = 0;
// Throttle Goes from 0 to 63 (0-30 for the Gas) and (30-63 for the break)
Throttle = -30;
// Throttle goes fom -30 ... 33
Throttle = 30 - Throttle;
int Angleint;
Angleint = 0;
Angleint = 509 - Angleint; // Angleint goes from -512 to +511.
// imitate variable ratio steering.
// teta = Angleint/ 40000.0 * (1 + Angleint*Angleint/ 250000) * Speed * DTime ;
//teta = -r[2]*r[2]*r[2] / 1658137500.0;
teta = - (r[2] * 1.8E-11 + r[2]*r[2]*r[2]*27.2E-11);
//if ((t[1] < 2) && (t[2]>-2)) t[1] = 0;
#endif
//Walking Mode: Button A: MOVES THE EYE WITHOUT THE CAR.
if (FLAG_MOVE_CAR==1) { // Equations of a real car, see Written Doc.
//rotate the 3D up,lk,hor system.
Habib_trackball(lastquat,0,0, teta, 0);
add_quats(lastquat, curquat, curquat);
build_rotmatrix(m, curquat);
lk_rt = mult_matrix_vector(m,lk); // lk is (0,0,1) lk_rt is the lk after the quaternion rotation
up_rt = mult_matrix_vector(m,up ); // up is (0,1,0) up_rt is up after the quaternion rotation.
hor_rt = mult_matrix_vector(m,hor); // hor is (1,0,0) hor_rt is hor after the quaternion rotation.
// Commented when programming the distortion correction.
// Calculate Forces => Velocity => Position
//Gazf = -Gazf;
//UpdateVelocity(); //commented for Distortion correction
//Velocity = mul_vect_par_nbr_reel (lk_rt, Speed); //commented for distcorrectin
// eye = add_vect_to_pt (eye,mul_vect_par_nbr_reel(Velocity,DTime)); // Calculate new eye position. // P = Po + V*dt
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
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
#if 0
// Collision detection.
ii = (eye.x - XminVrmlCity) * DimX / (XmaxVrmlCity - XminVrmlCity);
if (ii<0) ii = 0;
if (ii>=DimX) ii = DimX-1;
jj = (eye.y-HauteurEye - YminVrmlCity) * DimY / (YmaxVrmlCity - YminVrmlCity);
//jj1= (eye.y-HauteurEye+VoxelY - YminVrmlCity) * DimY / (YmaxVrmlCity - YminVrmlCity);
if (jj<0) jj = 0;
if (jj>=DimY) ii = DimY-1;
// if (jj1<0) ii = 0;
// if (jj1>=DimY) ii = DimY-1;
kk = (eye.z - ZminVrmlCity) * DimZ / (ZmaxVrmlCity - ZminVrmlCity);
if (kk<0) kk = 0;
if (kk>=DimZ) kk = DimZ-1;
//if (espace[ii][jj][kk].FULL==1) { // For stability of the image.
//eye.y = eye.y-Gravity.y; // Cancels gravity at any collision
// scalair = scalairv (espace[ii][jj][kk].N[0],Velocity);
//if (scalair < 0){
//vecttt = mul_vect_par_nbr_reel (espace[ii][jj][kk].N[0], scalair);
//Velocity = sous_vect_to_pt (Velocity, vecttt);
//}
//}
if (espace[ii][jj][kk].FULL>=1)
eye.y = eye.y+(VoxelY) * (espace[ii][jj][kk].FULL);
Velocity.y = 0;
#endif
}
// Driving Mode (Driving the car). BOTTOM B OF THE STEERING WHEEL.
if (FLAG_MOVE_CAR == 2){
//rotate the 3D up,lk,hor system.
//Habib_trackball(lastquat,0,0, teta, 0);
axis_to_quat (axisup ,teta ,lastquat);
add_quats(lastquat, curquatc, curquatc);
build_rotmatrix(mc, curquatc);
lkc_rt = mult_matrix_vector(mc,lk); // lk is (0,0,1) lk_rt is the lk after the quaternion rotation
upc_rt = mult_matrix_vector(mc,up ); // up is (0,1,0) up_rt is up after the quaternion rotation.
horc_rt = mult_matrix_vector(mc,hor); // hor is (1,0,0) hor_rt is hor after the quaternion rotation.
// Calculate Forces => Velocity => Position
Gazf = -Gazf;
/* Force = mul_vect_par_nbr_reel (lkc_rt, Gazf);
Gravity.x = Gravity.z =0; Gravity.y = -VoxelY;
Force = add_vect_to_pt (Force, Gravity);
Friction = mul_vect_par_nbr_reel (Velocity,Friction_coef);
Force = add_vect_to_pt (Force, Friction);
Acceleration = div_vect_par_nbrd (Force,Masse);
Velocity = add_vect_to_pt (Velocity, Acceleration); */
UpdateVelocity();
Velocity = mul_vect_par_nbr_reel (lkc_rt, -Speed);
eyec = add_vect_to_pt (eyec,mul_vect_par_nbr_reel(Velocity,DTime)); // Calculate new eye position. // P = Po + V*dt
#if 0
// Collision detection.
ii = (eyec.x - XminVrmlCity) * DimX / (XmaxVrmlCity - XminVrmlCity);
if (ii<0) ii = 0;
if (ii>=DimX) ii = DimX-1;
jj = (eyec.y-HauteurEye - YminVrmlCity) * DimY / (YmaxVrmlCity - YminVrmlCity);
//jj1= (eye.y-HauteurEye+VoxelY - YminVrmlCity) * DimY / (YmaxVrmlCity - YminVrmlCity);
if (jj<0) jj = 0;
if (jj>=DimY) ii = DimY-1;
// if (jj1<0) ii = 0;
// if (jj1>=DimY) ii = DimY-1;
kk = (eyec.z - ZminVrmlCity) * DimZ / (ZmaxVrmlCity - ZminVrmlCity);
if (kk<0) kk = 0;
if (kk>=DimZ) kk = DimZ-1;
if (espace[ii][jj][kk].FULL>=1)
eyec.y = eyec.y+VoxelY * (espace[ii][jj][kk].FULL);
Velocity.y = 0;
#endif
// Calculates the eye and lk_rt, up_rt, hor_rt.
lk_rt.x = lkP.x * horc_rt.x + lkP.y * upc_rt.x + lkP.z * lkc_rt.x;
lk_rt.y = lkP.x * horc_rt.y + lkP.y * upc_rt.y + lkP.z * lkc_rt.y;
lk_rt.z = lkP.x * horc_rt.z + lkP.y * upc_rt.z + lkP.z * lkc_rt.z;
up_rt.x = upP.x * horc_rt.x + upP.y * upc_rt.x + upP.z * lkc_rt.x;
up_rt.y = upP.x * horc_rt.y + upP.y * upc_rt.y + upP.z * lkc_rt.y;
up_rt.z = upP.x * horc_rt.z + upP.y * upc_rt.z + upP.z * lkc_rt.z;
hor_rt.x = horP.x * horc_rt.x + horP.y * upc_rt.x + horP.z * lkc_rt.x;
hor_rt.y = horP.x * horc_rt.y + horP.y * upc_rt.y + horP.z * lkc_rt.y;
hor_rt.z = horP.x * horc_rt.z + horP.y * upc_rt.z + horP.z * lkc_rt.z;
eye.x = eyeP.x * horc_rt.x + eyeP.y * upc_rt.x + eyeP.z * lkc_rt.x;
eye.y = eyeP.x * horc_rt.y + eyeP.y * upc_rt.y + eyeP.z * lkc_rt.y;
eye.z = eyeP.x * horc_rt.z + eyeP.y * upc_rt.z + eyeP.z * lkc_rt.z;
eye = add_vect_to_pt (eye , eyec);
#if 0 // Record the car mvmt.
if (RECORD_CAR_MVMT) {
//Allocates CarLocationRec
if (IndexCarLocRec[RecRouteNum] == CarLocAllocated[RecRouteNum]){
CarLocAllocated[RecRouteNum] = CarLocAllocated[RecRouteNum]+100;
if ( (CarLocationRec[RecRouteNum] = (struct car_location*) realloc (CarLocationRec[RecRouteNum],CarLocAllocated[RecRouteNum]*sizeof (struct car_location)) ) ==NULL)
cout << "realloc error 1341 " << endl;
}
// Reads in the location and orientation of the car.
CarLocationRec[RecRouteNum][IndexCarLocRec[RecRouteNum]].x = eyec.x;
CarLocationRec[RecRouteNum][IndexCarLocRec[RecRouteNum]].y = eyec.y;
CarLocationRec[RecRouteNum][IndexCarLocRec[RecRouteNum]].z = eyec.z;
CarLocationRec[RecRouteNum][IndexCarLocRec[RecRouteNum]].quat[0] = curquatc[0];
CarLocationRec[RecRouteNum][IndexCarLocRec[RecRouteNum]].quat[1] = curquatc[1];
CarLocationRec[RecRouteNum][IndexCarLocRec[RecRouteNum]].quat[2] = curquatc[2];
CarLocationRec[RecRouteNum][IndexCarLocRec[RecRouteNum]].quat[3] = curquatc[3];
IndexCarLocRec[RecRouteNum]++;
}
#endif
}
// Flying Mode.. Botton C: MOVES THE EYE WITHOUT COLLISION DETECTION.
if (FLAG_MOVE_CAR == 4) {
Habib_trackball(lastquat,0,0, teta, 0);
add_quats(lastquat, curquat, curquat);
build_rotmatrix(m, curquat);
eye.x = eye.x - up_rt.x*sgny - hor_rt.x*sgnx - lk_rt.x*sgnz;
eye.z = eye.z - up_rt.z*sgny - hor_rt.z*sgnx - lk_rt.z*sgnz;
if (!FLAG_HORIZ)
eye.y = eye.y - up_rt.y*sgny - hor_rt.y*sgnx - lk_rt.y*sgnz;
//rotate the 3D up,lk,hor system.
lk_rt = mult_matrix_vector(m,lk); // lk is (0,0,1) lk_rt is the lk after the quaternion rotation
up_rt = mult_matrix_vector(m,up ); // up is (0,1,0) up_rt is up after the quaternion rotation.
hor_rt = mult_matrix_vector(m,hor); // hor is (1,0,0) hor_rt is hor after the quaternion rotation.
}
// Moving Car Mode. Botton X: MOVES THE CAR WITHOUT THE EYE.
if (FLAG_MOVE_CAR==8) { //move car like in Netscape.
Gazf = Throttle * MaxAccel / 30; // /30 because Throttle goes from 0 --> 30 in that case).
teta = Angleint/ 4000.0;
if (WALK_SLOWLY){
sgnz = Gazf = Gazf / SlowIt;
teta = teta / SlowIt;
}
Habib_trackball(lastquat,0,0, teta, 0);
add_quats(lastquat, curquatc, curquatc);
build_rotmatrix(mc, curquatc);
eyec.x = eyec.x - upc_rt.x*sgny - horc_rt.x*sgnx - lkc_rt.x*sgnz;
eyec.z = eyec.z - upc_rt.z*sgny - horc_rt.z*sgnx - lkc_rt.z*sgnz;
if (!FLAG_HORIZ)
eyec.y = eyec.y - upc_rt.y*sgny - horc_rt.y*sgnx - lkc_rt.y*sgnz;
//rotate the 3D up,lk,hor system.
lkc_rt = mult_matrix_vector(mc,lk); // lk is (0,0,1) lk_rt is the lk after the quaternion rotation
upc_rt = mult_matrix_vector(mc,up ); // up is (0,1,0) up_rt is up after the quaternion rotation.
horc_rt = mult_matrix_vector(mc,hor); // hor is (1,0,0) hor_rt is hor after the quaternion rotation.
}
// Place the Cars in the scene (next step).
for (i=0;i<10;i++)
if (RouteNum[i])
if (IndexCarLocRec[i] < MaxIndexCarLocRec[i])
IndexCarLocRec[i]++;
else
IndexCarLocRec[i] = 0;
//Calc_Car_pos2();
glutPostRedisplay();
//ii = (eye.x - XminVrmlCity) * DimX / (XmaxVrmlCity - XminVrmlCity);
//jj = (eye.y - YminVrmlCity) * DimY / (YmaxVrmlCity - YminVrmlCity);
//kk = (eye.z - ZminVrmlCity) * DimZ / (ZmaxVrmlCity - ZminVrmlCity);
//cout << (int) espace[ii][jj][kk].FULL << endl;
//cout << eye.x << " " << eye.y << " " << eye.z << " " << ii << " " << jj << " " << kk << endl;
//cout << (int) espace[ii][jj][kk].FULL << endl;
}
void
motion(int x, int y) //fmotion
// Handles the motion of the mouse in the big black window. get called when
// the a mouse button is pressed and the mouse is in motion.
{
void redraw();
void calc_corners_of_mirror(int i);
struct point add_vect_to_pt (struct point, struct point);
struct point mul_vect_par_nbr_reel(struct point, float);
if (APPLY_MOUSE_MOTION) {
double deux;
int sgnx, sgny;
double step1, step2;
float stepx, stepy, stepz;
struct point dv1,dv2;
int stepo,steppss,stepppi;
switch (flag_motion) {
case motion_carre1:
stepo = (y-beginy);
carre1 = carre1 + stepo*(deltaz/10000);
//cout << "carre1 = " << carre1 << endl;
beginy = y;
break;
case motion_carre2:
steppss = (y-beginy);
carre2 = carre2 + steppss*(deltay/20000);
beginy = y;
break;
case motion_carre3:
stepppi = (y-beginy);
carre3 = carre3 + stepppi*(deltax/1000);
beginy = y;
break;
case flag_change_light_intensity:
if (beginy!=y) {
int sgnn = (y-beginy);
step1 = 0.01;
lightZeroColor[0] = lightZeroColor[0] + sgnn * step1;
if (lightZeroColor[0] > 1) lightZeroColor[0] = 1;
if (lightZeroColor[0] < 0) lightZeroColor[0] = 0;
lightZeroColor[2] = lightZeroColor[1] = lightZeroColor[0];
lightOneColor[0]=lightOneColor[1]=lightOneColor[2]=lightZeroColor[0];
cout << "lightIntensity" << lightZeroColor[0] << endl;
cout << "delta pixels = " << sgnn << endl;
beginy = y;
newModel = 1;
//glutPostRedisplay();
}
break;
case scaling:
if (beginy!=y) {
// scalefactor = scalefactor * (1.0 + (((float) (beginy - y)) / H));
int sgnn = (y-beginy);
step1 = (LEFT-RIGHT)/200.0;
step2 = (BOTTOM-TOP)/200.0;
if (flag_motion_win == top_view_com) {
LEFT = LEFT + sgnn*step1;
RIGHT = RIGHT - sgnn*step1;
BOTTOM = BOTTOM+ sgnn*step2;
TOP = TOP - sgnn*step2;
}
else {
cam_angle = cam_angle + sgnn*0.1;
}
beginy = y;
newModel = 1;
//glutPostRedisplay();
}
break;
case flag_zoom_y:
if (beginy!=y) {
// scalefactor = scalefactor * (1.0 + (((float) (beginy - y)) / H));
int sgnn = (y-beginy);
step2 = (BOTTOM-TOP)/200.0;
if (flag_motion_win == top_view_com) {
BOTTOM = BOTTOM+ sgnn*step2;
TOP = TOP - sgnn*step2;
}
else {
// aspect_ratio = aspect_ratio + sgnn*0.01;
cam_angle = cam_angle + sgnn*0.01;
}
beginy = y;
newModel = 1;
}
case baseline_zoom:
if (beginy!=y) {
int sgnn = (beginy-y); //abs((beginx-x));
baseline = baseline + sgnn*0.001;
beginy = y;
//glutPostRedisplay();
}
break;
case vertical_adj:
vav = vav + (beginy - y); // vav = vertical adjustment value.
mz[FLAG_SELECTED_MIRROR] = mz[FLAG_SELECTED_MIRROR] + (beginy - y);
beginy=y;
break;
case translating: // TRANSLATING THE CAMERA.
sgnx = sgny =0;
if (beginx != x) sgnx = (beginx-x); //abs(beginx-x);
if (beginy != y) sgny = (beginy-y); //abs(beginy-y);
if (flag_motion_win == top_view_com) {
step1 = -(LEFT-RIGHT)/800.0;
step2 = (BOTTOM-TOP)/500.0;
step1 = step1 / SlowIt;
step2 = step2 / SlowIt;
TRANSLATE_X = TRANSLATE_X - sgnx*step1;
TRANSLATE_Y = TRANSLATE_Y - sgny*step2;
/*LEFT = LEFT - sgnx*step1;
RIGHT = RIGHT - sgnx*step1;
BOTTOM = BOTTOM+ sgny*step2;
TOP = TOP + sgny*step2; */
}
else { // If I am moving the and my eye is fix with the scene, then
// Translate the car, when shift motion is applied. Do not translate
// the scene when I am in the moving CAR mode.
if (FLAG_MOVE_CAR==8){ // This is the moving car mode.
sgny = sgny / SlowIt;
sgnx = sgnx / SlowIt;
eyec.x = eyec.x + upc_rt.x*sgny*0.1 - horc_rt.x*sgnx*0.05;
eyec.z = eyec.z + upc_rt.z*sgny*0.1 - horc_rt.z*sgnx*0.05;
if (!FLAG_HORIZ)
eyec.y = eyec.y + upc_rt.y*sgny*0.1 - horc_rt.y*sgnx*0.05;
}else{
eye.x = eye.x - up_rt.x*sgny*0.01 - hor_rt.x*sgnx*0.05;
eye.z = eye.z - up_rt.z*sgny*0.01 - hor_rt.z*sgnx*0.05;
if (!FLAG_HORIZ)
eye.y = eye.y - up_rt.y*sgny*0.01 - hor_rt.y*sgnx*0.050;
}
}
beginx = x;
beginy = y;
newModel = 1;
//glutPostRedisplay();
break;
// translating the camera in the z direction.
case translatingz:
sgny = 0;
if (beginy != y) sgny = (beginy-y);
eye.x = eye.x + lk_rt.x*sgny*0.05 ;
eye.z = eye.z + lk_rt.z*sgny*0.05 ;
if (!FLAG_HORIZ)
eye.y = eye.y + lk_rt.y*sgny*0.05;
beginy = y;
newModel = 1;
break;
case rotating_Geye:
deux = 2.0;
trackball(lastquat_Geye,
(deux*beginx - W) / W,
(H - deux*beginy) / H,
(deux*x - W) / W,
(H - deux*y) / H
);
beginx = x;
beginy = y;
add_quats(lastquat_Geye, curquat_Geye, curquat_Geye);
break;
case rotating:
deux = 2.0;
if (flag_motion_win == top_view_com)
trackball(lastquat_top_view,
(deux*beginx - W) / W,
(H - deux*beginy) / H,
(deux*x - W) / W,
(H - deux*y) / H
);
else {
sgnx = beginx-x;
sgny = beginy-y;
if ( abs(sgnx)>abs(sgny) )
Habib_trackball(lastquat,0,0, sgnx*0.001, 0);
else
Habib_trackball(lastquat,0,0, 0,sgny*0.001 );
}
beginx = x;
beginy = y;
spinning = 0;
if (flag_motion_win == top_view_com)
add_quats(lastquat_top_view, curquat_top_view, curquat_top_view);
else {
add_quats(lastquat, curquat, curquat);
build_rotmatrix(m, curquat);
//rotate the 3D up,lk,hor system.
lk_rt = mult_matrix_vector(m,lk); // lk is (0,0,1) lk_rt is the lk after the quaternion rotation
up_rt = mult_matrix_vector(m,up ); // up is (0,1,0) up_rt is up after the quaternion rotation.
hor_rt = mult_matrix_vector(m,hor); // hor is (1,0,0) hor_rt is hor after the quaternion rotation.
}
newModel = 1;
//glutPostRedisplay();
break;
case mirror_translate:
sgnx = sgny =0;
if (beginx != x) sgnx = (x-beginx)*0.01; //abs(beginx-x);
if (beginy != y) sgny = (beginy-y)*0.01; //abs(beginy-y);
step1 = sgnx;
step2 = sgny;
dv1 = mul_vect_par_nbr_reel (m1[FLAG_SELECTED_MIRROR].side,step1);
dv2 = mul_vect_par_nbr_reel (m1[FLAG_SELECTED_MIRROR].up ,step2);
m1[FLAG_SELECTED_MIRROR].cr = add_vect_to_pt (m1[FLAG_SELECTED_MIRROR].cr, dv1);
m1[FLAG_SELECTED_MIRROR].cr = add_vect_to_pt (m1[FLAG_SELECTED_MIRROR].cr, dv2);
calc_corners_of_mirror(FLAG_SELECTED_MIRROR);
beginx = x;
beginy = y;
break;
case mirror_translateZ:
sgnx = sgny =0;
if (beginx != x) sgnx = (beginx-x)*0.01; //abs(beginx-x);
if (beginy != y) sgny = (beginy-y)*0.01; //abs(beginy-y);
step1 = sgnx ;
step2 = sgny ;
dv1 = mul_vect_par_nbr_reel (m1[FLAG_SELECTED_MIRROR].nl,step1);
dv2 = mul_vect_par_nbr_reel (m1[FLAG_SELECTED_MIRROR].nl ,step2);
m1[FLAG_SELECTED_MIRROR].cr = add_vect_to_pt (m1[FLAG_SELECTED_MIRROR].cr, dv1);
m1[FLAG_SELECTED_MIRROR].cr = add_vect_to_pt (m1[FLAG_SELECTED_MIRROR].cr, dv2);
calc_corners_of_mirror(FLAG_SELECTED_MIRROR);
beginx = x;
beginy = y;
break;
case flag_mirror_rotate:
deux = 2.0;
sgnx = beginx-x;
sgny = beginy-y;
if ( abs(sgnx)>abs(sgny) )
Habib_trackball_mirror(lastquat_mirror,0,0, sgnx*0.001, 0,FLAG_SELECTED_MIRROR);
else
Habib_trackball_mirror(lastquat_mirror,0,0, 0,sgny*0.001, FLAG_SELECTED_MIRROR);
/* opp_trackball(lastquat_mirror,
(deux*beginx - W) / W,
(H - deux*beginy) / H,
(deux*x - W) / W,
(H - deux*y) / H
); */
beginx = x;
beginy = y;
// add_quats(lastquat_mirror, curquat_mirror, curquat_mirror);
build_rotmatrix(m, lastquat_mirror);
//rotate mirror.
m1[FLAG_SELECTED_MIRROR].side = mult_matrix_vector(m,m1[FLAG_SELECTED_MIRROR].side); //vx);
m1[FLAG_SELECTED_MIRROR].up = mult_matrix_vector(m,m1[FLAG_SELECTED_MIRROR].up ); //vy);
m1[FLAG_SELECTED_MIRROR].nl = mult_matrix_vector(m,m1[FLAG_SELECTED_MIRROR].nl);//vz);
calc_corners_of_mirror(FLAG_SELECTED_MIRROR);
break;
case flag_expand_mirror1_x:
step2 =0;
if (beginx != x) step2 = 0.1*(beginx-x); //abs(beginx-x);
m1[FLAG_SELECTED_MIRROR].width=m1[FLAG_SELECTED_MIRROR].width+step2;
calc_corners_of_mirror(FLAG_SELECTED_MIRROR);
m1[FLAG_SELECTED_MIRROR].cr.x = (m1[FLAG_SELECTED_MIRROR].c1.x+m1[FLAG_SELECTED_MIRROR].c3.x)/2.0;
m1[FLAG_SELECTED_MIRROR].cr.y = (m1[FLAG_SELECTED_MIRROR].c1.y+m1[FLAG_SELECTED_MIRROR].c3.y)/2.0;
m1[FLAG_SELECTED_MIRROR].cr.z = (m1[FLAG_SELECTED_MIRROR].c1.z+m1[FLAG_SELECTED_MIRROR].c3.z)/2.0;
beginx = x;
break;
case flag_expand_mirror1_y:
step1 =0;
if (beginy != y) step1 = 0.1*(beginy-y);
m1[FLAG_SELECTED_MIRROR].height=m1[FLAG_SELECTED_MIRROR].height+step1;
calc_corners_of_mirror(FLAG_SELECTED_MIRROR);
m1[FLAG_SELECTED_MIRROR].cr.x = (m1[FLAG_SELECTED_MIRROR].c1.x+m1[FLAG_SELECTED_MIRROR].c3.x)/2.0;
m1[FLAG_SELECTED_MIRROR].cr.y = (m1[FLAG_SELECTED_MIRROR].c1.y+m1[FLAG_SELECTED_MIRROR].c3.y)/2.0;
beginy = y;
break;
case flag_expand_mirror1_xy:
step1 = step2 =0;
if (beginx != x) step1 = 0.001*(beginx-x);
if (beginy != y) step2 = 0.001*(beginy-y);
m1[FLAG_SELECTED_MIRROR].width =fabs(m1[FLAG_SELECTED_MIRROR].width +step1);
m1[FLAG_SELECTED_MIRROR].height=fabs(m1[FLAG_SELECTED_MIRROR].height+step2);
calc_corners_of_mirror(FLAG_SELECTED_MIRROR);
m1[FLAG_SELECTED_MIRROR].cr.x = (m1[FLAG_SELECTED_MIRROR].c1.x+m1[FLAG_SELECTED_MIRROR].c3.x)/2.0;
m1[FLAG_SELECTED_MIRROR].cr.y = (m1[FLAG_SELECTED_MIRROR].c1.y+m1[FLAG_SELECTED_MIRROR].c3.y)/2.0;
beginx = x;
beginy = y;
break;
case flag_top_expand_xy:
sgny = sgnx =0;
if (beginx != x) sgnx = (beginx-x);
if (beginy != y) sgny = (beginy-y);
TOP_W = TOP_W + sgnx;
TOP_H = TOP_H + sgny;
TOP_V_Y= H-TOP_H; // It's the lower left corner of the TOP_VIEW_WINDOW
beginx = x;
beginy = y;
break;
case flag_move_light0:
sgny = 0;
if (beginy != y) sgny = (beginy-y);
stepx = (lightZeroPosition[0] - Center_Of_Rot_Of_Lights.x)/200.0;
stepy = (lightZeroPosition[1] - Center_Of_Rot_Of_Lights.y)/200.0;
stepz = (lightZeroPosition[2] - Center_Of_Rot_Of_Lights.z)/200.0;
lightZeroPosition[0] = lightZeroPosition[0] + stepx*sgny;
lightZeroPosition[1] = lightZeroPosition[1] + stepy*sgny;
lightZeroPosition[2] = lightZeroPosition[2] + stepz*sgny;
beginx = x;
beginy = y;
break;
case flag_move_light1:
sgny = 0;
if (beginy != y) sgny = (beginy-y);
stepx = (lightOnePosition[0] - Center_Of_Rot_Of_Lights.x)/200.0;
stepy = (lightOnePosition[1] - Center_Of_Rot_Of_Lights.y)/200.0;
stepz = (lightOnePosition[2] - Center_Of_Rot_Of_Lights.z)/200.0;
lightOnePosition[0] = lightOnePosition[0] + stepx*sgny;
lightOnePosition[1] = lightOnePosition[1] + stepy*sgny;
lightOnePosition[2] = lightOnePosition[2] + stepz*sgny;
beginx = x;
beginy = y;
break;
case flag_rotate_light0:
pos_light0.x = lightZeroPosition[0];
pos_light0.y = lightZeroPosition[1];
pos_light0.z = lightZeroPosition[2];
trackball(lastquat_light0,
(2.0*beginx - W) / W,
(H - 2.0*beginy) / H,
(2.0*x - W) / W,
(H - 2.0*y) / H );
//add_quats(lastquat_light0, curquat_light0, curquat_light0);
build_rotmatrix (m, lastquat_light0);
pos_light0 = mult_matrix_vector(m,pos_light0);
lightZeroPosition[0]=pos_light0.x ;
lightZeroPosition[1]=pos_light0.y ;
lightZeroPosition[2]=pos_light0.z ;
beginx = x;
beginy = y;
break;
case flag_rotate_light1:
pos_light1.x = lightOnePosition[0];
pos_light1.y = lightOnePosition[1];
pos_light1.z = lightOnePosition[2];
trackball(lastquat_light1,
(2.0*beginx - W) / W,
(H - 2.0*beginy) / H,
(2.0*x - W) / W,
(H - 2.0*y) / H );
//add_quats(lastquat_light0, curquat_light0, curquat_light0);
build_rotmatrix (m, lastquat_light1);
pos_light1 = mult_matrix_vector(m,pos_light1);
lightOnePosition[0]=pos_light1.x ;
lightOnePosition[1]=pos_light1.y ;
lightOnePosition[2]=pos_light1.z ;
beginx = x;
beginy = y;
break;
}
}
glutPostRedisplay();
}
inline
void
DropMenu3(int value)
{
void redraw();
/*switch (value) {
case 1: */
FLAG_SELECTED_MIRROR = value;
}
GLboolean lightZeroSwitch = GL_TRUE, lightOneSwitch = GL_TRUE;
void
DropMenu2(int value)
{
void redraw();
if (FLAG_TOGGLE_MIRROR[value]==1)
FLAG_TOGGLE_MIRROR[value] =0 ;
else
FLAG_TOGGLE_MIRROR[value] =1 ;
//displayListInited = 0;
// redraw();
glutPostRedisplay();
}
//fdropmenu1
void
DropMenu1(int value)
{
extern void calc_coord_mirror_rel_to_camera(int i);
void add_to_the_menus_a_mirror(int i);
void redraw();
void fog();
switch (value) {
case 1: // Toggle Light.
if (FLAG_TOGGLE_MENU1){
FLAG_TOGGLE_MENU1 = 0;
cout << "Light Disabled" << endl;
glDisable(GL_LIGHTING);
}
else{
FLAG_TOGGLE_MENU1 = 1;
cout << "Light Enabled" << endl;
glEnable(GL_LIGHTING);
}
break;
case 2:
if (FLAG_TOGGLE_TEXTURE_MAP){
FLAG_TOGGLE_TEXTURE_MAP = 0;
glDisable(GL_LIGHTING);
}
else{
FLAG_TOGGLE_TEXTURE_MAP = 1;
glEnable(GL_LIGHTING);
}
break;
case 3:
/* workaround hack */
#if 0
if(glIsEnabled(GL_MULTISAMPLE_SGIS)) {
glDisable(GL_MULTISAMPLE_SGIS);
} else {
glEnable(GL_MULTISAMPLE_SGIS);
}
#endif
break;
case 4:
glutFullScreen();
break;
case 5:
cout << "Baseline = " << baseline << endl ;
cout << "Give new Baseline : " ;
cin >> baseline;
break;
case 6:
displayListInited=0;
for (i=0; i<dim[0]; i++){
cxx[i]=1.0;
cyy[i]=1.0;
czz[i]=1.0;
}
break;
case 7:
displayListInited=0;
for (i=0; i<dim[0]; i++){
switch (col1[i]){
case 1:
cxx[i]=0.0; cyy[i]=1.0; czz[i]=1.0;
break;
case 2:
cxx[i]=1.0; cyy[i]=0.0; czz[i]=1.0;
break;
case 3:
cxx[i]=1.0; cyy[i]=1.0; czz[i]=0.0;
break;
case 4:
cxx[i]=1.0; cyy[i]=0.0; czz[i]=0.0;
break;
case 5:
cxx[i]=0.0; cyy[i]=1.0; czz[i]=0.0;
break;
case 6:
cxx[i]=0.0; cyy[i]=0.0; czz[i]=1.0;
break;
case 7:
cxx[i]=1.0; cyy[i]=0.5; czz[i]=0.25;
break;
case 8:
cxx[i]=1.0; cyy[i]=1.0; czz[i]=1.0;
break;
}
}
break;
case 8:
displayListInited=0;
for (i=0; i<dim[0]; i++){
switch (col4[i]){
case 1:
cxx[i]=1.0; cyy[i]=0.5; czz[i]=0.25;
break;
case -1:
cxx[i]=0.25; cyy[i]=0.9; czz[i]=0.75;
break;
}
}
break;
case 9:
TRANSLATE_TO_GRAVITY = 0;
TRANSLATE_TO_MIDDLE = 0;
break;
case 10:
TRANSLATE_TO_GRAVITY = 1;
TRANSLATE_TO_MIDDLE = 0;
break;
case 11:
TRANSLATE_TO_GRAVITY = 0;
TRANSLATE_TO_MIDDLE = 1;
break;
case 12: // normal scaling (1,1,1)
SCALE_SIGMA = 0 ;
SCALE_MIDDLE = 0 ;
break;
case 13: // sigma scaling
SCALE_SIGMA = 1 ;
SCALE_MIDDLE = 0 ;
break;
case 14: // middle scaling
SCALE_SIGMA = 0 ;
SCALE_MIDDLE = 1 ;
break;
case 15:
cout << "Give the pixel size : " << endl;
cin >> pt_size;
displayListInited = 0;
break;
case 16:
cout << "What fraction of the points would you like to display ?" ;
cin >> fraction;
displayListInited = 0;
break;
case 17:
if (TOGGLE_BOX == 1 ) TOGGLE_BOX = 0;
else TOGGLE_BOX = 1;
redraw();
break;
case 18:
baseline = -baseline;
redraw();
break;
case 19:
//fog();
redraw();
break;
case 20:
glDisable(GL_FOG);
redraw();
break;
case 21:
if (viewport == 0)
viewport = 1;
else{
viewport = 0;
}
redraw();
break;
case 22:
if (Draw_relative_axe == 0)
Draw_relative_axe = 1;
else{
Draw_relative_axe = 0;
}
redraw();
break;
case 23:
if (FLAG_TOP_VIEW == 0)
FLAG_TOP_VIEW = 1;
else{
FLAG_TOP_VIEW = 0;
}
redraw();
break;
case 24:
if (FLAG_FRONT_VIEW == 0)
FLAG_FRONT_VIEW = 1;
else{
FLAG_FRONT_VIEW = 0;
}
redraw();
break;
case 25:
if (FLAG_ORTHO_PERSP == 0)
FLAG_ORTHO_PERSP = 1;
else{
FLAG_ORTHO_PERSP = 0;
}
redraw();
break;
case 26:
if (FLAG_HORIZ == 0)
FLAG_HORIZ = 1;
else
FLAG_HORIZ = 0;
break;
case 27: if (FLAG_FIX_MIRROR ==0){
FLAG_FIX_MIRROR =1;
for (i=0;i<number_of_mirrors;i++){
calc_coord_mirror_rel_to_camera(i);
}
}
else
FLAG_FIX_MIRROR = 0;
break;
case 28:
add_to_the_menus_a_mirror(number_of_mirrors);
number_of_mirrors++;
break;
case 29:
if (Draw_light_position == 0)
Draw_light_position = 1;
else{
Draw_light_position = 0;
}
redraw();
break;
case 99:
exit(0);
break;
}
glutPostRedisplay();
}
//fcreate_menus
void
create_menus()
{
glutCreateMenu(DropMenu1); html // Drop Menu1 is the function where you implement
// the menu id's.
Menu1_id = glutGetMenu();
glutAddMenuEntry("Toggle lights" , 1);
// glutAddMenuEntry("Toggel Mirror 1" , 2);
glutAddMenuEntry("Full screen" , 4);
//glutAddMenuEntry("Set baseline" , 5);
//glutAddMenuEntry("Remove color " , 6);
//glutAddMenuEntry("Put color col1" , 7);
//glutAddMenuEntry("Put color col4" , 8);
//glutAddMenuEntry("Origine at 0" , 9);
//glutAddMenuEntry("Origine at mean" , 10);
//glutAddMenuEntry("Origine at mid-range" , 11);
//glutAddMenuEntry("Scaling unity" , 12);
// glutAddMenuEntry("Scaling sigma" , 13);
//glutAddMenuEntry("Scaling range" , 14);
//glutAddMenuEntry("Size_pt = " , 15);
//glutAddMenuEntry("Number_points = " , 16);
// glutAddMenuEntry("Toggle box" , 17);
//glutAddMenuEntry("Toggle cameras left-right" , 18);
//glutAddMenuEntry("Add some Fog..." , 19);
// glutAddMenuEntry("Remove the Fog..." , 20);
glutAddMenuEntry("Toggle viewport" , 21);
glutAddMenuEntry("Toggle axes " , 22);
glutAddMenuEntry("Toggle TOP VIEW " , 23);
// glutAddMenuEntry("Toggle FRONT VIEW" , 24);
glutAddMenuEntry("Toggle Ortho-Persp." , 25);
glutAddMenuEntry("Toggle Move Horizontally." , 26);
glutAddMenuEntry("FIX_MIRROR_TO_CAMERA" , 27);
glutAddMenuEntry("ADD A MIRROR TO THE SCENE" , 28);
glutAddMenuEntry("Show the position of the lights" , 29);
if(glutGet(GLUT_WINDOW_NUM_SAMPLES) > 0) {
glutAddMenuEntry("Toggle multisampling", 3);
glutSetWindowTitle("dinospin (multisample capable)");
}
glutAddMenuEntry("Quit", 99);
// Drop Menu2.
glutCreateMenu(DropMenu2);
Menu2_id = glutGetMenu();
glutSetMenu(Menu2_id);
// int i;
// glutAddMenuEntry ("None",1);
/*for (i=0;i<nbr_of_col; i++){
glutAddMenuEntry(var_name[i],i+2);
}*/
// Drop Menu3.
glutCreateMenu(DropMenu3);
Menu3_id = glutGetMenu();
glutSetMenu(Menu3_id);
// glutAddMenuEntry ("None",1);
}
void
add_to_the_menus_a_mirror(int i)
{
void initialize_a_mirror(int );
char buffer[20];
char b2[20];
glutSetMenu(Menu2_id);
strcpy (buffer,"Toggle mirror ");
//strcat (buffer, itoa(i,b2,10)); // WinUnix Just Comment this for now...
glutAddMenuEntry(buffer,i); // the Id of the first mirror[0] is 2 in the menu.
glutSetMenu(Menu3_id);
strcpy (buffer,"Select mirror ");
strcat (buffer, b2); // WinUnix Just Comment this for now...
glutAddMenuEntry(buffer,i);
initialize_a_mirror(i);
}
void
draw_elevator() //fdraw_elevator
/* draws the background of the window2 the elevator window. */
{
int len;
char string1[] = "Up";
char string2[] = "Do";
char string3[] = "Ba";
char string4[] = "9.11";
glDrawBuffer(GL_BACK);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Set Projection Matrix
glMatrixMode(GL_PROJECTION);/* set up projection transform */
glLoadIdentity();
glOrtho (0,W2, H2,0 ,-1 ,1);
// Set ModelView Matrix.
glMatrixMode (GL_MODELVIEW);
glLoadIdentity();
// Drawing the up box.
up_rect->xmin = 0 ;
up_rect->xmax = 20;
up_rect->ymin = 0 ;
up_rect->ymax = 10 ;
glBegin (GL_POLYGON);
glColor3f (0.9f,0.8f,0.7f);
glVertex2i (up_rect->xmin,up_rect->ymin);
glVertex2i (up_rect->xmin,up_rect->ymax);
glVertex2i (up_rect->xmax,up_rect->ymax);
glVertex2i (up_rect->xmax,up_rect->ymin);
glEnd();
glColor3f (0.15f,0.15f,1.0f);
glRasterPos2i(up_rect->xmin, up_rect->ymax);
len = (int) strlen(string1);
for (i = 0; i < len; i++)
glutBitmapCharacter(GLUT_BITMAP_8_BY_13, string1[i]);
// Drawing the down box.
down_rect->xmin = 30 ;
down_rect->xmax = 50;
down_rect->ymin = 0 ;
down_rect->ymax = 10 ;
glBegin (GL_POLYGON);
glColor3f (0.7f,0.9f,0.8f);
glVertex2i (down_rect->xmin,down_rect->ymin);
glVertex2i (down_rect->xmin,down_rect->ymax);
glVertex2i (down_rect->xmax,down_rect->ymax);
glVertex2i (down_rect->xmax,down_rect->ymin);
glEnd();
glColor3f (0.2f,0.15f,0.1f);
glRasterPos2i(down_rect->xmin, down_rect->ymax);
len = (int) strlen(string2);
for (i = 0; i < len; i++)
glutBitmapCharacter(GLUT_BITMAP_8_BY_13, string2[i]);
// Drawing the Band box.
band_rect->xmin = 60 ;
band_rect->xmax = 80;
band_rect->ymin = 0 ;
band_rect->ymax = 10 ;
glBegin (GL_POLYGON);
glColor3f (0.76f,0.9f,0.6f);
glVertex2i (band_rect->xmin,band_rect->ymin);
glVertex2i (band_rect->xmin,band_rect->ymax);
glVertex2i (band_rect->xmax,band_rect->ymax);
glVertex2i (band_rect->xmax,band_rect->ymin);
glEnd();
glColor3f (0.15f,0.15f,0.3f);
glRasterPos2i(band_rect->xmin, band_rect->ymax);
len = (int) strlen(string3);
for (i = 0; i < len; i++)
glutBitmapCharacter(GLUT_BITMAP_8_BY_13, string3[i]);
// Draw the line indicating where you are in the window.
glBegin (GL_LINES);
glColor3f (0.15f,1.0f,0.3f);
glVertex2i (0,Y);
glVertex2i (90,Y);
glEnd();
glColor3f (1,1,1);
glRasterPos2i(3,Y);
len = (int) strlen(string4);
for (i = 0; i < len; i++)
glutBitmapCharacter(GLUT_BITMAP_8_BY_13, string4[i]);
glutSwapBuffers();
}
char
inline
ItoA (int i){
switch (i){
case 0: return '0';break;
case 1: return '1';break;
case 2: return '2';break;
case 3: return '3';break;
case 4: return '4';break;
case 5: return '5';break;
case 6: return '6';break;
case 7: return '7';break;
case 8: return '8';break;
case 9: return '9';break;
}
return 'e';
}
void
inline
LoadCarNum(int p){
FILE *tmp;
char CarFileName [15];
char t;
t = ItoA (p);
strcpy (CarFileName,"CarRoute");
strncat (CarFileName, &t,1);
if ((tmp=fopen(CarFileName,"rb"))==NULL)
printf ("CarRouteEEEEt file not opened paw!!!\n");
fread (&MaxIndexCarLocRec[p],sizeof(int),1,tmp);
CarLocAllocated[p] = MaxIndexCarLocRec[p];
if ( (CarLocationRec[p] = (struct car_location*) realloc (CarLocationRec[p],CarLocAllocated[p]*sizeof (struct car_location)) ) ==NULL)
cout << "realloc error 134341 " << endl;
for (i=0;i<MaxIndexCarLocRec[p];i++)
fread (&CarLocationRec[p][i],sizeof(struct car_location),1,tmp);
fclose(tmp);
cout << "MaxIndexCarLocRec[p] = " << MaxIndexCarLocRec[p] << endl;
}
char commandLineChar[100];
int commandLineInd = 0;
static void
Key(unsigned char key, int x, int y)
{
extern void load_configuration(char );
extern void save_configurations (char );
int jyu;
switch (key) {
case 'z': FLAG_WHICH_KEY_NEXT = save_configuration;
break;
case 'd':
FLAG_DISTORTION_WITH_TEXTURE = !FLAG_DISTORTION_WITH_TEXTURE;
FLAG_DISTORTION_WITHOUT_TEXTURE = 0;
FLAG_TEXTURE_MAP_SPHERE = !FLAG_TEXTURE_MAP_SPHERE;
fogDensity *= 1.10;
//glFogf(GL_FOG_DENSITY, fogDensity);
glutPostRedisplay();
break;
case 'D':
FLAG_DISTORTION_WITH_TEXTURE = 0;
FLAG_DISTORTION_WITHOUT_TEXTURE = !FLAG_DISTORTION_WITHOUT_TEXTURE ;
fogDensity /= 1.10;
//glFogf(GL_FOG_DENSITY, fogDensity);
glutPostRedisplay();
break;
case 'b':
if (FLAG_WHICH_KEY_NEXT == configurations){
load_configuration('b');
// PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == save_configuration){
save_configurations('b');
// PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
/* if (flag_motion == motion_carre1);
carre1_trans = carre1_trans +0.05;
if (flag_motion == motion_carre2);
carre2_trans = carre2_trans +0.05;
if (flag_motion == motion_carre3);
carre3_trans = carre3_trans +0.05; */
glutPostRedisplay();
break;
case 'n': FLAG_WHICH_KEY_NEXT = empty;
case '`' :
if (FLAG_WHICH_KEY_NEXT == configurations){
load_configuration('`');
//PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == save_configuration){
save_configurations('``');
//PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
break;
case '~' :
if (FLAG_WHICH_KEY_NEXT == configurations){
load_configuration('~');
//PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == save_configuration){
save_configurations('~');
//PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
break;
case '!' :
if (FLAG_WHICH_KEY_NEXT == configurations){
load_configuration('!');
//PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == save_configuration){
save_configurations('!');
//PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
break;
case '@' :
if (FLAG_WHICH_KEY_NEXT == configurations){
load_configuration('@');
//PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == save_configuration){
save_configurations('@');
//PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
break;
case '#' :
if (FLAG_WHICH_KEY_NEXT == configurations){
load_configuration('#');
//PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == save_configuration){
save_configurations('#');
//PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
break;
case '$' :
if (FLAG_WHICH_KEY_NEXT == configurations){
load_configuration('$');
//PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == save_configuration){
save_configurations('$');
//PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
break;
case '%' :
if (FLAG_WHICH_KEY_NEXT == configurations){
load_configuration('%');
//PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == save_configuration){
save_configurations('%');
//PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
break;
case '^' :
if (FLAG_WHICH_KEY_NEXT == configurations){
load_configuration('^');
//PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == save_configuration){
save_configurations('^');
//PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
break;
case '&' :
if (FLAG_WHICH_KEY_NEXT == configurations){
load_configuration('&');
//PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == save_configuration){
save_configurations('&');
//PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
break;
case '(' :
if (FLAG_WHICH_KEY_NEXT == configurations){
load_configuration('(');
//PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == save_configuration){
save_configurations('(');
//PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
break;
case ')' :
if (FLAG_WHICH_KEY_NEXT == configurations){
load_configuration(')');
//PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == save_configuration){
save_configurations(')');
//PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
break;
case '-' :
if (FLAG_WHICH_KEY_NEXT == configurations){
load_configuration('-');
//PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == save_configuration){
save_configurations('-');
//PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
break;
case '_' :
if (FLAG_WHICH_KEY_NEXT == configurations){
load_configuration('_');
//PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == save_configuration){
save_configurations('_');
//PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
break;
case '+' :
if (FLAG_WHICH_KEY_NEXT == configurations){
load_configuration('+');
//PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == save_configuration){
save_configurations('+');
//PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
break;
case '=' :
if (FLAG_WHICH_KEY_NEXT == configurations){
load_configuration('=');
//PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == save_configuration){
save_configurations('=');
//PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
break;
case '{' :
if (FLAG_WHICH_KEY_NEXT == configurations){
load_configuration('{');
//PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == save_configuration){
save_configurations('{');
//PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
break;
case '[' :
if (FLAG_WHICH_KEY_NEXT == configurations){
load_configuration('[');
//PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == save_configuration){
save_configurations('[');
//PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
break;
case '}' :
if (FLAG_WHICH_KEY_NEXT == configurations){
load_configuration('}');
//PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == save_configuration){
save_configurations('}');
//PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
break;
case ']' :
if (FLAG_WHICH_KEY_NEXT == configurations){
load_configuration(']');
//PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == save_configuration){
save_configurations(']');
//PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
break;
case 'p' :
if (FLAG_WHICH_KEY_NEXT == configurations){
load_configuration('p');
//PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == save_configuration){
save_configurations('p');
//PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
break;
case 'P' :
if (FLAG_WHICH_KEY_NEXT == configurations){
load_configuration('P');
//PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == save_configuration){
save_configurations('P');
//PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
break;
case 'O' :
if (FLAG_WHICH_KEY_NEXT == configurations){
load_configuration('O');
//PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == save_configuration){
save_configurations('O');
//PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
break;
case 'o' :
if (FLAG_WHICH_KEY_NEXT == configurations){
load_configuration('o');
//PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == save_configuration){
save_configurations('o');
//PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
break;
case 'i' :
if (FLAG_WHICH_KEY_NEXT == configurations){
load_configuration('i');
//PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == save_configuration){
save_configurations('i');
//PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == lights)
flag_motion_command = flag_change_light_intensity;
break;
case 'I' :
if (FLAG_WHICH_KEY_NEXT == configurations){
load_configuration('I');
//PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == save_configuration){
save_configurations('I');
//PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
break;
case 'u' :
if (FLAG_WHICH_KEY_NEXT == configurations){
load_configuration('u');
//PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == save_configuration){
save_configurations('u');
//PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
break;
case 'U' :
if (FLAG_WHICH_KEY_NEXT == configurations){
load_configuration('U');
//PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == save_configuration){
save_configurations('U');
//PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
break;
case 'y' :
if (FLAG_WHICH_KEY_NEXT == configurations){
load_configuration('y');
//PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == save_configuration){
save_configurations('y');
//PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
break;
case 'Y' :
if (FLAG_WHICH_KEY_NEXT == configurations){
load_configuration('Y');
//PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == save_configuration){
save_configurations('Y');
//PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
break;
case 'c':
/*if (flag_motion == motion_carre1);
carre1_trans = carre1_trans -0.05;
if (flag_motion == motion_carre2);
carre2_trans = carre2_trans -0.05;
if (flag_motion == motion_carre3);
carre3_trans = carre3_trans -0.05;*/
eyec.x = eye.x;
eyec.y = eye.y;
eyec.z = eye.z;
glutPostRedisplay();
break;
case ' ': if (flag_motion_win == top_view_com)
flag_motion_win = big_win_com;
else
flag_motion_win = top_view_com;
break;
case 's': if (SHOW_LOCATION_DIRECTION_OF_LIGHTS) {
SHOW_LOCATION_DIRECTION_OF_LIGHTS = 0;
cout << "lights are hidden " << endl;
} else {
SHOW_LOCATION_DIRECTION_OF_LIGHTS = 1;
cout << "lights are shown" << endl;
}
break;
case 'l': FLAG_WHICH_KEY_NEXT = lights;
break;
case 'L': FLAG_WHICH_KEY_NEXT = load_car_num;
break;
case 'w': FLAG_WHICH_KEY_NEXT = walk_slowly;
break;
case 't': if (FLAG_WHICH_KEY_NEXT == lights)
FLAG_WHICH_KEY_NEXT = lights_translate;
break;
case 'r': if (FLAG_WHICH_KEY_NEXT == lights)
FLAG_WHICH_KEY_NEXT = lights_rotate;
break;
case 'R': FLAG_WHICH_KEY_NEXT = recordCarMvmt;
RECORD_CAR_MVMT = 0;
// Write to file if RecRouteNum !=999
if (RecRouteNum != 999){
//PlaySound ("WritingCoordinateToFile.wav",NULL,SND_ASYNC);
FILE *tmp;
char CarFileName [15];
char t;
t = ItoA (RecRouteNum);
strcpy (CarFileName,"CarRoute");
strncat (CarFileName, &t,1);
if ((tmp=fopen(CarFileName,"wb"))==NULL)
printf ("CarPath file not opened \n");
fwrite (&IndexCarLocRec[RecRouteNum],sizeof(int),1,tmp);
for (jyu=0;jyu<IndexCarLocRec[RecRouteNum];jyu++)
fwrite (&CarLocationRec[RecRouteNum][jyu],sizeof(struct car_location),1,tmp);
fclose(tmp);
cout << "IndexCarLocRec[RecRouteNum] = " << IndexCarLocRec[RecRouteNum] << endl;
}
// We are not recording any route anymore.
RecRouteNum =999; // The RecRouteNum is the Route Number that is being Recorde.
// If RecRouteNum == 999 => we are not recording any route...
break;
case '0': if (FLAG_WHICH_KEY_NEXT == lights_translate)
flag_motion_command = flag_move_light0; else
if (FLAG_WHICH_KEY_NEXT == lights_rotate)
flag_motion_command = flag_rotate_light0;
if (FLAG_WHICH_KEY_NEXT == save_configuration){
save_configurations('0');
//PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == configurations){
load_configuration('0');
//PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == load_car_num){
LoadCarNum(0);
RouteNum[0]=1; // Activates the Route num 0
}
if (FLAG_WHICH_KEY_NEXT == recordCarMvmt){
RECORD_CAR_MVMT = 1; // Flag to say that we are recording a route #
RecRouteNum = 1; // The RecRouteNum is the Route Number that is being Recorde.
// If RecRouteNum == 999 => we are not recording any route...
//PlaySound ("ReadingCoordinateToMemory.wav",NULL,SND_ASYNC);
}
break;
case 'C': FLAG_WHICH_KEY_NEXT = configurations;
break;
case 'G' : flag_motion = rotating_Geye;
//PlaySound("RotatingGodsVehicleCentricEye.wav", NULL, SND_ASYNC);
break;
case 'g' : FLAG_MOVE_GODS_EYE = 1;
break;
case 'v' : FLAG_MOVE_GODS_EYE = 2;
break;
case 'V' : FLAG_MOVE_GODS_EYE = 3;
break;
case 'S' : FLAG_MOVE_GODS_EYE =4;
break;
case '1': if (FLAG_WHICH_KEY_NEXT == lights_translate)
flag_motion_command = flag_move_light1; else
if (FLAG_WHICH_KEY_NEXT == lights_rotate)
flag_motion_command = flag_rotate_light1; else
if (FLAG_WHICH_KEY_NEXT == lights) {
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
glEnable(GL_LIGHTING);
}
if (FLAG_WHICH_KEY_NEXT == walk_slowly){
WALK_SLOWLY = 0; // does not affect the rate of walking.
SlowIt = 1.0;
//PlaySound ("NoSlowing.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == configurations){
load_configuration('1');
//PlaySound ("configuration1.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == save_configuration){
save_configurations('1');
// PlaySound ("configuration1Saved.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == load_car_num){
LoadCarNum(1);
RouteNum[1]=1; // Activates the Route num 1
}
if (FLAG_WHICH_KEY_NEXT == recordCarMvmt){
RECORD_CAR_MVMT = 1; // Flag to say that we are recording a route #
RecRouteNum = 1; // The RecRouteNum is the Route Number that is being Recorde.
// If RecRouteNum == 999 => we are not recording any route...
//PlaySound ("ReadingCoordinateToMemory.wav",NULL,SND_ASYNC);
}
break;
case '2': if (FLAG_WHICH_KEY_NEXT == lights) {
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
glEnable (GL_LIGHTING);
}
if (FLAG_WHICH_KEY_NEXT == walk_slowly){
WALK_SLOWLY = 1; //start walking slower.
SlowIt = 2.0;
//PlaySound ("SlowingTwice.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == save_configuration){
save_configurations('2');
//PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == configurations){
load_configuration('2');
//PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == load_car_num){
LoadCarNum(2);
RouteNum[2]=1; // Activates the Route num 2
}
if (FLAG_WHICH_KEY_NEXT == recordCarMvmt){
RECORD_CAR_MVMT = 1; // Flag to say that we are recording a route #
RecRouteNum = 2; // The RecRouteNum is the Route Number that is being Recorde.
// If RecRouteNum == 999 => we are not recording any route...
//PlaySound ("ReadingCoordinateToMemory.wav",NULL,SND_ASYNC);
}
break;
case '3': if (FLAG_WHICH_KEY_NEXT == lights) {
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
glEnable (GL_LIGHTING);
}
if (FLAG_WHICH_KEY_NEXT == walk_slowly){
WALK_SLOWLY = 1; //start walking slower.
SlowIt = 3.0;
//PlaySound ("Slowing3times.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == save_configuration){
save_configurations('3');
//PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == configurations){
load_configuration('3');
//PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == recordCarMvmt){
RECORD_CAR_MVMT = 1; // Flag to say that we are recording a route #
RecRouteNum = 3; // The RecRouteNum is the Route Number that is being Recorde.
// If RecRouteNum == 999 => we are not recording any route...
//PlaySound ("ReadingCoordinateToMemory.wav",NULL,SND_ASYNC);
}
if (FLAG_WHICH_KEY_NEXT == load_car_num){
LoadCarNum(3);
RouteNum[3]=3; // Activates the Route num 3
}
break;
case '4': if (FLAG_WHICH_KEY_NEXT == lights) {
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
glEnable (GL_LIGHTING);
}
if (FLAG_WHICH_KEY_NEXT == walk_slowly){
WALK_SLOWLY = 1; //start walking slower.
//PlaySound ("Slowing4times.wav",NULL,SND_ASYNC); //WinUnix
SlowIt = 4.0;
}
if (FLAG_WHICH_KEY_NEXT == save_configuration){
save_configurations('4');
//PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == configurations){
load_configuration('4');
//PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == load_car_num){
LoadCarNum(4);
RouteNum[4]=1; // Activates the Route num 4
}
if (FLAG_WHICH_KEY_NEXT == recordCarMvmt){
RECORD_CAR_MVMT = 1; // Flag to say that we are recording a route #
RecRouteNum = 4; // The RecRouteNum is the Route Number that is being Recorde.
// If RecRouteNum == 999 => we are not recording any route...
//PlaySound ("ReadingCoordinateToMemory.wav",NULL,SND_ASYNC);
}
break;
case '5': if (FLAG_WHICH_KEY_NEXT == lights) {
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
glEnable (GL_LIGHTING);
}
if (FLAG_WHICH_KEY_NEXT == walk_slowly){
WALK_SLOWLY = 1; //start walking slower.
SlowIt = 5.0;
//PlaySound ("Slowing5times.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == save_configuration){
save_configurations('5');
//PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == configurations){
load_configuration('5');
//PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == load_car_num){
LoadCarNum(5);
RouteNum[5]=5; // Activates the Route num 5
}
if (FLAG_WHICH_KEY_NEXT == recordCarMvmt){
RECORD_CAR_MVMT = 1; // Flag to say that we are recording a route #
RecRouteNum = 5; // The RecRouteNum is the Route Number that is being Recorde.
// If RecRouteNum == 999 => we are not recording any route...
//PlaySound ("ReadingCoordinateToMemory.wav",NULL,SND_ASYNC);
}
break;
case '6': if (FLAG_WHICH_KEY_NEXT == lights) {
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
glEnable (GL_LIGHTING);
}
if (FLAG_WHICH_KEY_NEXT == walk_slowly){
WALK_SLOWLY = 1; //start walking slower.
SlowIt = 6.0;
//PlaySound ("Slowing6times.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == save_configuration){
save_configurations('6');
//PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == configurations){
load_configuration('6');
//PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == load_car_num){
LoadCarNum(6);
RouteNum[6]=1; // Activates the Route num 6
}
if (FLAG_WHICH_KEY_NEXT == recordCarMvmt){
RECORD_CAR_MVMT = 1; // Flag to say that we are recording a route #
RecRouteNum = 6; // The RecRouteNum is the Route Number that is being Recorde.
// If RecRouteNum == 999 => we are not recording any route...
//PlaySound ("ReadingCoordinateToMemory.wav",NULL,SND_ASYNC);
}
break;
case '7': if (FLAG_WHICH_KEY_NEXT == lights) {
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
glEnable (GL_LIGHTING);
}
if (FLAG_WHICH_KEY_NEXT == walk_slowly){
WALK_SLOWLY = 1; //start walking slower.
SlowIt = 7.0;
//PlaySound ("Slowing7times.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == save_configuration){
save_configurations('7');
//PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == configurations){
load_configuration('7');
//PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == load_car_num){
LoadCarNum(7);
RouteNum[7]=1; // Activates the Route num 7
}
if (FLAG_WHICH_KEY_NEXT == recordCarMvmt){
RECORD_CAR_MVMT = 1; // Flag to say that we are recording a route #
RecRouteNum = 7; // The RecRouteNum is the Route Number that is being Recorde.
// If RecRouteNum == 999 => we are not recording any route...
//PlaySound ("ReadingCoordinateToMemory.wav",NULL,SND_ASYNC);
}
break;
case '8': if (FLAG_WHICH_KEY_NEXT == lights) {
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
glEnable (GL_LIGHTING);
}
if (FLAG_WHICH_KEY_NEXT == walk_slowly){
WALK_SLOWLY = 1; //start walking slower.
SlowIt = 8.0;
//PlaySound ("Slowing8times.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == save_configuration){
save_configurations('8');
//PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == configurations){
load_configuration('8');
//PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == load_car_num){
LoadCarNum(8);
RouteNum[8]=1; // Activates the Route num 8
}
if (FLAG_WHICH_KEY_NEXT == recordCarMvmt){
RECORD_CAR_MVMT = 1; // Flag to say that we are recording a route #
RecRouteNum = 8; // The RecRouteNum is the Route Number that is being Recorde.
// If RecRouteNum == 999 => we are not recording any route...
//PlaySound ("ReadingCoordinateToMemory.wav",NULL,SND_ASYNC);
}
break;
case '9': if (FLAG_WHICH_KEY_NEXT == lights) {
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
glEnable (GL_LIGHTING);
}
if (FLAG_WHICH_KEY_NEXT == walk_slowly){
WALK_SLOWLY = 1; //start walking slower.
SlowIt = 35.0;
//PlaySound ("Slowing9times.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == save_configuration){
save_configurations('9');
//PlaySound ("savingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == configurations){
load_configuration('9');
//PlaySound ("loadingconfiguration.wav",NULL,SND_ASYNC); //WinUnix
}
if (FLAG_WHICH_KEY_NEXT == load_car_num){
LoadCarNum(9);
RouteNum[9]=1; // Activates the route num 9.
}
if (FLAG_WHICH_KEY_NEXT == recordCarMvmt){
RECORD_CAR_MVMT = 1; // Flag to say that we are recording a route #
RecRouteNum = 9; // The RecRouteNum is the Route Number that is being Recorde.
// If RecRouteNum == 999 => we are not recording any route...
//PlaySound ("ReadingCoordinateToMemory.wav",NULL,SND_ASYNC);
}
break;
case 'f': LIGHTS_FIX_WITH_CAMERA = !LIGHTS_FIX_WITH_CAMERA;
break;
case 'q' : flag_motion_command = motion_carre1;
break;
case 'Q' : flag_motion_command = motion_carre2;
break;
case 'a': CRot.x = eyec.x - eye.x;
CRot.y = eyec.y - eye.y;
CRot.z = eyec.z - eye.z;
// RecalculateRotatedPoints(CNC,mc);
//TranslatePoints (CNC,CRot);
eyec.x = eye.x;
eyec.y = eye.y;
eyec.z = eye.z;
//PlaySound ("RotationMovedToYourEyeLocation.wav",NULL,SND_ASYNC); //WinUnix
break;
case 27:
exit(0);
}
commandLineChar[commandLineInd] = key;
commandLineInd++;
if (key == 13){ // if we pressed on the key enter
commandLineChar[commandLineInd-1] = 0; // wipes out the enter char from the end of the
// stream so that the next strcmp works well.
// Command: 'stereo natt'
if (strcmp (commandLineChar,"stereo natt")==0){
FLAG_STEREO_NATT = !FLAG_STEREO_NATT;
FLAG_STEREO = 0;
}
// Command: 'stereo'
if (strcmp (commandLineChar,"stereo")==0){
FLAG_STEREO = !FLAG_STEREO;
FLAG_STEREO_NATT = 0;
}
// Command: 'F'
if (strcmp (commandLineChar, "F")==0){
cout << "give the friction coef. " ;
cin >> Friction_coef ;
}
commandLineInd = 0; // Reset the commandLineInd so that to take new entry.
strcpy (commandLineChar, "");// Reset the commandLineChar so that to take new entry.
} // if (key == 13) if we pressed on the key enter.
}
static void
SpecialKey(int key, int x, int y)
{
switch (key) {
case GLUT_KEY_UP:
DRAW_CARRE1 = 1;
carre1 = carre1 + (deltaz/100);
glutPostRedisplay();
break;
case GLUT_KEY_DOWN:
DRAW_CARRE1 = 1;
carre1 = carre1 - (deltaz/100);
glutPostRedisplay();
break;
case GLUT_KEY_LEFT:
carre1_trans = carre1_trans-0.03;
glutPostRedisplay();
break;
case GLUT_KEY_RIGHT:
carre1_trans = carre1_trans+0.03;
glutPostRedisplay();
break;
case GLUT_KEY_INSERT: // Expand carre.
if (expand_carre1)
expand_carre1 = 0;
else
expand_carre1 = 1;
glutPostRedisplay();
break;
}
}
/* Keyboard menu:
// LIGHTS
s: shows and hides (Toggles) the lights. It does not turn them on
and off, rather it only shows their location / or orientation.
z# : Saves configuration number #.
C# : Puts us in Configuration number #.
G : rotates Rotating Gods Vehicle Centric Eye (symbolic or non symbolic).
g : Move and rotate God's eye camera. (on mirror 0)
v : Switches on the vehicle centric display. (on mirror 0)
V : Switches on the Vehicle symbolic gods eye. (on mirror 0)
S : Switches to the Green Sensors gods eye.
lt0: Lights Translate 0 Translates light number Zero towards or away
from the Center_Of_Rot_Of_Lights which is a code variable.
lt1: Lights Translate 1 Translates light number One towards or away
from the Center_Of_Rot_Of_Lights which is a code variable.
lr0: Lights rotate 0 rotates light number Zero around
the Center_Of_Rot_Of_Lights which is a code variable.
lr1: Lights rotate 1 rotates light number One around
the Center_Of_Rot_Of_Lights which is a code variable.
l1 : turns glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
l2 : turns glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
li : makes the intensity of the light more or less.
L# : Loads CarRoot # into memory and Activates rendering it.
R# R: Record Route #. Then pressing R again writes it on disk, and stop
Recording
d : Toggles Dom mode with Normal mode.
f : Toggles between fixing the lights t the camera or to the scene.
w? : Slows the translationS ? times.
c : Shows the car wherever it is...
n : resets the FLAG_WHICH_NEXT_KEY TO nothing.
q : gives you just a dummy variable that you can change interactively using the middle mouse buuton
This dummy variable is used now for making the angle of the camera looking at the dome bigger or smaller
Q : Same as q but makes the camera cames towards or away from the dome. (dummy variable carre2.)
Joystick interface.
Stick button right: walk in the city.
Stick button right down: Adjust car.
Stick button left : Drive.
"stereo" : toggles stereo on and off.
*/