#define DEPTH_OF_FIELD 0

GLint   screenWidth  = 800;
GLint   screenHeight = 600;
GLfloat xangle=0, yangle=0, zangle=0;
GLint   lineSmooth=0, polySmooth=0;

float  sphi=0.0, stheta=0.0;
float  sside=0.0,sdepth=0.0;
float  sx=0.0,   sy=0.0;
bool  mouse_left_click, mouse_middle_click, mouse_right_click;
int   mouseX, mouseY;

partStruct *object1, *head1;

GLfloat ambientLight[]   = { 0.3, 0.3, 0.3, 1.0 };
GLfloat diffuseLight[]   = { 0.5, 0.5, 0.5, 1.0 };
GLfloat specularLight[]  = { 1.0, 1.0, 1.0, 1.0 };
GLfloat specularLight2[] = { 1.0, 1.0, 1.0, 1.0 };
GLfloat blueDiffuse[]    = { 0.0, 0.0, 0.3, 1.0 };

GLfloat lightpos0[]    = {  100.0, 100.0, 100.0, 1.0};
GLfloat lightpos1[]    = {   0.0,  100.0, 0.0, 1.0};
GLfloat lightpos2[]    = { 100.0,   0.0, 0.0, 1.0};
GLfloat lightpos3[]    = {-100.0,   0.0, 0.0, 1.0};

static GLfloat grey[4]          = { 0.5, 0.5, 0.5, 1.0 };
static GLfloat white[4]         = { 1.0, 1.0, 1.0, 1.0 };

static GLfloat darkPlastic[4]   = { 0.0, 0.0, 0.0, 1.0 };
static GLfloat brightPlastic[4] = { 0.2, 0.2, 0.2, 1.0 };
static GLfloat darkSeats[4]     = { 0.5, 0.25, 0.0, 1.0 };
static GLfloat brightSeats[4]   = { 1.0, 0.50, 0.1, 1.0 };

static GLfloat bodyAmb[4]   = { 0.3, 0.3, 0.0, 1.0 };
static GLfloat bodyDif[4]   = { 0.9, 0.9, 0.0, 1.0 };
static GLfloat bodySpe[4]   = { 1.0, 1.0, 0.0, 1.0 };

static GLfloat metalAmb[4]  = { 0.3, 0.3, 0.3, 1.0 };
static GLfloat metalDif[4]  = { 0.5, 0.5, 0.5, 1.0 };
static GLfloat metalSpe[4]  = { 1.0, 1.0, 1.0, 1.0 };

static GLfloat glassAmb[4]  = { 0.2, 0.2, 0.2, 0.5 };
static GLfloat glassDif[4]  = { 0.6, 0.6, 0.6, 0.5 };
static GLfloat glassSpe[4]  = { 0.8, 0.8, 0.8, 0.5 };

static GLfloat insideAmb[4] = { 0.2, 0.1, 0.0, 1.0 };
static GLfloat insideDif[4] = { 0.4, 0.2, 0.0, 1.0 };
static GLfloat insideSpe[4] = { 0.4, 0.2, 0.0, 1.0 };

static GLfloat lambAmb[4]   = { 0.4, 0.4, 0.4, 0.8 };
static GLfloat lambDif[4]   = { 0.8, 0.8, 0.8, 0.8 };
static GLfloat lambSpe[4]   = { 1.0, 1.0, 1.0, 0.8 };

typedef struct typeTVertex {
  float X, Y, Z;
} TVertex;

float ShadowMatrix[16];
TVertex roomNormal, roomPoints;
void generateShadowMatrix(float *ShadowMatrix, TVertex normal, TVertex point, 
                          float lightX, float lightY, float lightZ, float lightW)
{
  float d, dot;

  d   = -normal.X*point.X - normal.Y*point.Y - normal.Z*point.Z;
  dot =  normal.X*lightX  + normal.Y*lightY + normal.Z*lightZ + d*lightW;

  ShadowMatrix[0]  = -lightX*normal.X + dot;
  ShadowMatrix[4]  = -lightX*normal.Y;
  ShadowMatrix[8]  = -lightX*normal.Z;
  ShadowMatrix[12] = -lightX*d;
  ShadowMatrix[1]  = -lightY*normal.X;
  ShadowMatrix[5]  = -lightY*normal.Y + dot;
  ShadowMatrix[9]  = -lightY*normal.Z;
  ShadowMatrix[13] = -lightY*d;
  ShadowMatrix[2]  = -lightZ*normal.X;
  ShadowMatrix[6]  = -lightZ*normal.Y;
  ShadowMatrix[10] = -lightZ*normal.Z + dot;
  ShadowMatrix[14] = -lightZ*d;
  ShadowMatrix[3]  = -lightW*normal.X;
  ShadowMatrix[7]  = -lightW*normal.Y;
  ShadowMatrix[11] = -lightW*normal.Z;
  ShadowMatrix[15] = -lightW*d + dot;
}

