コード例 #1
0
ファイル: main.cpp プロジェクト: therichardnguyen/-CS184-AS3
BoundingBox RenderGroup(SceneGroup *i, vec3 color, int lod, int depth) 
{
	int ii;
	BoundingBox bbox;
		
	// if this is a terminal node
	if (i->getChildCount() == 0) {
		
		// set the correct color for the polygon
		glColor3f(color[0],color[1],color[2]);
		
		// draw the polygon if LOD == 3
		if (lod == 3)
			i->getPolygon()->draw(GL_POLYGON);
			
		// draw the polygon outline if LOD == 2
		else if (lod == 2)
			i->getPolygon()->draw(GL_LINE_LOOP);
			
		// draw the bounding box
		setColor(depth);
		i->getPolygon()->getBoundingBox().draw();
		
		// return the polygon's bounding box
		return i->getPolygon()->getBoundingBox();
	} else {
		
		// expand and traverse this node
		for(ii=0; ii<i->getChildCount();ii++) 
			bbox.expand(RenderInstance(i->getChild(ii), color, lod, depth+1));
		
		// draw this group's bounding box
		setColor(depth);
		bbox.draw();
	}
	
	return bbox;
}
コード例 #2
0
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;

}