home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.hitl.washington.edu
/
ftp.hitl.washington.edu.tar
/
ftp.hitl.washington.edu
/
pub
/
people
/
habib
/
VirtCity
/
glut_viewer.cc~
< prev
next >
Wrap
Text File
|
2000-04-24
|
66KB
|
2,390 lines
// By Habib Abi-Rached
// Summer 1997.
// Intern in Ford Motor.
// Parts of code taken from Mark J. Kilgard, 1994.
// Using Glut / OpenGl
// Implementation of Data Desk using Stereo-Vision.
#include <stdio.h>
#include <iostream.h>
#include <stdlib.h>
#include <string.h>
#include <math.h> /* for cos(), sin(), and sqrt() */
#include <GL/glut.h>
#include "trackball.h"
#define FLAG int
float zero1 = 0.0;
float zero2 = 0.0;
float NaN = 999999999;
extern void add_quats (float, float, float);
extern void add_quats (float *, float *, float *);
typedef enum {
RESERVED, BODY_SIDE, BODY_EDGE, BODY_WHOLE, ARM_SIDE, ARM_EDGE, ARM_WHOLE,
LEG_SIDE, LEG_EDGE, LEG_WHOLE, EYE_SIDE, EYE_EDGE, EYE_WHOLE, DINOSAUR
} displayLists;
GLfloat angle = -150; /* in degrees */
GLboolean doubleBuffer = GL_TRUE, iconic = GL_FALSE, keepAspect = GL_FALSE;
int beginx, beginy;
float curquat[4];
float lastquat[4];
GLdouble bodyWidth = 2.0;
int dinosor =0;
int newModel = 1;
float scalefactor = 1.0;
GLdouble TOP = 1; /* it is the limits of the bounding box */
GLdouble BOTTOM = -1; /* it is the limits of the bounding box */
GLdouble LEFT = -13.8/10.5; /* it is the limits of the bounding box */
GLdouble RIGHT = 13.8/10.5; /* it is the limits of the bounding box */
GLdouble NEAR2 = 0;
GLdouble FAR2 = 3;
/* *INDENT-OFF* */
GLfloat body[][2] = { {0, 3}, {1, 1}, {5, 1}, {8, 4}, {10, 4}, {11, 5},
{11, 11.5}, {13, 12}, {13, 13}, {10, 13.5}, {13, 14}, {13, 15}, {11, 16},
{8, 16}, {7, 15}, {7, 13}, {8, 12}, {7, 11}, {6, 6}, {4, 3}, {3, 2},
{1, 2} };
GLfloat arm[][2] = { {8, 10}, {9, 9}, {10, 9}, {13, 8}, {14, 9}, {16, 9},
{15, 9.5}, {16, 10}, {15, 10}, {15.5, 11}, {14.5, 10}, {14, 11}, {14, 10},
{13, 9}, {11, 11}, {9, 11} };
GLfloat leg[][2] = { {8, 6}, {8, 4}, {9, 3}, {9, 2}, {8, 1}, {8, 0.5}, {9, 0},
{12, 0}, {10, 1}, {10, 2}, {12, 4}, {11, 6}, {10, 7}, {9, 7} };
GLfloat eye[][2] = { {8.75, 15}, {9, 14.7}, {9.6, 14.7}, {10.1, 15},
{9.6, 15.25}, {9, 15.25} };
GLfloat skinColor[] = {0.1, 1.0, 0.1, 1.0}, eyeColor[] = {1.0, 0.2, 0.2, 1.0};
// Structures --------------------------------------------------------------------------- Structures
// Structures -------------------------------------------------------------------------- Structures
// Structures -------------------------------------------------------------------------- Structures
struct bmm {
double bar; /*pr calc xmin xbar xmax ymin... */
double min; /*sans parcourir a chaque fois */
double max; /*trois fois l'array xc, yc, zc. */
} ;
struct color {
char r;
char g;
char b;
};
struct scr_bar
{
// corner of the green square
int x_g_min, x_g_max, y_g_min, y_g_max;
// corner of the red square
int x_r_min, x_r_max, y_r_min, y_r_max;
// corners of the middle square.
int x_m_min, x_m_max, y_m_min, y_m_max;
// corners of the higher triangle
int x_ht_min, x_ht_max, y_ht_min, y_ht_max;
// corners of the lower triangle
int x_lt_min, x_lt_max, y_lt_min, y_lt_max;
};
struct rect
{
int xmin, xmax, ymin, ymax;
};
// Variables of my data (The Cloud of points) ------------------------- Variables of my data (The Cloud of points)
// Variables of my data (The Cloud of points) ------------------------- Variables of my data (The Cloud of points)
// Variables of my data (The Cloud of points) ------------------------- Variables of my data (The Cloud of points)
float *var[100]; // Contains all the variables at hand.
float *var_animation;
float var_animation_min;
float var_animation_max;
char var_name[100][40];
int nbr_of_col = 0;
float *zc; // Contain the z value 4th column (cloud of pts)
float *yc; // Contain the y value 3rd column (cloud of pts)
float *xc; // Contain the x value 2nd column (cloud of pts)
int *col1; // I have 5 column in my data this is the first one
int *col4; // I have 5 column in my data this is the 5th one
float *czz; /* arrays containg the color information of the 3D pts */
float *cyy; /* arrays containg the color information of the 3D pts */
float *cxx; /* arrays containg the color information of the 3D pts */
double xmin,xmin_e ;
double xmax,xmax_e ;
double ymin,ymin_e ;
double ymax,ymax_e ;
double zmin,zmin_e ;
double zmax,zmax_e ;
double delta_min;
double sig_min;
double deltax ; // abs (xmax-xmin)
double deltay ; // abs (ymax-ymin)
double deltaz ; // abs (zmax-zmin)
double deltax_n ; // abs (xmax-xmin) after normalization to have normalized scaling
double deltay_n ; // abs (ymax-ymin) after normalization to have normalized scaling
double deltaz_n ; // abs (zmax-zmin) after normalization to have normalized scaling
double xbar = 1; /* Ce sont les coordonnes du */
double ybar = 2; /* centre du gravite de la */
double zbar = 3; /* carte de profondeur */
double sigx; // sigmax
double sigy; // sigmay
double sigz; // sigmaz
double sig_x_n; // sigmax after normalization to have normalized scaling
double sig_y_n; // sigmay after normalization to have normalized scaling
double sig_z_n; // sigmaz after normalization to have normalized scaling
int dim[1]; // Number of 3D points => dim[0]-1 is the last indice. [of the point with the Nans].
// Variables for my camera -------------------------------------------- Variables for my camera
// Variables for my camera -------------------------------------------- Variables for my camera
// Variables for my camera -------------------------------------------- Variables for my camera
double transX, transY, transZ;
double baseline = -1.14; // 0.2;
double eyex,eyey,eyez,upx,upy,upz,sidex,sidey,sidez,teta=0,phi=0,teta2;
// Flags ------------------------------------------------------------------------------------------------ Flags
// Flags ------------------------------------------------------------------------------------------------ Flags
// Flags ------------------------------------------------------------------------------------------------ Flags
FLAG DRAW_CARRE1 = 0;
FLAG DRAW_CARRE2 = 0;
FLAG DRAW_CARRE3 = 0;
FLAG FLAG_X_SMALLER_THAN_100 = 0;
FLAG TOGGLE_BOX = 0;
FLAG TRANSLATE_TO_GRAVITY=0;
FLAG TRANSLATE_TO_MIDDLE =1;
FLAG displayListInited = 0;
FLAG Draw_relative_axe = 1;
FLAG spinning = 0;
FLAG expand_carre1 = 0;
FLAG expand_carre2 = 0;
FLAG expand_carre3 = 0;
FLAG APPLY_MOUSE_MOTION = 0;
enum {baseline_zoom, rotating, translating, scaling, motion_carre1, motion_carre2, motion_carre3, vertical_adj}
flag_motion, flag_motion_command;
FLAG VIRGULE = 0;
FLAG VIRGULE_AT_END_OF_LINE = 0;
enum {up, down, bandflag}
flag_elevator;
// int SCALE_DEFAULT = 1 ; not necessary since by default it's 1!!!
int SCALE_SIGMA = 0 ;
int SCALE_MIDDLE = 1 ;
// OpenGl Variables. --------------------------------------------------------------------- OpenGl Variables.
// OpenGl Variables. --------------------------------------------------------------------- OpenGl Variables.
// OpenGl Variables. --------------------------------------------------------------------- OpenGl Variables.
double pt_size = 1.0;
int fraction =1 ; // the fraction of the points displayed.
float fogDensity = 0.02;
// strings strings -----------------------------------------------------------------strings
// strings strings -----------------------------------------------------------------strings
// strings strings -----------------------------------------------------------------strings
char string1[40]; // Z Blue.
char string2[40]; // Y Green.
char string3[40]; // X RED.
char string4[]="Stereo_zoom";
char string5[]="Zoom";
char string6[]="Animation";
char string7[]="Vert_adj.";
char string8[]="Color.";
char string9[]="Pt_Size";
// Variables for the viewport -------------------------------------- Variables for the viewport
// Variables for the viewport--------------------------------------- Variables for the viewport
// Variables for the viewport -------------------------------------- Variables for the viewport
FLAG viewport = 1; // initially no command bar.
struct scr_bar
sb_c1[1], sb_c2[1], sb_c3[1];
struct rect
stereo_zoom_rect[1],scaling_rect[1],animation_rect[1],vertical_adj_rect[1], color_rect[1], pt_size_rect[1];
// Variables for the elevator------------------------------------- Variables for the elevator
// Variables for the elevator------------------------------------- Variables for the elevator
// Variables for the elevator------------------------------------- Variables for the elevator
struct rect
up_rect[1], down_rect[1],band_rect[1];
float band; //determins the band width of highlight points.
float thresh; // threshhold for window2 (the elevator) (The line).
// GLUT Variables -------------------------------------------------------------------- GLUT Variables
// GLUT Variables -------------------------------------------------------------------- GLUT Variables
// GLUT Variables -------------------------------------------------------------------- GLUT Variables
int Menu1_id,Menu2_id;
int X,Y;
int W = 930, H = 350;
int W2 = 400, H2 = 100;
int vav = 33; // vav = vertical adjustment value.
int win; // identifier of the big big windoooooow...
// Variables -------------------------------------------------------------------- Variables
// Variables -------------------------------------------------------------------- Variables
// Variables -------------------------------------------------------------------- Variables
double carre1 = 0;
double carre2 = 0;
double carre3 = 0;
double carre1_trans=0.5;
double carre2_trans=0.5;
double carre3_trans=0.5;
float lUPt[16][3] = { 1 , 0 , 0 ,
0 , 1 , 0 ,
0 , 0 , 1 ,
1 , 0.8, 0.3,
0.8, 1 , 0.3,
0.8, 0.3, 1,
1 , 1 , 0 ,
1 , 0 , 1 ,
0 , 1 , 1 ,
1 , 0.3, 0.8,
0.3, 1 , 0.8,
0.3, 0.8, 1,
0.5 , 0.5 , 1,
0.5 , 1 , 0.5,
1 , 0.5, 0.5,
1 , 1 , 1} ;
int i;
void
inputdollar (char phrase[70])
{
char mot[20] ;
char blanc [2];
blanc[0] = ' ';
strcpy (phrase,""); /* pour vider input car on va lui faire un strcat. */
printf ("---> ");
while (blanc[0] == ' ')
{
scanf ("%s",mot);
scanf ("%1c",blanc);
strcat (phrase,mot);
strncat (phrase,blanc,1);
}
}
void
showMessage(GLfloat x, GLfloat y, GLfloat z, char *message)
{
glPushMatrix();
glDisable(GL_LIGHTING);
glRasterPos3f(x,y,z);
//glScalef(.02, .02, .02);
while (*message) {
//glutStrokeCharacter(GLUT_STROKE_ROMAN, *message);
glutBitmapCharacter(GLUT_BITMAP_8_BY_13, *message);
message++;
}
glPopMatrix();
if (dinosor) glEnable(GL_LIGHTING);
}
/*________________________trouver____________________________________*/
/* c'est une fct qui calcul la moyenne */
/* d'un tableau TABC et le min et le */
/* et le max du meme TABC et renvoie */
/* ces 3 valeurs en renvoyant une struc*/
struct bmm trouver (float *tabc,int dim[1])
{ int i;
int local_dim = dim[0];
struct bmm bmm2;
bmm2.bar=0;
bmm2.min=tabc[0];
bmm2.max=tabc[0];
for (i=0; i<dim[0]; i++)
{
if (tabc[i] != NaN) {
bmm2.bar = bmm2.bar + tabc [i];
if (tabc[i]<bmm2.min) bmm2.min = tabc[i];
if (tabc[i]>bmm2.max) bmm2.max = tabc[i];
}
else local_dim = local_dim -1;
}
bmm2.bar = bmm2.bar/local_dim;
return bmm2;
}
/*_____________________trouver_bar_min_max_________________________*/
/* c'est une fct qui calcul le bar, max et min */
/* de 3 tableaux: xc, yc, zc. */
trouver_bar_min_max_sig(float *xc,float *yc, float* zc,int dim[1])
{ struct bmm bmm1;
bmm1=trouver (xc,dim);
xmax = bmm1.max;
xbar = bmm1.bar;
xmin = bmm1.min;
bmm1=trouver (yc,dim);
ymax = bmm1.max;
ybar = bmm1.bar;
ymin = bmm1.min;
bmm1=trouver (zc,dim);
zmax = bmm1.max;
zbar = bmm1.bar;
zmin = bmm1.min;
// Calculating sigma and taking care of NaN.
sigx = sigy = sigz = 0;
int dimx, dimy, dimz; // to take care of NaN.
dimx = dimy = dimz = dim[0];
for (int i=0; i< dim[0]; i++){
if (xc[i] != NaN)
sigx = sigx + (xbar - xc[i]) * (xbar - xc[i]);
else dimx = dimx -1;
if (yc[i] != NaN)
sigy = sigy + (ybar - yc[i]) * (ybar - yc[i]);
else (dimy = dimy -1);
if (zc[i] != NaN)
sigz = sigz + (zbar - zc[i]) * (zbar - zc[i]);
else (dimz = dimz -1);
}
sigx = sigx/dimx;
sigy = sigy/dimy;
sigz = sigz/dimz;
sigx = sqrt (sigx);
sigy = sqrt (sigy);
sigz = sqrt (sigz);
// Normalizing sigma so that when we scale it keeps the smallest axes fix.
if ((sigx<sigy) && (sigx<sigz)) sig_min = sigx;
else
if ((sigy<sigx) && (sigy<sigz)) sig_min = sigy;
else sig_min = sigz;
sig_x_n = sigx/sig_min;
sig_y_n = sigy/sig_min;
sig_z_n = sigz/sig_min;
// Calculating delta.
deltax = fabs(xmax - xmin);
deltay = fabs(ymax - ymin);
deltaz = fabs(zmax - zmin);
// Normalizing sigma so that when we scale it keeps the smallest axes fix.
if ((deltax<deltay) && (deltax<deltaz)) delta_min = deltax;
else
if ((deltay<deltax) && (deltay<deltaz)) delta_min = deltay;
else delta_min = deltaz;
deltax_n = deltax/delta_min;
deltay_n = deltay/delta_min;
deltaz_n = deltaz/delta_min;
// Calculating xmin_e ... for some extraneous uses...
xmin_e = xmin - 0.3*deltax;
ymin_e = ymin - 0.3*deltay;
zmin_e = zmin - 0.3*deltaz;
xmax_e = xmax + 0.3*deltax;
ymax_e = ymax + 0.3*deltay;
zmax_e = zmax + 0.3*deltaz;
cout << "xmax=" << xmax << " ymax=" << ymax << " zmax=" << zmax << endl;
cout << "xmin=" << xmin << " ymin=" << ymin << " zmin=" << zmin << endl;
cout << "xbar=" << xbar << " ybar=" << ybar << " zbar=" << zbar << endl;
cout << "sigx="<< sigx << " sigy=" << sigy << " sigz=" << sigz << endl;
cout << "sig_x_n="<< sig_x_n << " sig_y_n=" << sig_y_n << " sig_z_n=" << sig_z_n << endl;
cout << "xmax-xmin=" << xmax - xmin << " ymax-ymin=" << ymax - ymin << " zmax-zmin=" << zmax - zmin << endl;
cout << "deltax=" << deltax << " deltay="<< deltay << " deltaz=" << deltaz << endl;
cout << "deltax_n=" << deltax_n << " deltay_n="<< deltay_n << " deltaz_n=" << deltaz_n << endl;
}
void
load_data_NZP ()
{
// initializing the look up table.
int fin,i,choice;
int pts = 1000;
char joumlat[10000];
FILE *file;
char filename[70];
char fileroot[70];
i=0;
strcpy (fileroot,"./");
cout << "Please give the name of the file : " ;
cin >> filename;
strcat (fileroot,filename);
printf ("loading ...\n");
if ((file = fopen (fileroot,"r")) == NULL)
// if ((file = fopen ("/ford/sl1426/u/habirach/c/data/data.hab","r")) == NULL)
printf ("mako1 it's not opening the NZP file \n");
// Reading the first line of the file + prompting the user
// to get rid of the junk. Junk will point AT the last char read.
int junk = 0; // contains the junk
int junkl = 0; // contains the junk + the last line read
choice = 3;
while (choice == 3){
junk = junkl;
joumlat[junkl] = '-'; // initializing joumlat[junk]
cout << endl << endl;
cout << "*********************************************************"<< endl;
while (joumlat[junkl] !='\n'){
junkl++;
fscanf (file, "%1c",&joumlat[junkl]);
cout << joumlat[junkl] ;
}
cout << "*********************************************************"<< endl;
cout << endl << endl;
cout << "* 1) Use as a header *"<< endl;
cout << "* 2) Start loading *"<< endl;
cout << "* 3) Skip row *"<< endl;
cout << " Press 1,2 or 3 ---> ";
cin >> choice;
}
cout << "How Many points do you want to load ? " ;
cin >> pts;
// Setting the VIRGULE FLAG.
char harf [2];
harf[0] = 't';
while (harf[0]!='\n'){
fscanf (file, "%1c",&harf[0]);
if (harf[0] == ',') VIRGULE = VIRGULE + 1;
}
// counting the number of columns and placing the file pointer on the first number.
nbr_of_col = 0;
float f;
harf[0] = 't';
while (harf[0] != '\n'){
while ( (harf[0]!=32) && (harf[0]!=9) && (harf[0]!=',') && (harf[0]!='\n')) // scan the first number
fscanf (file, "%1c",&harf[0]);
nbr_of_col++;
while ( (harf[0]==32) || (harf[0]==9) || (harf[0]==',') ) // scan the following del.
fscanf (file, "%1c",&harf[0]);
}
fflush(file);
fclose(file);
if ((file = fopen (fileroot,"r")) == NULL) // Reopening the file
printf ("mako2 it's not opening the NZP file \n");
for (i = 0; i<junk-1; i++){ // Passing all the junk again.
fscanf (file, "%1c",&joumlat[i]);
}
fscanf (file, "%1c",&joumlat[i]);
// set VIRGULE_AT_END_OF_LINE
if (VIRGULE == nbr_of_col) VIRGULE_AT_END_OF_LINE = 1;
// Load the damn data!!
int dim_list_points = 0;
if (choice == 1){
if (!VIRGULE){
for (i=0; i<nbr_of_col; i++){
fscanf (file, "%s",var_name[i]);
cout << var_name[i] << endl;
}
}
if (VIRGULE){
for (i=0; i<nbr_of_col; i++){
int j = 0;
fscanf (file, "%1c",&harf[0]);
while ((harf[0]!=',')&&(harf[0]!='\n')) {
var_name[i][j] = harf[0];
fscanf (file, "%1c",&harf[0]);
j++;
}
}
}
for (i=0; i<nbr_of_col; i++)
cout << var_name[i] << endl;
}
// setting var_name
char cca[1],ccb[1];
i=0;
if (choice ==2)
for (cca[0]=48;cca[0]<58;cca[0]++)
for (ccb[0]=48;ccb[0]<58;ccb[0]++){
strcat (var_name[i],"var_");
strcat (var_name[i],ccb);
strcat (var_name[i],cca);
i++;
}
i = 0;
fin = 1;
char string[40];
// Reading the numerical value of the data points
while ((fin!=-1)&&(dim_list_points < pts)){
if ((dim_list_points%1000) == 0) printf (".");
glFlush();
dim_list_points = dim_list_points +1;
for (i=0; i<nbr_of_col; i++){
var[i] = (float *) realloc (var[i],(dim_list_points) * sizeof(float));
fin = fscanf (file, "%s", &string);
if ((string[0] == 'N') && (string[1]=='a')) var[i][dim_list_points-1] = NaN;
else var[i][dim_list_points-1] = atof(string);
if (dim_list_points <= 2) printf(" - %f - ",var[i][dim_list_points-1]);
if (VIRGULE){
fscanf (file, "%1c",&harf[0]);
while ( (harf[0]==32) || (harf[0]==9) ) // scan until ',' read
fscanf (file, "%1c",&harf[0]);
}
}
if (VIRGULE_AT_END_OF_LINE){
fscanf (file, "%1c",&harf[0]);
while ( (harf[0]==32) || (harf[0]==9) ) // scan the following del.
fscanf (file, "%1c",&harf[0]);
}
}
fclose (file);
if (fin ==-1)
dim_list_points = dim_list_points -1;
// dim_list_points is now = to the number of points. dim_list_points-1 --> to the last point.
cxx = (float *) realloc (cxx,(dim_list_points) * sizeof(float));
cyy = (float *) realloc (cyy,(dim_list_points) * sizeof(float));
czz = (float *) realloc (czz,(dim_list_points) * sizeof(float));
for (i=0;i<dim_list_points;i++){
cxx[i] = 1.0;
cyy[i] = 1.0;
czz[i] = 1.0;
}
cout << endl << "There is " << dim_list_points << " loaded" << endl;
dim[0] = dim_list_points;
printf ("finishing the Load data from disk process...\n" );
// set string1,2,3
strcat (string1,"Z: ");
strcat (string1,var_name[0]);
strcat (string2,"Y: ");
strcat (string2,var_name[1]);
strcat (string3,"X: ");
strcat (string3,var_name[2]);
xc = var[0];
yc = var[1];
zc = var[2];
trouver_bar_min_max_sig (xc,yc,zc,dim);
/* if (Flag_eternal) {
// Set TOP RIGHT
if (fabs(xmax) > fabs (xmin)) RIGHT = 2*fabs(xmax);
else RIGHT = 2*fabs (xmin);
if (fabs(ymax) > fabs (ymin)) TOP = 2*fabs(ymax);
else TOP = 2*fabs (ymin);
// Scaling so that it is in the same ratio as the pixel ratio : 5/4
if (TOP > RIGHT) RIGHT = 5*TOP/4;
else TOP = 4*RIGHT/5;
BOTTOM = - TOP;
LEFT = - RIGHT;
}
Flag_eternal = 0; */
}
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.7,0.6,0.5);
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.7,0.6,0.5);
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.7,0.9,0.6);
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, 0, 0.9,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, 0, 0.9,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.9,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.9,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.9, 0.0,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.9, 0.0,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.9, 0.0,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.9, 0.0,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.9, 0.0, 0.0,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.9, 0, 0.0,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.9, 0.0, 0.0,carre3_trans);
glVertex3f (x,ymin,zmax);
glVertex3f (x,ymin,zmin);
glVertex3f (x,ymax,zmin);
glVertex3f (x,ymax,zmax);
glEnd();
glBegin (GL_POLYGON);
glColor4f (0.9, 0, 0.0,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);
}
void
draw_axes()
{
void dvertical_adjx();
glBegin(GL_LINES);
glColor3f (0.2,0.2,1.0);
glVertex3f (0.0, 0.0, 0.0);
glVertex3f (deltax, 0.0, 0.0);
glEnd();
showMessage(deltax,0,0, string3);
glBegin(GL_LINES);
glColor3f (0.15,0.7,0.15);
glVertex3f (0.0, 0.0, 0.0);
glVertex3f (0.0, deltay, 0.0);
glEnd();
showMessage(0,deltay,0, string2);
glBegin(GL_LINES);
glColor3f (1,0.2,0.2);
glVertex3f (0, 0, 0);
glVertex3f (0.0, 0.0, deltaz);
glEnd();
showMessage(0,0,deltaz, string1);
}
void
draw_box()
{
glBegin(GL_LINES);
glColor3f (0.45,0.45,0.45);
glVertex3f (xmin,ymax,zmax);
glVertex3f (xmax,ymax,zmax);
glEnd();
glBegin(GL_LINES);
glColor3f (0.45,0.45,0.45);
glVertex3f (xmax,ymax,zmax);
glVertex3f (xmax,ymin,zmax);
glEnd();
glBegin(GL_LINES);
glColor3f (0.45,0.45,0.45);
// glColor3f (0.5,0,0);
glVertex3f (xmax,ymin,zmax);
glVertex3f (xmin,ymin,zmax);
glEnd();
glBegin(GL_LINES);
glColor3f (0.45,0.45,0.45);
// glColor3f (0.0,0.5,0.0);
glVertex3f (xmin,ymin,zmax);
glVertex3f (xmin,ymax,zmax);
glEnd();
glBegin(GL_LINES);
glColor3f (0.45,0.45,0.45);
// glColor3f (0,0,0.8);
glVertex3f (xmin,ymax,zmax);
glVertex3f (xmin,ymax,zmin);
glEnd();
glBegin(GL_LINES);
glColor3f (0.45,0.45,0.45);
//glColor3f (0,0,0.8);
glVertex3f (xmax,ymax,zmax);
glVertex3f (xmax,ymax,zmin);
glEnd();
glBegin(GL_LINES);
glColor3f (0.45,0.45,0.45);
//glColor3f (0,0,0.8);
glVertex3f (xmax,ymin,zmax);
glVertex3f (xmax,ymin,zmin);
glEnd();
glBegin(GL_LINES);
glColor3f (0.45,0.45,0.45);
//glColor3f (0,0,0.8);
glVertex3f (xmin,ymin,zmax);
glVertex3f (xmin,ymin,zmin);
glEnd();
glBegin(GL_LINES);
glColor3f (0.45,0.45,0.45);
//glColor3f (0.0,0.5,0.0);
glVertex3f (xmin,ymax,zmin);
glVertex3f (xmin,ymin,zmin);
glEnd();
glBegin(GL_LINES);
glColor3f (0.45,0.45,0.45);
//glColor3f (0.5,0,0);
glVertex3f (xmin,ymin,zmin);
glVertex3f (xmax,ymin,zmin);
glEnd();
glBegin(GL_LINES);
glColor3f (0.45,0.45,0.45);
//glColor3f (0.0,0.5,0.0);
glVertex3f (xmax,ymin,zmin);
glVertex3f (xmax,ymax,zmin);
glEnd();
glBegin(GL_LINES);
glColor3f (0.45,0.45,0.45);
//glColor3f (0.5,0,0);
glVertex3f (xmax,ymax,zmin);
glVertex3f (xmin,ymax,zmin);
glEnd();
}
void
recalcModelView(void) //frecalcmodelview
{
GLfloat m[4][4];
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
glPushMatrix();
double scalex, scaley, scalez;
build_rotmatrix(m, curquat);
gluLookAt(eyex,eyey,eyez, /* eye is at (... */
0,0,0, /* looking to */
upx,upy,upz); /* up is in positive Y direction */
// rotate
glMultMatrixf(&m[0][0]);
// We should normalize scaling in order to maintain the same lenth for the smaller axes.
if (SCALE_SIGMA) {
scalex = 1/sigx;
scaley = 1/sigy;
scalez = 1/sigz;
}
// We should normalize scaling in order to maintain the same lenth for the smaller axes.
if (SCALE_MIDDLE) {
scalex = 1/deltax;
scaley = 1/deltay;
scalez = 1/deltaz;
}
else {
scalex = 1;
scaley = 1;
scalez = 1;
}
// Translate the origin ONLY IF INDICATED OTHERWHISE PUT IT IN 0,0,0
//
if (TRANSLATE_TO_GRAVITY) glTranslatef (-xbar*scalex,-ybar*scaley,-zbar*scalez);
if (TRANSLATE_TO_MIDDLE ) glTranslatef (-(xmin+xmax)*scalex/2,-(ymin+ymax)*scaley/2,-(zmin+zmax)*scalez/2);
// SCALE ONLY IF REQUESTED OTHERWISE DO NOT SCALE (1,1,1).
glScalef (scalex, scaley, scalez);
newModel = 0;
}
void
ViewPort() //fViewPort()
{
// Draw The Vertical Control Menu.
// Set View Port.
glViewport (0,0,100,H);
// Set Projection Matrix
glMatrixMode(GL_PROJECTION);/* set up projection transform */
glLoadIdentity();
glOrtho (0,100, H,0, -1,1);
// Set ModelView Matrix.
glMatrixMode (GL_MODELVIEW);
glLoadIdentity();
// Draw Menu.
glBegin (GL_POLYGON);
glColor3f (0.25,0.2,0.1);
glVertex3f (0 ,H,-0.5);
glColor3f (0.25,0.2,0.1);
glVertex3f (100,H,-0.5);
glColor3f (0.3,0.1,0.15);
glVertex3f (100, 0,-0.5);
glColor3f (0.3, 0.1,0.15);
glVertex3f (0 , 0,-0.5);
glEnd();
// writing on the window characters Blue -->X...
int i;
glColor3f (0.75,0.75,1.0);
glRasterPos3f(0,10,0.5);
int len;
len = (int) strlen(string3);
for (i = 0; i < len; i++)
glutBitmapCharacter(GLUT_BITMAP_8_BY_13, string3[i]);
glColor3f (0.75,1.0,0.75);
glRasterPos3f(0,20,0.5);
len = (int) strlen(string2);
for (i = 0; i < len; i++)
glutBitmapCharacter(GLUT_BITMAP_8_BY_13, string2[i]);
glColor3f (1.0,0.75,0.75);
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,sb_c1);
scrollbar (40,40,20,sb_c2);
scrollbar (70,40,20,sb_c3);
// Drawing rectanle Stereo_Zoom
rectangle (10,130,90,143,0.9,0.3,0.7,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.7,0.9,0.4,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.7,0.9,0.4,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.9,0.9,0.4,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.9,0.3,0.4,color_rect);
glColor3f (0,0,0);
glRasterPos3f(10,203,0.5);
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.5,0.3,0.8,pt_size_rect);
glColor3f (0,0,0);
glRasterPos3f(10,219,0.5);
len = (int) strlen(string8);
for (i = 0; i < len; i++)
glutBitmapCharacter(GLUT_BITMAP_8_BY_13, string9[i]);
}
void
recalcModelView_axes(void)
{
GLfloat m[4][4];
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
glPushMatrix();
build_rotmatrix(m, curquat);
gluLookAt(eyex,eyey,eyez, /* eye is at (... */
0,0,0, /* looking to */
upx,upy,upz); /* up is in positive Y direction */
// rotate
glMultMatrixf(&m[0][0]);
// SCALE ONLY IF REQUESTED OTHERWISE DO NOT SCALE (1,1,1).
if (SCALE_SIGMA) glScalef (1/sigx,1/sigy,1/sigz); // normalized scaling.
else
if (SCALE_MIDDLE) glScalef (1/deltax,1/deltay,1/deltaz);
else
glScalef (1,1,1);
newModel = 0;
}
recalcboundingbox() //frecalcboundingbox
{
glMatrixMode(GL_PROJECTION);/* set up projection transform */
glPopMatrix();
glLoadIdentity();
glOrtho (LEFT,RIGHT, BOTTOM,TOP, NEAR2,FAR2);
glPushMatrix();
}
void
redraw() //fredraw
{
int i;
glDrawBuffer(GL_BACK_LEFT);
if (viewport){
// draw command margin then set the viewport for the 3D
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
ViewPort(); // Sets the control band viewport and draws in it.
glViewport (100,0,W-100,H); // set the viewport for the 3D left eye
} // vav = vertical adj value.
else {
// Set all the screen viewport for the 3D rendering the left eye..
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glViewport (0,0,W ,H);
}
if (displayListInited) {
// Draw left eye
eyex = -baseline;
// Draw axes left eye
if (Draw_relative_axe) {
recalcboundingbox();
recalcModelView_axes();
draw_axes();
}
// Recalc Model View.
recalcboundingbox();
recalcModelView();
// Draw either Dinosaur or pts in left eye
if (dinosor)
glCallList(DINOSAUR);
else
glCallList(28);
// Draw box left eye
if (TOGGLE_BOX) draw_box();
// Draw carre1
if (DRAW_CARRE1) draw_carre1();
// Draw carre2
if (DRAW_CARRE2) draw_carre2();
// Draw carre3
if (DRAW_CARRE3) draw_carre3();
// Draw right eye
glDrawBuffer(GL_BACK_RIGHT);
eyex = baseline;
// Draw axes right eye
if (viewport){
glViewport (100,0,W-100,H); // set the viewport for the 3D
}
else {
// Set all the screen viewport for the 3D rendering.
glViewport (0,0,W,H);
}
if (Draw_relative_axe) {
recalcboundingbox();
recalcModelView_axes();
draw_axes();
}
// Recalc Model View.
recalcboundingbox();
recalcModelView();
// Draw Object right eye
if (dinosor)
glCallList(DINOSAUR);
else
glCallList(28);
// Draw box right eye
if (TOGGLE_BOX) draw_box();
// Draw carre1
if (DRAW_CARRE1) draw_carre1();
// Draw carre2
if (DRAW_CARRE2) draw_carre2();
// Draw carre3
if (DRAW_CARRE3) draw_carre3();
glutSwapBuffers();
}
else {
/* otherwise compile and execute to create the display list */
glNewList(28, GL_COMPILE_AND_EXECUTE);
/* front face */
glPointSize (pt_size);
glBegin(GL_POINTS);
/* glColor3f(0.0, 0.7, 0.1); green */
printf ("Drawing for the first time \n");
for (i=0; i<dim[0]; i=i+fraction){
if ((xc[i] != NaN) && (yc[i] != NaN) && (zc[i] != NaN)){
glColor3f (cxx[i], cyy[i], czz[i]);
glVertex3f(xc[i],yc[i],zc[i]);
}
}
glEnd();
glEndList();
displayListInited = 1;
redraw();
glFlush();
}
}
void
fog()
{
glEnable(GL_DEPTH_TEST);
GLfloat fogColor[4] = {0, 0,0 , 1.0};
glEnable (GL_FOG);
glFogi (GL_FOG_MODE, GL_EXP);
glFogf (GL_FOG_DENSITY, fogDensity);
glFogfv(GL_FOG_COLOR, fogColor);
// glHint (GL_FOG_HINT, GL_NICEST);
//glFogf (GL_FOG_START, 0);
//glFogf (GL_FOG_END, abs(zmin) + abs(zmax));
}
void
extrudeSolidFromPolygon(GLfloat data[][2], unsigned int dataSize,
GLdouble thickness, GLuint side, GLuint edge, GLuint whole)
{
static GLUtriangulatorObj *tobj = NULL;
GLdouble vertex[3], dx, dy, len;
int i;
int count = dataSize / (2 * sizeof(GLfloat));
if (tobj == NULL) {
tobj = gluNewTess(); /* create and initialize a GLU
polygon * * tesselation object */
// gluTessCallback(tobj, GLU_BEGIN, glBegin);
// gluTessCallback(tobj, GLU_VERTEX, glVertex2fv); // semi-tricky
gluTessCallback(tobj, GLU_END, glEnd);
}
glNewList(side, GL_COMPILE);
glShadeModel(GL_SMOOTH); /* smooth minimizes seeing
tessellation */
gluBeginPolygon(tobj);
for (i = 0; i < count; i++) {
vertex[0] = data[i][0];
vertex[1] = data[i][1];
vertex[2] = 0;
gluTessVertex(tobj, vertex, data[i]);
}
gluEndPolygon(tobj);
glEndList();
glNewList(edge, GL_COMPILE);
glShadeModel(GL_FLAT); /* flat shade keeps angular hands
from being * * "smoothed" */
glBegin(GL_QUAD_STRIP);
for (i = 0; i <= count; i++) {
/* mod function handles closing the edge */
glVertex3f(data[i % count][0], data[i % count][1], 0.0);
glVertex3f(data[i % count][0], data[i % count][1], thickness);
/* Calculate a unit normal by dividing by Euclidean
distance. We * could be lazy and use
glEnable(GL_NORMALIZE) so we could pass in * arbitrary
normals for a very slight performance hit. */
dx = data[(i + 1) % count][1] - data[i % count][1];
dy = data[i % count][0] - data[(i + 1) % count][0];
len = sqrt(dx * dx + dy * dy);
glNormal3f(dx / len, dy / len, 0.0);
}
glEnd();
glEndList();
glNewList(whole, GL_COMPILE);
glFrontFace(GL_CW);
glCallList(edge);
glNormal3f(0.0, 0.0, -1.0); /* constant normal for side */
glCallList(side);
glPushMatrix();
glTranslatef(0.0, 0.0, thickness);
glFrontFace(GL_CCW);
glNormal3f(0.0, 0.0, 1.0); /* opposite normal for other side
*/
glCallList(side);
glPopMatrix();
glEndList();
}
void
makeDinosaur(void)
{
GLfloat bodyWidth = 3.0;
extrudeSolidFromPolygon(body, sizeof(body), bodyWidth,
BODY_SIDE, BODY_EDGE, BODY_WHOLE);
extrudeSolidFromPolygon(arm, sizeof(arm), bodyWidth / 4,
ARM_SIDE, ARM_EDGE, ARM_WHOLE);
extrudeSolidFromPolygon(leg, sizeof(leg), bodyWidth / 2,
LEG_SIDE, LEG_EDGE, LEG_WHOLE);
extrudeSolidFromPolygon(eye, sizeof(eye), bodyWidth + 0.2,
EYE_SIDE, EYE_EDGE, EYE_WHOLE);
glNewList(DINOSAUR, GL_COMPILE);
glMaterialfv(GL_FRONT, GL_DIFFUSE, skinColor);
glCallList(BODY_WHOLE);
glPushMatrix();
glTranslatef(0.0, 0.0, bodyWidth);
glCallList(ARM_WHOLE);
glCallList(LEG_WHOLE);
glTranslatef(0.0, 0.0, -bodyWidth - bodyWidth / 4);
glCallList(ARM_WHOLE);
glTranslatef(0.0, 0.0, -bodyWidth / 4);
glCallList(LEG_WHOLE);
glTranslatef(0.0, 0.0, bodyWidth / 2 - 0.1);
glMaterialfv(GL_FRONT, GL_DIFFUSE, eyeColor);
glCallList(EYE_WHOLE);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glTranslatef(8, 8, bodyWidth/2 );
glEndList();
}
void
redraw1(void)
{
if (newModel)
recalcModelView();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glCallList(DINOSAUR);
// showMessage(2, 7.1, 4.1, "Habib.");
glutSwapBuffers();
}
void
myReshape(int w, int h)
{
glViewport(0, 0, w, h);
W = w;
H = h;
}
void
myReshape2(int w, int h)
{
glViewport(0, 0, w, h);
W2 = w;
H2 = h;
}
void
commande_de_bord(int x, int y) //fcommand_de_bord
{
void animation_window2();
// if... draw the transparent carre1.
if (x>sb_c1->x_g_min && x<sb_c1->x_g_max
&& y>sb_c1->y_g_min && y<sb_c1->y_g_max){
DRAW_CARRE1 = 1;
if (expand_carre1)
expand_carre1 = 0;
else
expand_carre1 = 1;
flag_motion_command = motion_carre1;
}
// if... DO NOT draw the transparent carre1.
if (x>sb_c1->x_r_min && x<sb_c1->x_r_max
&& y>sb_c1->y_r_min && y<sb_c1->y_r_max)
DRAW_CARRE1 = 0;
// 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;
redraw();
}
void
mouse(int button, int state, int x, int y) //fmouse
{
// if button down
if (button == GLUT_MIDDLE_BUTTON && state == GLUT_DOWN ) {
// if commande board exist and mouse in it
if (viewport && x<100) {
commande_de_bord(x,y);
}
// if y>100 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;
flag_motion = rotating;
beginx = x;
beginy = y;
if(glutGetModifiers() & GLUT_ACTIVE_SHIFT) {
flag_motion = translating;
}
}
}
// 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();
// 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 == up)
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 == up)
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 = up;
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
animate(void)
{
glutPostRedisplay();
}
void
passive_motion(int x, int y) //fpassive_motion
{
X = x;
Y = y;
if ((x>200) && FLAG_X_SMALLER_THAN_100) {
FLAG_X_SMALLER_THAN_100 = 0;
glutSetMenu(Menu1_id);
glutAttachMenu(GLUT_RIGHT_BUTTON);
}
else {
if ((x<100) && !FLAG_X_SMALLER_THAN_100) {
FLAG_X_SMALLER_THAN_100 =1;
glutSetMenu(Menu2_id);
glutAttachMenu(GLUT_RIGHT_BUTTON);
}
}
}
void
motion2(int x, int y) //f02
{
float thresh; // threshhold
float thresh2;
void draw_elevator();
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 == up)
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 == up)
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
motion(int x, int y) //fmotion
// Handles the motion of the mouse in the big black window.
{
if (APPLY_MOUSE_MOTION) {
double step1, step2;
int stepo,steppss,stepppi;
switch (flag_motion) {
case motion_carre1:
stepo = (y-beginy);
carre1 = carre1 + stepo*(deltaz/1000);
beginy = y;
break;
case motion_carre2:
steppss = (y-beginy);
carre2 = carre2 + steppss*(deltay/1000);
beginy = y;
break;
case motion_carre3:
stepppi = (y-beginy);
carre3 = carre3 + stepppi*(deltax/1000);
beginy = y;
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;
LEFT = LEFT + sgnn*step1;
RIGHT = RIGHT - sgnn*step1;
BOTTOM = BOTTOM+ sgnn*step2;
TOP = TOP - sgnn*step2;
beginy = y;
newModel = 1;
//glutPostRedisplay();
}
break;
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.
beginy=y;
break;
case translating:
int sgnx,sgny;
sgnx = sgny =0;
if (beginx != x) sgnx = (beginx-x); //abs(beginx-x);
if (beginy != y) sgny = (beginy-y); //abs(beginy-y);
step1 = (LEFT-RIGHT)/800.0;
step2 = (BOTTOM-TOP)/700.0;
LEFT = LEFT - sgnx*step1;
RIGHT = RIGHT - sgnx*step1;
BOTTOM = BOTTOM+ sgny*step2;
TOP = TOP + sgny*step2;
beginx = x;
beginy = y;
newModel = 1;
//glutPostRedisplay();
break;
case rotating:
double deux = 2.0;
trackball(lastquat,
(deux*beginx - W) / W,
(H - deux*beginy) / H,
(deux*x - W) / W,
(H - deux*y) / H
);
beginx = x;
beginy = y;
spinning = 0;
add_quats(lastquat, curquat, curquat);
newModel = 1;
//glutPostRedisplay();
break;
}
redraw();
}
}
GLboolean lightZeroSwitch = GL_TRUE, lightOneSwitch = GL_TRUE;
void
DropMenu2(int value)
{
int i;
FLAG FLAG_DRAW = 0;
// Choosing the appropriate axe to load our data too.
if (Y>0 && Y<=10) {
xc = var[value-2];
strcpy (string3,"");
strcat (string3,"X: ");
strcat (string3,var_name[value-2]);
FLAG_DRAW =1;
}
if (Y>10 && Y<20) {
yc = var[value-2];
strcpy (string2,"");
strcat (string2,"Y: ");
strcat (string2,var_name[value-2]);
FLAG_DRAW =1;
}
if (Y>20 && Y<30) {
zc = var[value-2];
strcpy (string1,"");
strcat (string1,"Z: ");
strcat (string1,var_name[value-2]);
FLAG_DRAW =1;
}
// Animation Variable.... Maximizing a part of the points...
if (Y>160 && Y<173){
if (value >= 2) {
// setting the var_animation value
var_animation = var[value-2];
// Setting the max & min
var_animation_min= var_animation[0];
var_animation_max= var_animation[0];
for (i=0; i<dim[0]; i++)
{
if (var_animation[i]<var_animation_min ) var_animation_min = var_animation[i];
if (var_animation[i]>var_animation_max ) var_animation_max = var_animation[i];
}
}
else {
pt_size = 1;
displayListInited = 0;
redraw();
}
}
// if you are in the color zone... you want to choose a color linked to a variable.
if (Y>190 && Y<205) {
if (value >=2) {
float *tmp,delta;
float min;
float max;
tmp = var [value - 2];
// setting max & min.
min = max = tmp[0]; // initializing.
for (i=0; i<dim[0]; i++){
if (tmp[i]<min ) min = tmp[i];
if (tmp[i]>max ) max = tmp[i];
}
delta = (max - min)/14.0;
// coloring the points
int index;
for (i=0; i<dim[0]; i++) {
index = (tmp[i] - min) / delta ; // possible value for index 0...14
cxx[i] = lUPt[index][0];
cyy[i] = lUPt[index][1];
czz[i] = lUPt[index][2];
}
displayListInited = 0;
redraw();
}
else {
for (i = 0; i<dim[0]; i++) {
cxx[i] = 1;
cyy[i] = 1;
czz[i] = 1;
}
displayListInited = 0;
redraw();
}
}
// Determin the pt_size...
if (Y> 206 && Y<221) {
pt_size = value;
displayListInited = 0;
redraw();
}
if (FLAG_DRAW){
trouver_bar_min_max_sig (xc,yc,zc,dim);
// Set TOP RIGHT
/* if (fabs(xmax) > fabs (xmin)) RIGHT = 2*fabs(xmax);
else RIGHT = 2*fabs (xmin);
if (fabs(ymax) > fabs (ymin)) TOP = 2*fabs(ymax);
else TOP = 2*fabs (ymin);
// Scaling so that it is in the same ratio as the pixel ratio : 5/4
if (TOP > RIGHT) RIGHT = 5*TOP/4;
else TOP = 4*RIGHT/5;
BOTTOM = - TOP;
LEFT = - RIGHT; */
displayListInited = 0;
redraw();
}
}
void
DropMenu1(int value)
{
switch (value) {
case 1:
glEnable(GL_LIGHTING);
dinosor = 1;
break;
case 2:
glDisable(GL_LIGHTING);
dinosor = 0;
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 99:
exit(0);
break;
}
glutPostRedisplay();
}
void
vis(int visible)
{
if (visible == GLUT_VISIBLE) {
if (spinning)
glutIdleFunc(animate);
}
else {
if (spinning)
glutIdleFunc(NULL);
}
}
static void
Key(unsigned char key, int x, int y)
{
switch (key) {
case 'd':
fogDensity *= 1.10;
glFogf(GL_FOG_DENSITY, fogDensity);
glutPostRedisplay();
break;
case 'D':
fogDensity /= 1.10;
glFogf(GL_FOG_DENSITY, fogDensity);
glutPostRedisplay();
break;
case 'b':
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 '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;
glutPostRedisplay();
break;
case 27:
exit(0);
}
}
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;
}
}
void
create_menus()
{
glutCreateMenu(DropMenu1);
Menu1_id = glutGetMenu();
glutAddMenuEntry("Show Dinosor" , 1);
glutAddMenuEntry("Show Pts", 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);
if(glutGet(GLUT_WINDOW_NUM_SAMPLES) > 0) {
glutAddMenuEntry("Toggle multisampling", 3);
glutSetWindowTitle("dinospin (multisample capable)");
}
glutAddMenuEntry("Quit", 99);
glutCreateMenu(DropMenu2);
Menu2_id = glutGetMenu();
int i;
glutAddMenuEntry ("None",1);
for (i=0;i<nbr_of_col; i++){
glutAddMenuEntry(var_name[i],i+2);
}
}
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.9,0.8,0.7);
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.15,0.15,1.0);
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.7,0.9,0.8);
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.2,0.15,0.1);
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.76,0.9,0.6);
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.15,0.15,0.3);
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.15,1.0,0.3);
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();
}
void
animation_window2() //fanimation_window
{
cout << "Animation window activated" << endl;
// glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH | GLUT_MULTISAMPLE | GLUT_STEREO);
// glutCreateSubWindow (win, 0,0,100,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();
}
int
main(int argc, char **argv)
{
GLenum type;
load_data_NZP ();
flag_motion = rotating;
glutInit(&argc, argv);
// glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH | GLUT_MULTISAMPLE | GLUT_STEREO);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH | GLUT_MULTISAMPLE );
trackball(curquat, 0.0, 0.0, 0.0, 0.0);
win = glutCreateWindow("Ford's Demo");
glutDisplayFunc(redraw);
glutReshapeFunc(myReshape);
glutVisibilityFunc(vis);
glutMouseFunc(mouse);
glutMotionFunc(motion);
glutPassiveMotionFunc(passive_motion);
cout << "hihi... " << NaN << endl;
create_menus();
makeDinosaur();
glEnable(GL_CULL_FACE);
glEnable(GL_DEPTH_TEST);
// glEnable(GL_LIGHTING);
glMatrixMode(GL_PROJECTION);
//gluPerspective( /* field of view in degree */ 40.0, /* aspect blen
// ratio
// */ 1.0,
// /* Z near */ 1.0, /* Z far */ 40.0);
NEAR2 = -10000;
FAR2 = 10000;
glMatrixMode(GL_MODELVIEW);
transX = 0;
transY = 0;
transZ = 0;
eyex = -baseline;
eyey = 0;
eyez = 30;
upy = 1;
upz = 0;
glPushMatrix(); /* dummy push so we can pop on model
recalc */
GLfloat lightZeroPosition[] = {10.0, 4.0, 10.0, 1.0};
GLfloat lightZeroColor[] = {0.8, 1.0, 0.8, 1.0}; /* green-tinted */
GLfloat lightOnePosition[] = {-1.0, -2.0, 1.0, 0.0};
GLfloat lightOneColor[] = {0.6, 0.3, 0.2, 1.0}; /* red-tinted */
glMatrixMode(GL_PROJECTION);/* set up projection transform */
glOrtho (LEFT,RIGHT, BOTTOM,TOP, NEAR2,FAR2);
glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1);
glLightfv(GL_LIGHT0, GL_POSITION, lightZeroPosition);
glLightfv(GL_LIGHT0, GL_DIFFUSE, lightZeroColor);
glLightf(GL_LIGHT0, GL_CONSTANT_ATTENUATION, 0.1);
glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION, 0.05);
glLightfv(GL_LIGHT1, GL_POSITION, lightOnePosition);
glLightfv(GL_LIGHT1, GL_DIFFUSE, lightOneColor);
glEnable(GL_LIGHT0);
glEnable(GL_LIGHT1);
GLfloat ambi[] = {1.0, 1.0, 1.0, 1.0};
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambi);
if (dinosor)
glEnable(GL_LIGHTING);
glLineWidth(2.0);
glutKeyboardFunc(Key);
glutSpecialFunc(SpecialKey);
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}