6 GLfloat luceAmbiente[4]        = { .1, .1, .1,1.}; 
     7 GLfloat luceDiffusa[4]         = { 1., 1., 1.,1.};
     8 GLfloat luceSpeculare[]        = { 1.0, 1.0, 1.0,1.};
     9 GLfloat direzione[4]           = { 1.0, 1.0, 0.0,1.};
    10 GLfloat posizioneLight0[4]     = { 1., 1., 1.0,0.};
    11 GLfloat posizioneLight1[4]     = { 1., 0., 1.0,0.};
    13 GLint   MaterialShininess      = 50;
    16   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    17   glClearColor(
Rback,Gback,Bback,Aback);
    21   glRotatef(
xa,1.,0.,0.);
    22   glRotatef(ya,0.,1.,0.);
    23   glRotatef(za,0.,0.,1.);
    36   glMatrixMode( GL_MODELVIEW );
    38   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    39   glClearColor(
Rback,Gback,Bback,Aback);
    43   glRotatef(
xa,1.,0.,0.);
    44   glRotatef(ya,0.,1.,0.);
    45   glRotatef(za,0.,0.,1.);
    47   glTranslatef(
xp,yp,zp);
    49   if(
IfBlend) glEnable(GL_DEPTH_TEST); 
    50   else glDisable(GL_DEPTH_TEST); 
    51   glBlendFunc(BlendSource,BlendDest);
    54     glRotatef(
xf,1.,0.,0.);
    55     glRotatef(yf,0.,1.,0.);
    56     glRotatef(zf,0.,0.,1.);
    57     glTranslatef(1.5*
Edge[0]*InvScaleUn,1.5*
Edge[1]*InvScaleUn,1.5*
Edge[2]*InvScaleUn);
    58     GLfloat PosLight[4] = {
xl0,yl0,zl0,1.};
    59     glLightfv(GL_LIGHT0,GL_POSITION,PosLight);
    72     glDrawPixels(
ImWidth,ImHeight,GL_RGBA,GL_UNSIGNED_BYTE,
pixel);
    76     glPushAttrib(GL_LIGHTING_BIT);
    77     glDisable(GL_LIGHTING);
    78     glColor4f(1.-
Rback,1.-Gback,1.-Bback,1.0);
    80     glTranslated(.5*
Edge[0]*InvScaleUn,.5*
Edge[1]*InvScaleUn,.5*
Edge[2]*InvScaleUn);
    81     glScalef((GLfloat)
Edge[0]*InvScaleUn,
    82            (GLfloat)
Edge[1]*InvScaleUn,
    83            (GLfloat)(
Edge[2])*InvScaleUn);
    84     glutWireCube((GLfloat)1.);
    89     glColor4f(1.-
Rback,1.-Gback,1.-Bback,1.0);
   109     glColor4f(1.-
Rback,1.-Gback,1.-Bback,1.0);
   110     glRasterPos3d(
xi, yi, zi);
   111     int len = (int)strlen(
info);
   112     for (
int i = 0; i < len; i++) {
   113       glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, 
info[i]);
   123   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
   125   glTranslatef(
xp,yp,zp);
   127   glRotatef(
xa,1.,0.,0.);
   128   glRotatef(ya,0.,1.,0.);
   129   glRotatef(za,0.,0.,1.);
   133     glRotatef(
xf,1.,0.,0.);
   134     glRotatef(yf,0.,1.,0.);
   135     glRotatef(zf,0.,0.,1.);
   136     glTranslatef(1.,1.,
Edge[2]*InvScaleUn);
   137     glLightfv(GL_LIGHT0,GL_AMBIENT,luceAmbiente);
   138     glLightfv(GL_LIGHT0,GL_DIFFUSE,luceDiffusa);
   139     glLightfv(GL_LIGHT0,GL_SPECULAR,luceSpeculare);
   140     glLightfv(GL_LIGHT0,GL_POSITION,posizioneLight0);
   141     glutSolidSphere(0.05,20,20);
   145   glTranslatef(.5*
Edge[0]*InvScaleUn,.5*
Edge[1]*InvScaleUn,.5*
Edge[2]*InvScaleUn);
   146   glScalef((GLfloat)
Edge[0]*InvScaleUn,
   147       (GLfloat)
Edge[1]*InvScaleUn,
   148       (GLfloat)(
Edge[2])*InvScaleUn);
   149   glColor4f(1.,1.,1.,1.);
   150   glutWireCube((GLfloat)1);
   158     GLfloat 
Normal[3]={.1,.1,.1};
   159     glNormalPointer(GL_FLOAT,
sizeof(GLfloat),&Normal[0]);  
   161     GLfloat Deltax = 1./(GLfloat) NPoint;
   162     double *Surface = 
new double [3*NPoint*NPoint];
   163     glColor4f(1.0,.0,1.,1.);
   164     for(
int i=0;i<NPoint;i++){
   165       for(
int j=0;j<NPoint;j++){
   166    Surface[(i*NPoint+j)*3+0] = Deltax*i+drand48()*.01;
   167    Surface[(i*NPoint+j)*3+1] = Deltax*j+drand48()*.01;
   168    Surface[(i*NPoint+j)*3+2] = drand48()*.05;
   171     glVertexPointer(3,GL_DOUBLE,3*
sizeof(
double),Surface);
   178   glTranslatef(.5,.3,.4);
   179   glColor4f(.0,.0,1.,1.);
   180   glutSolidSphere(.2,Detail,Detail);
   183   glTranslatef(.5,.7,.6);
   184   glColor4f(.0,1.0,.0,1.);
   185   glutSolidSphere(.2,Detail,Detail);
   192   vector <GLuint> VecIndices; 
   193   for(
int i=0;i<NPoint-1;i++){
   194     for(
int j=0;j<NPoint-1;j++){
   195       VecIndices.push_back(i*NPoint + j);
   196       VecIndices.push_back((i+1)*NPoint + j);
   197       VecIndices.push_back((i+1)*NPoint + (j+1));
   198       VecIndices.push_back(i*NPoint + j);
   199       VecIndices.push_back((i+1)*NPoint + (j+1));
   200       VecIndices.push_back((i)*NPoint + (j+1));
   203   int NIndex = VecIndices.size();
   204   GLuint *Indices = 
new GLuint [NIndex];
   205   for(
int i=0;i<NIndex;i++)Indices[i] = VecIndices[i];
   208   glDrawElements(GL_TRIANGLES,NIndex,GL_UNSIGNED_INT,Indices);
   212   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
   213   glDrawPixels(
ImWidth,ImHeight,GL_RGBA,GL_UNSIGNED_BYTE,
pixel);
   218   glEnable(GL_TEXTURE_2D);
   219   printf(
"Texture %d\n",glIsEnabled(GL_TEXTURE_2D));
   220   if(
OpenImage(
"Texture.tif")==0) {;
return 0;}
   223   glTexImage2D(GL_TEXTURE_2D, 0, 4, 
ImWidth, ImHeight , 0, GL_RGBA, GL_UNSIGNED_BYTE, 
pixel);
   227   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
   228   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
   233   glBindTexture(GL_TEXTURE_2D,
Texture);
   236   glTexCoord2f(0.,0.);glVertex3f(0.,0.,1.0);
   237   glTexCoord2f(1.,0.);glVertex3f(1.,0.,1.0);
   238   glTexCoord2f(1.,1.);glVertex3f(1.,1.,1.0);
   239   glTexCoord2f(0.,1.);glVertex3f(0.,1.,1.0);
   241   glRasterPos3f(0.,0.,0.);
   242   glDrawPixels(
ImWidth,ImHeight,GL_RGBA,GL_UNSIGNED_BYTE,
pixel);
   246   glDisable(GL_LIGHTING);
   274   glMatrixMode(GL_PROJECTION);
   278   glColor4f( .1,.1,.1,1.);
   281   glVertex3d(0.,0.,0.);
   282   glVertex3d(1.,0.,0.);
   287   glVertex3d(0.,0.,0.);
   288   glVertex3d(0.,1.,0.);
   293   glVertex3d(0.,0.,0.);
   294   glVertex3d(0.,0.,1.);
   300   glVertex3d(0.,0.,0.);
   301   glVertex3d(o[0],o[1],o[2]);
   304   glColor4f( 1.,.1,.1,1.);
   306   PutString(o[0]-.05,o[1]-.05,o[2]-.05,
"o");
   310   glVertex3d(o[0],o[1],o[2]);
   311   glVertex3d(o[0]+u[0],o[1]+u[1],o[2]+u[2]);
   314   PutString(o[0]+u[0],o[1]+u[1],o[2]+u[2],
"axis");
   317   glColor4f( .1,.1,1.,1.);
   320   glVertex3d(o[0],o[1],o[2]);
   321   glVertex3d(o[0]+v[0],o[1]+v[1],o[2]+v[2]);
   324   PutString(o[0]+v[0],o[1]+v[1],o[2]+v[2],
"v");
   327   glColor4f( 1.,1.,.1,1.);
   330   glVertex3d(o[0]+.1,o[1],o[2]);
   331   glVertex3d(o[0]+n[0]+.1,o[1]+n[1],o[2]+n[2]);
   334   PutString(o[0]+n[0]+.1,o[1]+n[1],o[2]+n[2],
"n");
   340   glColor4f( .1,1.,.1,1.);
   343   glVertex3d(o[0]+v[0],o[1]+v[1],o[2]+v[2]);
   344   glVertex3d(o[0]+v[0]+n[0],o[1]+v[1]+n[1],o[2]+v[2]+n[2]);
   347   PutString(o[0]+v[0]+n[0],o[1]+v[1]+n[1],o[2]+v[2]+n[2],
"v-n");
   349   glColor4f(.5,.5,1.,1.);
   353   glVertex3d(o[0],o[1],o[2]);
   354   glVertex3d(o[0]+v[0]+2.*n[0],o[1]+v[1]+2.*n[1],o[2]+v[2]+2.*n[2]);
   357   PutString(o[0]+v[0]+2.*n[0],o[1]+v[1]+2.*n[1],o[2]+v[2]+2.*n[2],
"v'");
   360   glColor4f(1.,.1,1.,1.);
   364   glVertex3d(o[0],o[1],o[2]);
   365   glVertex3d(o[0]+Norm1[0],o[1]+Norm1[1],o[2]+Norm1[2]);
   368   PutString(o[0]+Norm1[0],o[1]+Norm1[1],o[2]+Norm1[2],
"normal");
   371   glColor4f(1.,.1,1.,1.);
   374   glVertex3d(o[0],o[1],o[2]);
   375   glVertex3d(o[0]+Norm2[0],o[1]+Norm2[1],o[2]+Norm2[2]);
   378   PutString(o[0]+Norm2[0],o[1]+Norm2[1],o[2]+Norm2[2],
"normal");
   384   Piano p1(&v1,&v2,&v3);
   385   glColor4f(.5,.1,1.,1.);
   389   glVertex3d(PSurf[0],PSurf[1],PSurf[2]);
   390   glVertex3d(o[0],o[1],o[2]);
   392   glColor4f(.8,.1,1.,1.);
   394   glVertex3d(p1.
P1[0],p1.
P1[1],p1.
P1[2]);
   395   glVertex3d(p1.P2[0],p1.P2[1],p1.P2[2]);
   396   glVertex3d(p1.P3[0],p1.P3[1],p1.P3[2]);
   401     PutString(PSurf[0],PSurf[1],PSurf[2],
"in");
   404     PutString(PSurf[0],PSurf[1],PSurf[2],
"out");
   411   glVertex3d(PSurf[0],PSurf[1],PSurf[2]);
   412   glVertex3d(PSurf[0]+Vel[0],PSurf[1]+Vel[1],PSurf[2]+Vel[2]);
   416   PutString(PSurf[0]+Vel[0],PSurf[1]+Vel[1],PSurf[2]+Vel[2],
"vel");
   421   glVertex3d(PSurf[0],PSurf[1],PSurf[2]);
   422   glVertex3d(PSurf[0]+Vel[0],PSurf[1]+Vel[1],PSurf[2]+Vel[2]);
   426   PutString(PSurf[0]+Vel[0],PSurf[1]+Vel[1],PSurf[2]+Vel[2],
"vel'");
   436   glColor4f( 1.,.1,.1,1.);
   442       (Pos[2]*InvScaleUn));
   443   for(
int l=0; l < strlen(String); l++) {
   444     glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, String[l]);
   453   for(
int l=0; l < strlen(String); l++) {
   455     glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,String[l]);
 GLfloat xp
Translation, wheel. 
double InvScaleUn
Rescale the three orthogonal directions. 
int IfInfo
Removes the info line. 
void Copy(Vettore *o)
Copy the vector. 
Vettore P1
Points defining the plane. 
double Normal(double *v, double *u, double *w, double *n)
Calculate the normal. 
void DrTriangles(int NPoint)
Boh. 
Geometrical operations on vectors. 
void DMinimal(void)
A empty scene (only the list) 
void DFigure(void)
Definition of the scene on which the objects will be drawn. 
int ApplyTexture()
Apply the texture to a square. 
GLuint DrLegend
Refers to the list of the legend. 
GLfloat Rback
Background color. 
double * x
Where the data are stored. 
int gr
Puts/removes the grid. 
int ImWidth
Width and height of the image. 
int la
Puts/removes the box edges. 
int OpenImage(const char *FileName)
Open a image to be store in pixel. 
double ProjOnAxis(Vettore *a)
Projects along the axis. 
GLuint Griglia
Refers to the list of the grid. 
void DrCube()
Line in a cube. 
GLuint ScriptList
Refers to the list of the objects called by the script file. 
GLuint Particles
Refers to the list of the total position of the particles which will be generated in another program...
int ShowTexture()
Call the texture in the scene. 
void Draw1(void)
A scene for debugging. 
void Transform()
Transform the system coordinates. 
GLfloat xl0
Position of the light0. 
Matrice computes the algebric operations on matrices. 
GLfloat xf
Orientation of the light. 
int IfScript
Ignores the script file. 
int IfBlend
Activate the blending. 
int Impact(Vettore *P, Vettore *V)
Reflect velocity. 
GLfloat xi
Position of the info string. 
GLuint Texture
Refers to the list of the texture. 
void ShowImage()
Displays the data stored in pixel. 
int IsOnSurf(Vettore *P)
If the point is inside the triangle. 
void Normal(const Vettore *u, const Vettore *v)
Computes the normal with respect to the Vettore u and v. 
void PutString(double *Pos, char *String)
Put a string. 
void Prod(Quadri q)
Product between two quaternions. 
int lu
Enables/disables illumination. 
GLubyte * pixel
Principal image (always allocated) 
Vettore ProjOnSurf(Vettore *Pos)
Project on surface (point) 
void PerpTo(Vettore *o)
The vector perpendicolar.