Beispiel #1
0
void DrawScene()
{
    glPushMatrix();

    glDisable(GL_LIGHTING);
    glDisable(GL_TEXTURE_2D);

    //effet brouillard
    if(brouillard) {
        GLint fogmode; //Initialisation de fogmode
        GLfloat fogcolor[4] = {0.5, 0.5, 0.5, 1} ; //Initialisation de la couleur (RGBA)

        glEnable(GL_FOG); //Cela permet d'activer le mode GL_FOG
        fogmode = GL_EXP ;
        glFogi(GL_FOG_MODE, fogmode); //On range le mode fogmode dans la variable GL_FOG_MODE
        glFogfv(GL_FOG_COLOR, fogcolor); //On fait la meme chose pour la couleur et la variable GL_FOG_COLOR
        glFogf(GL_FOG_DENSITY, 0.05); //cela permet de definir la densite du brouillard (plus ou moins epais)
        glFogf(GL_FOG_START, 1.0);  //Debut du brouillard
        glFogf(GL_FOG_END, 5.0); //Fin du brouillar
    }
    else //desactiver effet brouillard
        glDisable(GL_FOG);

    /**********************************/

//effect du reflet
    if(reflet) {
        glDisable(GL_DEPTH_TEST);
        glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
        glEnable(GL_STENCIL_TEST);
        glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
        glStencilFunc(GL_ALWAYS, 1, 0xffffffff);

        glDisable(GL_LIGHTING);
        glDisable(GL_TEXTURE_2D);

        DrawGrille();

        glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
        glEnable(GL_DEPTH_TEST);

        glStencilFunc(GL_EQUAL, 1, 0xffffffff); /* draw if ==1 */
        glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);

        glPushMatrix();
        glScalef(1.0, -1.0, 1.0);
        //glEnable(GL_LIGHTING);  glEnable(GL_TEXTURE_2D);
        glmDraw22( pmodel, GLM_SMOOTH | GLM_2_SIDED | GLM_MATERIAL | GLM_TEXTURE);
        glPopMatrix();

        glDisable(GL_STENCIL_TEST);


        glDisable(GL_LIGHTING);
        glDisable(GL_TEXTURE_2D);
        DrawPlateau();

    }
    else
        DrawPlateau();

    glEnable(GL_LIGHTING);
    glEnable(GL_TEXTURE_2D);
    glmDraw2( pmodel, GLM_SMOOTH | GLM_2_SIDED | GLM_MATERIAL | GLM_TEXTURE);

    /**********************************/
//effect d ombre
    if(ombre) {
        glPushMatrix();
        static GLfloat floorPlane[4];
        static GLfloat floorShadow[4][4];
        GLfloat light_pos[] = { .3, .5, .2, 0.0 };
        findPlane(floorPlane, vfloor[1], vfloor[2], vfloor[3]);
        shadowMatrix(floorShadow, floorPlane, light_pos);

        glMultMatrixf((GLfloat *) floorShadow);
        glmDraw22( pmodel, GLM_NONE);
        glPopMatrix();
    }
    glPopMatrix();
}
Beispiel #2
0
static void
redraw(void)
{
  int start = 0, end = 0;

  if (reportSpeed) {
    start = glutGet(GLUT_ELAPSED_TIME);
  }

  /* Clear; default stencil clears to zero. */
  if ((stencilReflection && renderReflection) || (stencilShadow && renderShadow)) {
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
  } else {
    /* Avoid clearing stencil when not using it. */
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  }

  /* Reposition the light source. */
  lightPosition[0] = 12*cos(lightAngle);
  lightPosition[1] = lightHeight;
  lightPosition[2] = 12*sin(lightAngle);
  if (directionalLight) {
    lightPosition[3] = 0.0;
  } else {
    lightPosition[3] = 1.0;
  }

  shadowMatrix(floorShadow, floorPlane, lightPosition);

  glPushMatrix();
    /* Perform scene rotations based on user mouse input. */
    glRotatef(angle2, 1.0, 0.0, 0.0);
    glRotatef(angle, 0.0, 1.0, 0.0);
     
    /* Tell GL new light source position. */
    glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);

    if (renderReflection) {
      if (stencilReflection) {
        /* We can eliminate the visual "artifact" of seeing the "flipped"
  	   dinosaur underneath the floor by using stencil.  The idea is
	   draw the floor without color or depth update but so that 
	   a stencil value of one is where the floor will be.  Later when
	   rendering the dinosaur reflection, we will only update pixels
	   with a stencil value of 1 to make sure the reflection only
	   lives on the floor, not below the floor. */

        /* Don't update color or depth. */
        glDisable(GL_DEPTH_TEST);
        glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);

        /* Draw 1 into the stencil buffer. */
        glEnable(GL_STENCIL_TEST);
        glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
        glStencilFunc(GL_ALWAYS, 1, 0xffffffff);

        /* Now render floor; floor pixels just get their stencil set to 1. */
        drawFloor();

        /* Re-enable update of color and depth. */ 
        glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
        glEnable(GL_DEPTH_TEST);

        /* Now, only render where stencil is set to 1. */
        glStencilFunc(GL_EQUAL, 1, 0xffffffff);  /* draw if ==1 */
        glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
      }

      glPushMatrix();

        /* The critical reflection step: Reflect dinosaur through the floor
           (the Y=0 plane) to make a relection. */
        glScalef(1.0, -1.0, 1.0);

	/* Reflect the light position. */
        glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);

        /* To avoid our normals getting reversed and hence botched lighting
	   on the reflection, turn on normalize.  */
        glEnable(GL_NORMALIZE);
        glCullFace(GL_FRONT);

        /* Draw the reflected dinosaur. */
        drawDinosaur();

        /* Disable noramlize again and re-enable back face culling. */
        glDisable(GL_NORMALIZE);
        glCullFace(GL_BACK);

      glPopMatrix();

      /* Switch back to the unreflected light position. */
      glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);

      if (stencilReflection) {
        glDisable(GL_STENCIL_TEST);
      }
    }

    /* Back face culling will get used to only draw either the top or the
       bottom floor.  This let's us get a floor with two distinct
       appearances.  The top floor surface is reflective and kind of red.
       The bottom floor surface is not reflective and blue. */

    /* Draw "bottom" of floor in blue. */
    glFrontFace(GL_CW);  /* Switch face orientation. */
    glColor4f(0.1, 0.1, 0.7, 1.0);
    drawFloor();
    glFrontFace(GL_CCW);

    if (renderShadow) {
      if (stencilShadow) {
	/* Draw the floor with stencil value 3.  This helps us only 
	   draw the shadow once per floor pixel (and only on the
	   floor pixels). */
        glEnable(GL_STENCIL_TEST);
        glStencilFunc(GL_ALWAYS, 3, 0xffffffff);
        glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
      }
    }

    /* Draw "top" of floor.  Use blending to blend in reflection. */
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glColor4f(0.7, 0.0, 0.0, 0.3);
    glColor4f(1.0, 1.0, 1.0, 0.3);
    drawFloor();
    glDisable(GL_BLEND);

    if (renderDinosaur) {
      /* Draw "actual" dinosaur, not its reflection. */
      drawDinosaur();
    }

    if (renderShadow) {

      /* Render the projected shadow. */

      if (stencilShadow) {

        /* Now, only render where stencil is set above 2 (ie, 3 where
	   the top floor is).  Update stencil with 2 where the shadow
	   gets drawn so we don't redraw (and accidently reblend) the
	   shadow). */
        glStencilFunc(GL_LESS, 2, 0xffffffff);  /* draw if ==1 */
        glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
      }

      /* To eliminate depth buffer artifacts, we use polygon offset
	 to raise the depth of the projected shadow slightly so
	 that it does not depth buffer alias with the floor. */
      if (offsetShadow) {
	switch (polygonOffsetVersion) {
	case EXTENSION:
#ifdef GL_EXT_polygon_offset
	  glEnable(GL_POLYGON_OFFSET_EXT);
	  break;
#endif
#ifdef GL_VERSION_1_1
	case ONE_DOT_ONE:
          glEnable(GL_POLYGON_OFFSET_FILL);
	  break;
#endif
	case MISSING:
	  /* Oh well. */
	  break;
	}
      }

      /* Render 50% black shadow color on top of whatever the
         floor appareance is. */
      glEnable(GL_BLEND);
      glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
      glDisable(GL_LIGHTING);  /* Force the 50% black. */
      glColor4f(0.0, 0.0, 0.0, 0.5);

      glPushMatrix();
	/* Project the shadow. */
        glMultMatrixf((GLfloat *) floorShadow);
        drawDinosaur();
      glPopMatrix();

      glDisable(GL_BLEND);
      glEnable(GL_LIGHTING);

      if (offsetShadow) {
	switch (polygonOffsetVersion) {
#ifdef GL_EXT_polygon_offset
	case EXTENSION:
	  glDisable(GL_POLYGON_OFFSET_EXT);
	  break;
#endif
#ifdef GL_VERSION_1_1
	case ONE_DOT_ONE:
          glDisable(GL_POLYGON_OFFSET_FILL);
	  break;
#endif
	case MISSING:
	  /* Oh well. */
	  break;
	}
      }
      if (stencilShadow) {
        glDisable(GL_STENCIL_TEST);
      }
    }

    glPushMatrix();
    glDisable(GL_LIGHTING);
    glColor3f(1.0, 1.0, 0.0);
    if (directionalLight) {
      /* Draw an arrowhead. */
      glDisable(GL_CULL_FACE);
      glTranslatef(lightPosition[0], lightPosition[1], lightPosition[2]);
      glRotatef(lightAngle * -180.0 / M_PI, 0, 1, 0);
      glRotatef(atan(lightHeight/12) * 180.0 / M_PI, 0, 0, 1);
      glBegin(GL_TRIANGLE_FAN);
	glVertex3f(0, 0, 0);
	glVertex3f(2, 1, 1);
	glVertex3f(2, -1, 1);
	glVertex3f(2, -1, -1);
	glVertex3f(2, 1, -1);
	glVertex3f(2, 1, 1);
      glEnd();
      /* Draw a white line from light direction. */
      glColor3f(1.0, 1.0, 1.0);
      glBegin(GL_LINES);
	glVertex3f(0, 0, 0);
	glVertex3f(5, 0, 0);
      glEnd();
      glEnable(GL_CULL_FACE);
    } else {
      /* Draw a yellow ball at the light source. */
      glTranslatef(lightPosition[0], lightPosition[1], lightPosition[2]);
      glutSolidSphere(1.0, 5, 5);
    }
    glEnable(GL_LIGHTING);
    glPopMatrix();

  glPopMatrix();

  if (reportSpeed) {
    glFinish();
    end = glutGet(GLUT_ELAPSED_TIME);
    printf("Speed %.3g frames/sec (%d ms)\n", 1000.0/(end-start), end-start);
    fflush(stdout);
  }

  glutSwapBuffers();
}
Beispiel #3
0
void Polygon::draw(Light& lightSource)
{
	float PlaneVertex[4][3] = {
		{ -planeSize, planeY, -planeSize },
		{ planeSize, planeY, -planeSize },
		{ planeSize, planeY, planeSize },
		{ -planeSize, planeY, planeSize },
	};

	float PlaneNormal[] = {
		0, -1, 0,
		0, -1, 0,
		0, -1, 0,
		0, -1, 0,
	};

	float PlaneColor[] = {
		0.5, 0.5, 0.5, 1,
		0.5, 0.5, 0.5, 1,
		0.5, 0.5, 0.5, 1,
		0.5, 0.5, 0.5, 1,
	};

	GLfloat PlaneVector[4] = {
		0, 1, 0, -planeY - 0.03
	};


	// Plane underneath imade
	glEnable(GL_LIGHTING);
    glEnableClientState(GL_VERTEX_ARRAY);
    glEnableClientState(GL_NORMAL_ARRAY);
    glEnableClientState(GL_COLOR_ARRAY);

	glVertexPointer(3, GL_FLOAT, 0, &PlaneVertex[0][0]);
	glNormalPointer(GL_FLOAT, 0, PlaneNormal);
	glColorPointer(4, GL_FLOAT, 0, PlaneColor);

    glDrawArrays(GL_QUADS, 0, 4);

	glDisableClientState(GL_COLOR_ARRAY);
	glDisableClientState(GL_NORMAL_ARRAY);
	glDisableClientState(GL_VERTEX_ARRAY);


	// Fake shadows.
	glDisable(GL_LIGHTING);
	glEnableClientState(GL_VERTEX_ARRAY);
	glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specularOff.data);
	glPushMatrix();

	GLfloat matrix[4][4];
	Light stabstabstab = lightSource;
	shadowMatrix(matrix, PlaneVector, stabstabstab.position.data);
	glMultMatrixf(&matrix[0][0]);

	/*printf("%lf %lf %lf %lf\n", PlaneVector[0], PlaneVector[1], PlaneVector[2], PlaneVector[3]);
	printf("BEGIN\n");
	printf("%lf, %lf, %lf, %lf\n", matrix[0][0], matrix[0][1], matrix[0][2], matrix[0][3]); 
	printf("%lf, %lf, %lf, %lf\n", matrix[1][0], matrix[1][1], matrix[1][2], matrix[1][3]);
	printf("%lf, %lf, %lf, %lf\n", matrix[2][0], matrix[2][1], matrix[2][2], matrix[2][3]);
	printf("%lf, %lf, %lf, %lf\n", matrix[3][0], matrix[3][1], matrix[3][2], matrix[3][3]);
	printf("END\n\n\n");*/

    glVertexPointer(3, GL_FLOAT, 0, &vertexArray[0]);
    shadowColor.applyToRender();
    // Draw every face of the polygon.
    for(int i = 0; i < faces.size(); i++)
    {
        faces[i]->draw();
    }
	glPopMatrix();
    

	// Polygon pieces.
	glEnable(GL_LIGHTING);
    glEnableClientState(GL_VERTEX_ARRAY);
    glEnableClientState(GL_NORMAL_ARRAY);
    glEnableClientState(GL_COLOR_ARRAY);
    
	glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, fillColor.data);
    glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specularOn.data);
    
    glVertexPointer(3, GL_FLOAT, 0, &vertexArray[0]);
    glNormalPointer(GL_FLOAT, 0, &normalArray[0]);
    glColorPointer(4, GL_FLOAT, 0, &colorArray[0]);
    
    // Draw every face of the polygon.
    for(size_t i = 0; i < faces.size(); i++)
    {
        faces[i]->draw();
    }

	glDisableClientState(GL_COLOR_ARRAY);
	glDisableClientState(GL_NORMAL_ARRAY);
	glDisableClientState(GL_VERTEX_ARRAY);
}
void Robot::applyShadow(GLfloat rows, GLfloat columns) {
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        glEnable(GL_BLEND);
        glDisable(GL_LIGHTING);
         if (calculateAlpha(0, 0, rows, columns) >=0) {
             glPushMatrix();
                glEnable(GL_STENCIL_TEST);
                glStencilFunc(GL_EQUAL, 10, ~0);
                glStencilOp(GL_KEEP, GL_KEEP, GL_ZERO);
                glTranslatef(xPos, 0.02f, zPos); 
                TextureManager::getInstance()->toggleTextures();
                shadowMatrix(0-xPos, 12, 0-zPos, 1.0f);
                
                glColor4f(0.0, 0.0, 0.0, calculateAlpha(0, 0, rows, columns));
                model->draw();
                //draw();
                TextureManager::getInstance()->toggleTextures();
                
                 glDisable(GL_STENCIL_TEST); 
             glPopMatrix();
         }
            if (calculateAlpha(0, rows, rows, columns) >=0) {
            glPushMatrix();
                glEnable(GL_STENCIL_TEST);
                glStencilFunc(GL_EQUAL, 10, ~0);
                glStencilOp(GL_KEEP, GL_KEEP, GL_ZERO);
                glTranslatef(xPos, 0.02f, zPos); 
                TextureManager::getInstance()->toggleTextures();
                shadowMatrix(0-xPos, 12, rows-zPos, 1.0f);
                glColor4f(0.0, 0.0, 0.0, calculateAlpha(0, rows, rows, columns));
                model->draw();
                //draw();
                TextureManager::getInstance()->toggleTextures();
                glDisable(GL_STENCIL_TEST); 
             glPopMatrix();
            }
            if (calculateAlpha(columns, 0, rows, columns) >=0) {
            glPushMatrix();
                glEnable(GL_STENCIL_TEST);
                glStencilFunc(GL_EQUAL, 10, ~0);
                glStencilOp(GL_KEEP, GL_KEEP, GL_ZERO);
                glTranslatef(xPos, 0.02f, zPos); 
                TextureManager::getInstance()->toggleTextures();
                shadowMatrix(columns-xPos, 12, 0-zPos, 1.0f);
                glColor4f(0.0, 0.0, 0.0, calculateAlpha(columns, 0, rows, columns));
                model->draw();
                //draw();
                TextureManager::getInstance()->toggleTextures();
                glDisable(GL_STENCIL_TEST); 
             glPopMatrix();
            }
            if (calculateAlpha(columns, rows, rows, columns) >=0) {
            glPushMatrix();
                glEnable(GL_STENCIL_TEST);
                glStencilFunc(GL_EQUAL, 10, ~0);
                glStencilOp(GL_KEEP, GL_KEEP, GL_ZERO);
                glTranslatef(xPos, 0.02f, zPos); 
                TextureManager::getInstance()->toggleTextures();
                shadowMatrix(columns-xPos, 12, rows-zPos, 1.0f);
                glColor4f(0.0, 0.0, 0.0, calculateAlpha(columns, rows, rows, columns));
                model->draw();
                //draw();
                TextureManager::getInstance()->toggleTextures();
                glDisable(GL_STENCIL_TEST); 
             glPopMatrix();
            }
    //}
    //glDisable(GL_TEXTURE_2D);
                
                
                
                
                //glDisable(GL_STENCIL_TEST);  
       // glPopMatrix();
                    
        glEnable(GL_DEPTH_TEST);
        glDisable(GL_BLEND);
        glEnable(GL_LIGHTING);
        //glEnable(GL_COLOR_MATERIAL);
    //}
    
}
Beispiel #5
0
static void redraw(int object)
{
  int start, end;
  shadowMatrix(floorShadow, floorPlane, light_Position);
  glPushMatrix();
    if (renderShadow) {
      if (stencilShadow) {
        /* Now, only render where stencil is set above 2 (ie, 3 where
	   the top floor is).  Update stencil with 2 where the shadow
	   gets drawn so we don't redraw (and accidently reblend) the
	   shadow). */
        glStencilFunc(GL_LESS, 2, 0xffffffff); 
        glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
      }
      /* To eliminate depth buffer artifacts, we use polygon offset
	 to raise the depth of the projected shadow slightly so
	 that it does not depth buffer alias with the floor. */
      if (offsetShadow) {
	switch (polygonOffsetVersion) {
	case EXTENSION:
#ifdef GL_EXT_polygon_offset
	  glEnable(GL_POLYGON_OFFSET_EXT);
	  break;
#endif
#ifdef GL_VERSION_1_1
	case ONE_DOT_ONE:
          glEnable(GL_POLYGON_OFFSET_FILL);
	  break;
#endif
	case MISSING:
	  break;
	}
      }
      /* Render 50% black shadow color on top of whatever the
         floor appareance is. */
      glEnable(GL_BLEND);
      glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
      glDisable(GL_LIGHTING);  /* Force the 50% black. */
      glColor4f(0.0, 0.0, 0.0, 0.5);

      glPushMatrix();
		/* Project the shadow. */
        glMultMatrixf((GLfloat *) floorShadow);
		if(object == 1)
		{
			glScaled(.07, .05, .07);
			//glRotated(83, 0.0, 1.0, 0.0);
			glTranslatef(-6,12,-6);
			//glRotatef(180,0,0,1);
		    glCallList(vtd_dl::teslaL1DL);
		}
		else if(object == 2)
		{
			glScaled(0.15, 0.15, 0.15);
			glTranslatef(-.5,1,-.5);
			glCallList(vtd_dl::turretDL);
		}
		else if(object == 3)
		{
			 glScaled(0.03, 0.03, 0.03);
			 glRotated(90, 0.0, 1.0, 0.0);
			 glTranslatef(-6,12,-6);
			 glCallList(vtd_dl::backtrackL1DL);
		}
		else if(object == 4)
		{
			glScaled(0.035, 0.035, 0.035);
			glTranslatef(-5,10,-5);
			glCallList(vtd_dl::fanL1DL);
		}
		else if(object == 5)
		{
			glScalef(0.4, 0.4, 0.4);
			glTranslatef(-.4,0,-.5);
			glCallList(vtd_dl::lockL1DL);
		}
		else if(object == 6)
		{
			glScaled(.3,.2,.3);
			glTranslatef(-.5,1,-.5);
			glCallList(vtd_dl::blkhatL1DL);			
		}
		else if(object == 7)
		{
		    glScaled(0.1, 0.1, 0.1);
			glRotatef(90, 1.0, 1.0, 0.0);
			glTranslatef(0,0,-3);
		    glCallList(vtd_dl::wormL1DL);
		}
		else if(object == 8)
		{
		    //glScaled(0.5, 0.5, 0.5);
			glTranslatef(-.15,.25,0);
			glutSolidSphere(.2,10,10);
		    //glCallList(vtd_dl::virusDL);
		}
		else if(object == 9)
		{
			glScaled(0.20, 0.20, 0.20);
			glTranslatef(-0.5,1,-0.5);
			glCallList(vtd_dl::forkbL1DL);
		}
		else if(object == 10)
		{
			glScaled(0.10, 0.10, 0.10);
			glTranslatef(-3,6,-3);
			glCallList(vtd_dl::trojanL1DL);
		}
      glPopMatrix();

      glDisable(GL_BLEND);
      glEnable(GL_LIGHTING);

      if (offsetShadow) {
	switch (polygonOffsetVersion) {
#ifdef GL_EXT_polygon_offset
	case EXTENSION:
	  glDisable(GL_POLYGON_OFFSET_EXT);
	  break;
#endif
#ifdef GL_VERSION_1_1
	case ONE_DOT_ONE:
          glDisable(GL_POLYGON_OFFSET_FILL);
	  break;
#endif
	case MISSING:
	  break;
	}
      }
      if (stencilShadow) {
        glDisable(GL_STENCIL_TEST);
      }
    }
  glPopMatrix();
}
void LevelRenderer::buildMap()
{
    GrassModel::teamNumber = false;
    TextureManager::getInstance()->toggleTextures(true);
    TextureManager::getInstance()->toggleSkins(0);
    //SKIN1 W/OUT TEAM NUMBER ----------------------------------------------------------------------------------------
    glNewList(2, GL_COMPILE);
    /*for(int i = 0; i < rows; i++) {
    	for(int j = 0; j < columns; j++) {
    		glPushMatrix();

                glTranslatef((GLfloat)j, (GLfloat)0, (GLfloat)i);
    			models[ level[i][j] ]->draw();
    		glPopMatrix();
    	}
    }*/
    for(int i = 0; i < rows; i++) {
        for(int j = 0; j < columns; j++) {
            glPushMatrix();

            if (level[i][j]==0 || level[i][j]==11)
            {
                glEnable(GL_STENCIL_TEST);
                glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
                glStencilFunc(GL_ALWAYS, 10, ~0);

            }

            glTranslatef((GLfloat)j, (GLfloat)0, (GLfloat)i);
            models[ level[i][j] ]->draw();

            //also draw a grass tile under models
            if(level[i][j] >=11) {
                models[0]->draw();
            }

            glDisable(GL_STENCIL_TEST);
            glPopMatrix();
        }
    }
    //SHADOWS-----------------------------------

    //glDisable(GL_LIGHTING);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    //glEnable(GL_COLOR_MATERIAL);

    glEnable(GL_BLEND);
    for(int i = 0; i < rows; i++) {
        for(int j = 0; j < columns; j++) {
            if(level[i][j]!=0 && level[i][j]!=3 && level[i][j]!= 8 && level[i][j]!= 9 && level[i][j]!= 10) {
                glPushMatrix();
                glEnable(GL_STENCIL_TEST);
                glStencilFunc(GL_EQUAL, 10, ~0);
                glStencilOp(GL_KEEP, GL_KEEP, GL_ZERO);
                //glColor4f(0.0, 0.0, 0.0, 0.5f);

                glTranslatef((GLfloat)j, (GLfloat)0.02, (GLfloat)i);
                if(i < rows/2 && j < columns/2) {
                    shadowMatrix(light1->getPosX()-j, light1->getPosY()*2, light1->getPosZ()-i, 1.0f);
                    glColor4f(0.0f, 0.0f, 0.0f, calculateAlpha((GLfloat)j, (GLfloat)i, 0.0f, 0.0f, (GLfloat)rows, (GLfloat)columns));

                }
                else if(i< rows/2 && j <= columns) {
                    shadowMatrix(light2->getPosX()-j, light2->getPosY()*2, light2->getPosZ()-i, 1.0f);
                    glColor4f(0.0f, 0.0f, 0.0f, calculateAlpha((GLfloat)j, (GLfloat)i, (GLfloat)columns, 0.0f, (GLfloat)rows, (GLfloat)columns));

                }
                else if(i<= rows && j < columns/2) {
                    shadowMatrix(light4->getPosX()-j, light4->getPosY()*2, light4->getPosZ()-i, 1.0f);
                    glColor4f(0.0, 0.0, 0.0, calculateAlpha((GLfloat)j, (GLfloat)i, 0.0f, (GLfloat)rows, (GLfloat)rows, (GLfloat)columns));

                }
                else if(i<= rows && j <= columns) {
                    shadowMatrix(light3->getPosX()-j, light3->getPosY()*2, light3->getPosZ()-i, 1.0f);
                    glColor4f(0.0, 0.0, 0.0, calculateAlpha((GLfloat)j, (GLfloat)i, (GLfloat)columns, (GLfloat)rows, (GLfloat)rows, (GLfloat)columns));
                }
                models[ level[i][j] ]->draw();
                glDisable(GL_STENCIL_TEST);
                glPopMatrix();
            }
        }
    }
    //glEnable(GL_DEPTH_TEST);

    glEnable(GL_DEPTH_TEST);
    glDisable(GL_BLEND);
    glEnable(GL_LIGHTING);

    //-------------------------------------------
    glEndList();

    //SKIN2 W/OUT TEAM NUMBER ----------------------------------------------------------------------------------------
    glNewList(6, GL_COMPILE);
    TextureManager::getInstance()->toggleSkins(1);

    for(int i = 0; i < rows; i++) {
        for(int j = 0; j < columns; j++) {
            glPushMatrix();

            if (level[i][j]==0 || level[i][j]==11)
            {
                glEnable(GL_STENCIL_TEST);
                glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
                glStencilFunc(GL_ALWAYS, 10, ~0);

            }

            glTranslatef((GLfloat)j, (GLfloat)0, (GLfloat)i);
            models[ level[i][j] ]->draw();

            //also draw a grass tile under models
            if(level[i][j] >=11) {
                models[0]->draw();
            }

            glDisable(GL_STENCIL_TEST);
            glPopMatrix();
        }
    }
    //SHADOWS-----------------------------------

    //glDisable(GL_LIGHTING);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    //glEnable(GL_COLOR_MATERIAL);

    glEnable(GL_BLEND);
    for(int i = 0; i < rows; i++) {
        for(int j = 0; j < columns; j++) {
            if(level[i][j]!=0 && level[i][j]!=3 && level[i][j]!= 8 && level[i][j]!= 9 && level[i][j]!= 10) {
                glPushMatrix();
                glEnable(GL_STENCIL_TEST);
                glStencilFunc(GL_EQUAL, 10, ~0);
                glStencilOp(GL_KEEP, GL_KEEP, GL_ZERO);
                //glColor4f(0.0, 0.0, 0.0, 0.5f);

                glTranslatef((GLfloat)j, (GLfloat)0.02, (GLfloat)i);
                if(i < rows/2 && j < columns/2) {
                    shadowMatrix(light1->getPosX()-j, light1->getPosY()*2, light1->getPosZ()-i, 1.0f);
                    glColor4f(0.0, 0.0, 0.0, calculateAlpha((GLfloat)j, (GLfloat)i, 0.0f, 0.0f, (GLfloat)rows, (GLfloat)columns));

                }
                else if(i< rows/2 && j <= columns) {
                    shadowMatrix(light2->getPosX()-j, light2->getPosY()*2, light2->getPosZ()-i, 1.0f);
                    glColor4f(0.0, 0.0, 0.0, calculateAlpha((GLfloat)j, (GLfloat)i, (GLfloat)columns, 0.0f, (GLfloat)rows, (GLfloat)columns));

                }
                else if(i<= rows && j < columns/2) {
                    shadowMatrix(light4->getPosX()-j, light4->getPosY()*2, light4->getPosZ()-i, 1.0f);
                    glColor4f(0.0, 0.0, 0.0, calculateAlpha((GLfloat)j, (GLfloat)i, 0.0f, (GLfloat)rows, (GLfloat)rows, (GLfloat)columns));

                }
                else if(i<= rows && j <= columns) {
                    shadowMatrix(light3->getPosX()-j, light3->getPosY()*2, light3->getPosZ()-i, 1.0f);
                    glColor4f(0.0, 0.0, 0.0, calculateAlpha((GLfloat)j, (GLfloat)i, (GLfloat)columns, (GLfloat)rows, (GLfloat)rows, (GLfloat)columns));
                }
                models[ level[i][j] ]->draw();
                glDisable(GL_STENCIL_TEST);
                glPopMatrix();
            }
        }
    }
    //glEnable(GL_DEPTH_TEST);

    glEnable(GL_DEPTH_TEST);
    glDisable(GL_BLEND);
    glEnable(GL_LIGHTING);

    //-------------------------------------------
    glEndList();

    //LIST FOR NO TEXTURES W/OUT TEAM NUMBER ----------------------------------------------------------------------------------------
    BoundingBox* tempBox;
    glNewList(5, GL_COMPILE);
    TextureManager::getInstance()->toggleTextures(false);

    for(int i = 0; i < rows; i++) {
        for(int j = 0; j < columns; j++) {

            if (level[i][j]==0)
            {
                glEnable(GL_STENCIL_TEST);
                glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
                glStencilFunc(GL_ALWAYS, 10, ~0);

            }
            glPushMatrix();
            glTranslatef((GLfloat)j, (GLfloat)0, (GLfloat)i);
            models[ level[i][j] ]->draw();

            //also draw a grass tile under models
            if(level[i][j] >=12) {
                models[0]->draw();
            }
            glPopMatrix();
            glDisable(GL_STENCIL_TEST);
            switch(level[i][j]) {
            case 1:
            case 6:
            case 7: //hills, plain and holloy block
                tempBox = new BoundingBox((GLfloat)j, 0.0f, (GLfloat)i, (GLfloat)(j+1), 1.0f, (GLfloat)(i+1));
                lrBoxes->staticBoxes.push_back(tempBox);
                tempBox->draw();
                break;
            case 4:
            case 5: //half blocks
                tempBox = new BoundingBox((GLfloat)j, 0.0f, (GLfloat)i, (GLfloat)(j+1),0.5f, (GLfloat)(i+1));
                lrBoxes->staticBoxes.push_back(tempBox);
                tempBox->draw();
                break;
            case 2: //mountains
                tempBox = new BoundingBox((GLfloat)j, 0.0f, (GLfloat)i, (GLfloat)(j+2),3.75f, (GLfloat)(i+1));
                lrBoxes->staticBoxes.push_back(tempBox);
                tempBox->draw();
                break;
            case 3: //fence
                tempBox = new BoundingBox((GLfloat)j, 0.0f, (GLfloat)i, (GLfloat)(j+1),2.75f, (GLfloat)(i+1));
                lrBoxes->staticBoxes.push_back(tempBox);
                tempBox->draw();
                break;
            case 8:
            case 9:
            case 10:
            case 11: //pits and light rubble
                tempBox = new BoundingBox((GLfloat)j, 0.0f, (GLfloat)i, (GLfloat)(j+1),0.01f, (GLfloat)(i+1));
                lrBoxes->staticBoxes.push_back(tempBox);
                tempBox->draw();
                break;
            case 13://base
                //5.0f,1.25f,4.0f
                tempBox = new BoundingBox((GLfloat)j, 0.0f, (GLfloat)i, (GLfloat)(j+5.0f),1.25f, (GLfloat)(i+2.5f));
                lrBoxes->staticBoxes.push_back(tempBox);
                tempBox->draw();
                tempBox = new BoundingBox((GLfloat)(j+1.0f), 0.0f, (GLfloat)(i+2.5f), (GLfloat)(j+4.0f),0.75f, (GLfloat)(i+4.0f));
                lrBoxes->staticBoxes.push_back(tempBox);
                tempBox->draw();
                break;
            case 12://factory
                //3.0f,1.25f,2.0f
                //tempBox = new BoundingBox((GLfloat)i, 0.0f, (GLfloat)j, (GLfloat)(i+3.0f),1.25f, (GLfloat)(j+1.0f));
                tempBox = new BoundingBox((GLfloat)j, 0.0f, (GLfloat)i, (GLfloat)(j+3.0f),1.25f, (GLfloat)(i+1.0f));
                lrBoxes->staticBoxes.push_back(tempBox);
                tempBox->draw();
                //tempBox = new BoundingBox((GLfloat)i, 0.0f, (GLfloat)(j+1.0f), (GLfloat)(i+3.0f),0.75f, (GLfloat)(j+2.0f));
                tempBox = new BoundingBox((GLfloat)j, 0.0f, (GLfloat)(i+1.0f), (GLfloat)(j+3.0f),0.75f, (GLfloat)(i+2.0f));
                lrBoxes->staticBoxes.push_back(tempBox);
                tempBox->draw();
                break;
            case 14:
                tempBox = new BoundingBox((GLfloat)j, 0.0f, (GLfloat)i, (GLfloat)(j+1.0f),8.0f, (GLfloat)(i+1.0f));
                lrBoxes->staticBoxes.push_back(tempBox);
                tempBox->draw();
                //tempBox = new BoundingBox((GLfloat)i, 0.0f, (GLfloat)(j+1.0f), (GLfloat)(i+3.0f),0.75f, (GLfloat)(j+2.0f));
                break;
            default:
                break;
            }
        }
    }
    //SHADOWS-----------------------------------

    //glDisable(GL_LIGHTING);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    //glEnable(GL_COLOR_MATERIAL);

    glEnable(GL_BLEND);
    for(int i = 0; i < rows; i++) {
        for(int j = 0; j < columns; j++) {
            if(level[i][j]!=0 && level[i][j]!=3 && level[i][j]!= 8 && level[i][j]!= 9 && level[i][j]!= 10) {
                glPushMatrix();
                glEnable(GL_STENCIL_TEST);
                glStencilFunc(GL_EQUAL, 10, ~0);
                glStencilOp(GL_KEEP, GL_KEEP, GL_ZERO);
                //glColor4f(0.0, 0.0, 0.0, 0.5f);

                glTranslatef((GLfloat)j, (GLfloat)0.02, (GLfloat)i);
                if(i < rows/2 && j < columns/2) {
                    shadowMatrix(light1->getPosX()-j, light1->getPosY()*2, light1->getPosZ()-i, 1.0f);
                    glColor4f(0.0, 0.0, 0.0, calculateAlpha((GLfloat)j, (GLfloat)i, 0, 0, (GLfloat)rows, (GLfloat)columns));

                }
                else if(i< rows/2 && j <= columns) {
                    shadowMatrix(light2->getPosX()-j, light2->getPosY()*2, light2->getPosZ()-i, 1.0f);
                    glColor4f(0.0, 0.0, 0.0, calculateAlpha((GLfloat)j, (GLfloat)i, (GLfloat)columns, 0, (GLfloat)rows, (GLfloat)columns));

                }
                else if(i<= rows && j < columns/2) {
                    shadowMatrix(light4->getPosX()-j, light4->getPosY()*2, light4->getPosZ()-i, 1.0f);
                    glColor4f(0.0, 0.0, 0.0, calculateAlpha((GLfloat)j, (GLfloat)i, 0, (GLfloat)rows, (GLfloat)rows, (GLfloat)columns));

                }
                else if(i<= rows && j <= columns) {
                    shadowMatrix(light3->getPosX()-j, light3->getPosY()*2, light3->getPosZ()-i, 1.0f);
                    glColor4f(0.0, 0.0, 0.0, calculateAlpha((GLfloat)j, (GLfloat)i, (GLfloat)columns, (GLfloat)rows, (GLfloat)rows, (GLfloat)columns));
                }
                models[ level[i][j] ]->draw();
                glDisable(GL_STENCIL_TEST);
                glPopMatrix();
            }
        }
    }
    //glEnable(GL_DEPTH_TEST);

    glEnable(GL_DEPTH_TEST);
    glDisable(GL_BLEND);
    glEnable(GL_LIGHTING);

    //-------------------------------------------
    glEndList();
    delete tempBox;

    GrassModel::teamNumber = true;
    TextureManager::getInstance()->toggleTextures(true);
    TextureManager::getInstance()->toggleSkins(0);

    //SKIN1 W/ TEAM NUMBER ----------------------------------------------------------------------------------------
    glNewList(8, GL_COMPILE);
    for(int i = 0; i < rows; i++) {
        for(int j = 0; j < columns; j++) {
            glPushMatrix();

            if (level[i][j]==0 || level[i][j]==11)
            {
                glEnable(GL_STENCIL_TEST);
                glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
                glStencilFunc(GL_ALWAYS, 10, ~0);

            }

            glTranslatef((GLfloat)j, (GLfloat)0, (GLfloat)i);
            models[ level[i][j] ]->draw();

            //also draw a grass tile under models
            if(level[i][j] >=11) {
                models[0]->draw();
            }

            glDisable(GL_STENCIL_TEST);
            glPopMatrix();
        }
    }
    //SHADOWS-----------------------------------

    //glDisable(GL_LIGHTING);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    //glEnable(GL_COLOR_MATERIAL);

    glEnable(GL_BLEND);
    for(int i = 0; i < rows; i++) {
        for(int j = 0; j < columns; j++) {
            if(level[i][j]!=0 && level[i][j]!=3 && level[i][j]!= 8 && level[i][j]!= 9 && level[i][j]!= 10) {
                glPushMatrix();
                glEnable(GL_STENCIL_TEST);
                glStencilFunc(GL_EQUAL, 10, ~0);
                glStencilOp(GL_KEEP, GL_KEEP, GL_ZERO);
                //glColor4f(0.0, 0.0, 0.0, 0.5f);

                glTranslatef((GLfloat)j, (GLfloat)0.02, (GLfloat)i);
                if(i < rows/2 && j < columns/2) {
                    shadowMatrix(light1->getPosX()-j, light1->getPosY()*2, light1->getPosZ()-i, 1.0f);
                    glColor4f(0.0, 0.0, 0.0, calculateAlpha((GLfloat)j, (GLfloat)i, 0, 0, (GLfloat)rows, (GLfloat)columns));

                }
                else if(i< rows/2 && j <= columns) {
                    shadowMatrix(light2->getPosX()-j, light2->getPosY()*2, light2->getPosZ()-i, 1.0f);
                    glColor4f(0.0, 0.0, 0.0, calculateAlpha((GLfloat)j, (GLfloat)i, (GLfloat)columns, 0, (GLfloat)rows, (GLfloat)columns));

                }
                else if(i<= rows && j < columns/2) {
                    shadowMatrix(light4->getPosX()-j, light4->getPosY()*2, light4->getPosZ()-i, 1.0f);
                    glColor4f(0.0, 0.0, 0.0, calculateAlpha((GLfloat)j, (GLfloat)i, 0, (GLfloat)rows, (GLfloat)rows,(GLfloat)columns));

                }
                else if(i<= rows && j <= columns) {
                    shadowMatrix(light3->getPosX()-j, light3->getPosY()*2, light3->getPosZ()-i, 1.0f);
                    glColor4f(0.0, 0.0, 0.0, calculateAlpha((GLfloat)j, (GLfloat)i, (GLfloat)columns, (GLfloat)rows, (GLfloat)rows, (GLfloat)columns));
                }
                models[ level[i][j] ]->draw();
                glDisable(GL_STENCIL_TEST);
                glPopMatrix();
            }
        }
    }
    //glEnable(GL_DEPTH_TEST);

    glEnable(GL_DEPTH_TEST);
    glDisable(GL_BLEND);
    glEnable(GL_LIGHTING);

    //-------------------------------------------
    glEndList();

    //SKIN2 W TEAM NUMBER ----------------------------------------------------------------------------------------
    glNewList(9, GL_COMPILE);
    TextureManager::getInstance()->toggleSkins(1);

    for(int i = 0; i < rows; i++) {
        for(int j = 0; j < columns; j++) {
            glPushMatrix();

            if (level[i][j]==0 || level[i][j]==11)
            {
                glEnable(GL_STENCIL_TEST);
                glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
                glStencilFunc(GL_ALWAYS, 10, ~0);

            }

            glTranslatef((GLfloat)j, (GLfloat)0, (GLfloat)i);
            models[ level[i][j] ]->draw();

            //also draw a grass tile under models
            /*if(level[i][j] >=11){
            	models[0]->draw();
            }*/

            glDisable(GL_STENCIL_TEST);
            glPopMatrix();
        }
    }
    //SHADOWS-----------------------------------

    //glDisable(GL_LIGHTING);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    //glEnable(GL_COLOR_MATERIAL);

    glEnable(GL_BLEND);
    for(int i = 0; i < rows; i++) {
        for(int j = 0; j < columns; j++) {
            if(level[i][j]!=0 && level[i][j]!=3 && level[i][j]!= 8 && level[i][j]!= 9 && level[i][j]!= 10) {
                glPushMatrix();
                glEnable(GL_STENCIL_TEST);
                glStencilFunc(GL_EQUAL, 10, ~0);
                glStencilOp(GL_KEEP, GL_KEEP, GL_ZERO);
                //glColor4f(0.0, 0.0, 0.0, 0.5f);

                glTranslatef((GLfloat)j, (GLfloat)0.02, (GLfloat)i);
                if(i < rows/2 && j < columns/2) {
                    shadowMatrix(light1->getPosX()-j, light1->getPosY()*2, light1->getPosZ()-i, 1.0f);
                    glColor4f(0.0, 0.0, 0.0, calculateAlpha((GLfloat)j, (GLfloat)i, 0, 0, (GLfloat)rows, (GLfloat)columns));

                }
                else if(i< rows/2 && j <= columns) {
                    shadowMatrix(light2->getPosX()-j, light2->getPosY()*2, light2->getPosZ()-i, 1.0f);
                    glColor4f(0.0, 0.0, 0.0, calculateAlpha((GLfloat)j, (GLfloat)i, (GLfloat)columns, 0,(GLfloat)rows, (GLfloat)columns));

                }
                else if(i<= rows && j < columns/2) {
                    shadowMatrix(light4->getPosX()-j, light4->getPosY()*2, light4->getPosZ()-i, 1.0f);
                    glColor4f(0.0, 0.0, 0.0, calculateAlpha((GLfloat)j, (GLfloat)i, 0, (GLfloat)rows, (GLfloat)rows, (GLfloat)columns));

                }
                else if(i<= rows && j <= columns) {
                    shadowMatrix(light3->getPosX()-j, light3->getPosY()*2, light3->getPosZ()-i, 1.0f);
                    glColor4f(0.0, 0.0, 0.0, calculateAlpha((GLfloat)j, (GLfloat)i, (GLfloat)columns, (GLfloat)rows, (GLfloat)rows, (GLfloat)columns));
                }
                models[ level[i][j] ]->draw();
                glDisable(GL_STENCIL_TEST);
                glPopMatrix();
            }
        }
    }
    //glEnable(GL_DEPTH_TEST);

    glEnable(GL_DEPTH_TEST);
    glDisable(GL_BLEND);
    glEnable(GL_LIGHTING);

    //-------------------------------------------
    glEndList();

    //LIST FOR NO TEXTURES W/ TEAM NUMBER ----------------------------------------------------------------------------------------
    glNewList(10, GL_COMPILE);
    toggleTeamNumber();
    TextureManager::getInstance()->toggleTextures(false);

    for(int i = 0; i < rows; i++) {
        for(int j = 0; j < columns; j++) {

            if (level[i][j]==0)
            {
                glEnable(GL_STENCIL_TEST);
                glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
                glStencilFunc(GL_ALWAYS, 10, ~0);

            }
            glPushMatrix();
            glTranslatef((GLfloat)j, (GLfloat)0, (GLfloat)i);
            models[ level[i][j] ]->draw();

            //also draw a grass tile under models
            /*if(level[i][j] >=12){
            	models[0]->draw();
            }*/
            glPopMatrix();
            glDisable(GL_STENCIL_TEST);
            switch(level[i][j]) {
            case 1:
            case 6:
            case 7: //hills, plain and holloy block
                tempBox = new BoundingBox((GLfloat)j, 0.0f, (GLfloat)i, (GLfloat)(j+1), 1.0f, (GLfloat)(i+1));
                lrBoxes->staticBoxes.push_back(tempBox);
                tempBox->draw();
                break;
            case 4:
            case 5: //half blocks
                tempBox = new BoundingBox((GLfloat)j, 0.0f, (GLfloat)i, (GLfloat)(j+1),0.5f, (GLfloat)(i+1));
                lrBoxes->staticBoxes.push_back(tempBox);
                tempBox->draw();
                break;
            case 2: //mountains
                tempBox = new BoundingBox((GLfloat)j, 0.0f, (GLfloat)i, (GLfloat)(j+2),3.75f, (GLfloat)(i+1));
                lrBoxes->staticBoxes.push_back(tempBox);
                tempBox->draw();
                break;
            case 3: //fence
                tempBox = new BoundingBox((GLfloat)j, 0.0f, (GLfloat)i, (GLfloat)(j+1),2.75f, (GLfloat)(i+1));
                lrBoxes->staticBoxes.push_back(tempBox);
                tempBox->draw();
                break;
            case 8:
            case 9:
            case 10:
            case 11: //pits and light rubble
                tempBox = new BoundingBox((GLfloat)j, 0.0f, (GLfloat)i, (GLfloat)(j+1),0.01f, (GLfloat)(i+1));
                lrBoxes->staticBoxes.push_back(tempBox);
                tempBox->draw();
                break;
            case 13://base
                //5.0f,1.25f,4.0f
                tempBox = new BoundingBox((GLfloat)j, 0.0f, (GLfloat)i, (GLfloat)(j+5.0f),1.25f, (GLfloat)(i+2.5f));
                lrBoxes->staticBoxes.push_back(tempBox);
                tempBox->draw();
                tempBox = new BoundingBox((GLfloat)(j+1.0f), 0.0f, (GLfloat)(i+2.5f), (GLfloat)(j+4.0f),0.75f, (GLfloat)(i+4.0f));
                lrBoxes->staticBoxes.push_back(tempBox);
                tempBox->draw();
                break;
            case 12://factory
                //3.0f,1.25f,2.0f
                //tempBox = new BoundingBox((GLfloat)i, 0.0f, (GLfloat)j, (GLfloat)(i+3.0f),1.25f, (GLfloat)(j+1.0f));
                tempBox = new BoundingBox((GLfloat)j, 0.0f, (GLfloat)i, (GLfloat)(j+3.0f),1.25f, (GLfloat)(i+1.0f));
                lrBoxes->staticBoxes.push_back(tempBox);
                tempBox->draw();
                //tempBox = new BoundingBox((GLfloat)i, 0.0f, (GLfloat)(j+1.0f), (GLfloat)(i+3.0f),0.75f, (GLfloat)(j+2.0f));
                tempBox = new BoundingBox((GLfloat)j, 0.0f, (GLfloat)(i+1.0f), (GLfloat)(j+3.0f),0.75f, (GLfloat)(i+2.0f));
                lrBoxes->staticBoxes.push_back(tempBox);
                tempBox->draw();
                break;
            case 14:
                tempBox = new BoundingBox((GLfloat)j, 0.0f, (GLfloat)i, (GLfloat)(j+1.0f),8.0f, (GLfloat)(i+1.0f));
                lrBoxes->staticBoxes.push_back(tempBox);
                //tempBox->hasNukePowerUp = true;
                tempBox->draw();
                //tempBox = new BoundingBox((GLfloat)i, 0.0f, (GLfloat)(j+1.0f), (GLfloat)(i+3.0f),0.75f, (GLfloat)(j+2.0f));
                break;
            default:
                break;
            }
        }
    }
    //SHADOWS-----------------------------------

    //glDisable(GL_LIGHTING);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    //glEnable(GL_COLOR_MATERIAL);

    glEnable(GL_BLEND);
    for(int i = 0; i < rows; i++) {
        for(int j = 0; j < columns; j++) {
            if(level[i][j]!=0 && level[i][j]!=3 && level[i][j]!= 8 && level[i][j]!= 9 && level[i][j]!= 10) {
                glPushMatrix();
                glEnable(GL_STENCIL_TEST);
                glStencilFunc(GL_EQUAL, 10, ~0);
                glStencilOp(GL_KEEP, GL_KEEP, GL_ZERO);
                //glColor4f(0.0, 0.0, 0.0, 0.5f);

                glTranslatef((GLfloat)j, (GLfloat)0.02, (GLfloat)i);
                if(i < rows/2 && j < columns/2) {
                    shadowMatrix(light1->getPosX()-j, light1->getPosY()*2, light1->getPosZ()-i, 1.0f);
                    glColor4f(0.0, 0.0, 0.0, calculateAlpha((GLfloat)j, (GLfloat)i, 0, 0, (GLfloat)rows, (GLfloat)columns));

                }
                else if(i< rows/2 && j <= columns) {
                    shadowMatrix(light2->getPosX()-j, light2->getPosY()*2, light2->getPosZ()-i, 1.0f);
                    glColor4f(0.0, 0.0, 0.0, calculateAlpha((GLfloat)j, (GLfloat)i, (GLfloat)columns, 0, (GLfloat)rows, (GLfloat)columns));

                }
                else if(i<= rows && j < columns/2) {
                    shadowMatrix(light4->getPosX()-j, light4->getPosY()*2, light4->getPosZ()-i, 1.0f);
                    glColor4f(0.0, 0.0, 0.0, calculateAlpha((GLfloat)j, (GLfloat)i,0, (GLfloat)rows, (GLfloat)rows, (GLfloat)columns));

                }
                else if(i<= rows && j <= columns) {
                    shadowMatrix(light3->getPosX()-j, light3->getPosY()*2, light3->getPosZ()-i, 1.0f);
                    glColor4f(0.0, 0.0, 0.0, calculateAlpha((GLfloat)j, (GLfloat)i, (GLfloat)columns, (GLfloat)rows, (GLfloat)rows, (GLfloat)columns));
                }
                models[ level[i][j] ]->draw();
                glDisable(GL_STENCIL_TEST);
                glPopMatrix();
            }
        }
    }
    //glEnable(GL_DEPTH_TEST);

    glEnable(GL_DEPTH_TEST);
    glDisable(GL_BLEND);
    glEnable(GL_LIGHTING);

    //-------------------------------------------
    glEndList();

    delete tempBox;

}