// cube.c++   Simple cube drawing for test case

#include "drawwindow.h"
#include "screen.h"
#include "cube.h"
extern struct screenvalue  sc;

void sidecube(void) { /* make a square translated 0.5 in the z direction */
    glPushMatrix();
    glTranslatef(0.0,0.0,0.5);
    glRectf(-0.5,-0.5,0.5,0.5);
    glPopMatrix();
}

void cube(void) { /* make a cube out of 4 squares */
    glPushMatrix();
    sidecube();
    glRotatef(90.,1.,0.,0.);
    sidecube();
    glRotatef(90.,1.,0.,0.);
    sidecube();
    glRotatef(90.,1.,0.,0.);
    sidecube();
    glPopMatrix();
}

#if 1
void drawcube()//Simple Routine from motif program that draws a solid cube inside a line cube
{
    mycolor(whitev);
    glLoadName(5);
    cube(); // draws a line cube
    glScalef(0.3,0.3,0.3);  // draws another - solid  and smaller -cube 
    glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
//    glColor3f(.8, .8, .1);
    mycolor(sc.cubecol);
    glLoadName(10);
    cube();
}
#endif

#define zz -10.0
#define yy  3

float v0[3]={-1.0,-1.0+yy,-1.0+zz};
float v1[3]={-1.0,-1.0+yy,1.0+zz};
float v2[3]={-1.0,1.0+yy,1.0+zz};
float v3[3]={-1.0,1.0+yy,-1.0+zz};
float v4[3]={1.0,-1.0+yy,-1.0+zz};
float v5[3]={1.0,-1.0+yy,1.0+zz};
float v6[3]={1.0,1.0+yy,1.0+zz};
float v7[3]={1.0,1.0+yy,-1.0+zz};

void drawsquare(float v1[],float v2[],float v3[],float v4[])
{
   glBegin(GL_POLYGON);
     glVertex3f(v1[0],v1[1],v1[2]);   
     glVertex3f(v2[0],v2[1],v2[2]);   
     glVertex3f(v3[0],v3[1],v3[2]);   
     glVertex3f(v4[0],v4[1],v4[2]);
  glEnd();
}   

void translatecube(float tr[] )
{
   for(int i =0;i<=2;i++){
      v0[i]=v0[i]+tr[i];
      v1[i]=v1[i]+tr[i];
      v2[i]=v2[i]+tr[i];
      v3[i]=v3[i]+tr[i];
      v4[i]=v4[i]+tr[i];
      v5[i]=v5[i]+tr[i];
      v6[i]=v6[i]+tr[i];
      v7[i]=v7[i]+tr[i];
   }
}

#if 0  
void drawcube()  // My version
{
   drawsquare(v0,v1,v2,v3);
   drawsquare(v0,v4,v5,v1);
   drawsquare(v4,v7,v6,v5);
   drawsquare(v3,v7,v6,v2);
   drawsquare(v5,v1,v2,v6);
   drawsquare(v0,v4,v7,v3);
}
#endif

void copyright() 
/* New version - prints the real residue number */
{
   int i;
   float xpos[3];

   glColor3fv(writecolv);
   xpos[2] = -1.0;  
   xpos[0] = -2.5;
   xpos[1] = 2.5;
    glRasterPos3f(xpos[0],xpos[1],xpos[2]);
    printString("MAID    COPYRIGHT 2000");
    glFlush ();
   xpos[0] = -2.5;
   xpos[1] = 2.0;
    glRasterPos3f(xpos[0],xpos[1],xpos[2]);
    printString("DAVID G. LEVITT");
    glFlush ();
  xpos[0] = -2.0;
  xpos[1] = -1.0;
  xpos[2] = 0.0;
    glRasterPos3f(xpos[0],xpos[1],xpos[2]);
    printString("MOUSE BUTTONS:"); 
    glFlush ();
  xpos[0] = -2.5;
  xpos[1] = -1.5;
  xpos[2] = 0.0;
    glRasterPos3f(xpos[0],xpos[1],xpos[2]);
    printString(" Left (Pick in Left Window)"); 
    glFlush ();
  xpos[0] = -2.5;
  xpos[1] = -2.0;
  xpos[2] = 0.0;
    glRasterPos3f(xpos[0],xpos[1],xpos[2]);
    printString("Middle (translate) Right (Rotate)");
    glFlush ();
  xpos[0] = -3.0;
  xpos[1] = -2.5;
  xpos[2] = 0.0;
    glRasterPos3f(xpos[0],xpos[1],xpos[2]);
    printString("Letter Key & Right Button: 'e' ZOOM");
    glFlush ();
  xpos[0] = -2.5;
  xpos[1] = -3.0;
  xpos[2] = 0.0;
    glRasterPos3f(xpos[0],xpos[1],xpos[2]);
    printString("'q' SLAB; 'a' X rot; 's' Y rot; 'd' Zrot");
    glFlush ();
}
