Пример #1
0
void Road::draw(){
	glPushMatrix();
		glTranslated(	getPosition().getX(),
						getPosition().getY(),
						0);
		defineMaterial(	0.00, 0.00, 0.00, 1.00,	//Ambient
						0.20, 0.20, 0.20, 1.00,	//Diffuse
						0.20, 0.20, 0.20, 1.00,	//Specular
						0.00, 0.00, 0.00, 1.00,	//Emission
						77, getTexture());		//SHININESS
		glColor3f(0.1137, 0.1137, 0.1137);
		Polygon::execute(2 * getSize().getX(), 2 * getSize().getY(), gm->getSettings().getNrPolygons(), gm->getSettings().getNrPolygons());
		for (int i = -3; i < 4; i+= 2)
			for (int j = -5; j < 6; j++){
				glPushMatrix();
					defineMaterial(	0.00, 0.00, 0.00, 1.00,	//Ambient
									1.00, 1.00, 1.00, 1.00,	//Diffuse
									1.00, 1.00, 1.00, 1.00,	//Specular
									0.00, 0.00, 0.00, 1.00,	//Emission
									77);					//SHININESS
					glColor3f(0.5764, 0.5764, 0.5764);
					glTranslated(j * (40), i * 6,0.01);
					Polygon::execute(20, 1, 2, 1);
				glPopMatrix();
			}
	glPopMatrix();
}
Пример #2
0
void Track::draw(){
	glPushMatrix();
	glEnable(GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D, getTexture());

    if(gameManager->getLightsOn() || gameManager->getModoDia() || gameManager->getCar()->getLightState()){
        defineMaterial(	0.56, 0.76, 0.83, 1.00,
                        0.00, 0.30, 0.36, 1.00,
                        0.56, 0.76, 0.83, 1.00,
                        0,0,0,1,
                        90);


    }else{
        defineMaterial(	0,0,0,0,
                        0,0,0,0,
                        0,0,0,0,
                        0,0,0,0,
                        0);
    }
    int quad = 2;
	glColor3f(0.56, 0.76, 0.83);
	for(float y = -50; y<50; y+=quad){
		for(float x = -50; x<50; x+=quad){

			glBegin(GL_POLYGON);
			glNormal3f(0, 0, 1);

			glTexCoord2f(0,0);
			glVertex3f(x, y, 50);

			glTexCoord2f(1,0);
			glVertex3f(x+quad, y, 50);

			glTexCoord2f(1,1);
			glVertex3f(x+quad, y+quad, 50);

			glTexCoord2f(0,1);
			glVertex3f(x, y+quad, 50);
			glEnd();

		}
	}
	glDisable(GL_TEXTURE_2D);
	glPopMatrix();
}
Пример #3
0
void Tunnel::draw(){
	glPushMatrix();
		//Position na colisao com a estrada, no plano Z = 0;
		glPushMatrix();
			glTranslated(-getPosition().getX(), getPosition().getY(), getPosition().getZ() + getSize().getZ() / 2);
			defineMaterial(	0.00, 0.00, 0.00, 1.00,	//Ambient
							0.50, 0.50, 0.50, 1.00,	//Diffuse
							1.00, 1.00, 1.00, 1.00,	//Specular
							0.00, 0.00, 0.00, 1.00,	//Emission
							77, getTexture());					//SHININESS
			glColor3f(0.4905, 0.4902, 0.4902);

			glPushMatrix();
				glTranslatef(-getSize().getX()/2, -getSize().getY() / 2,0);
				glScalef(getSize().getX(), 2, getSize().getZ());
				glutSolidCube(1); //Cubo baixo
			glPopMatrix();
			glPushMatrix();
				glTranslatef(-getSize().getX()/2,0, getSize().getZ() /2 );
				glScalef(getSize().getX(), getSize().getY(), 2);
				glutSolidCube(1); //Cubo Cima
			glPopMatrix();
			glPushMatrix();
				glTranslatef(-getSize().getX()/2, getSize().getY() / 2, 0);
				glScalef(getSize().getX(), 2, getSize().getZ());
				glutSolidCube(1); //Cubo baixo
			glPopMatrix();
		glPopMatrix();

		glScalef(-1, 1, 1);
		glPushMatrix();
			glTranslated(-getPosition().getX(), getPosition().getY(), getPosition().getZ() + getSize().getZ() / 2);

			glPushMatrix();
				glTranslatef(-getSize().getX()/2, -getSize().getY() / 2,0);
				glScalef(getSize().getX(), 2, getSize().getZ());
				glutSolidCube(1); //Cubo baixo
			glPopMatrix();
			glPushMatrix();
				glTranslatef(-getSize().getX()/2,0, getSize().getZ() /2 );
				glScalef(getSize().getX(), getSize().getY(), 2);
				glutSolidCube(1); //Cubo baixo
			glPopMatrix();
			glPushMatrix();
				glTranslatef(-getSize().getX()/2, getSize().getY() / 2, 0);
				glScalef(getSize().getX(), 2, getSize().getZ());
				glutSolidCube(1); //Cubo baixo
			glPopMatrix();
		
		glPopMatrix();

	glPopMatrix();
}
Пример #4
0
void TimberLog::draw(){
	glPushMatrix();
		glTranslated(getPosition().getX(), getPosition().getY(), getPosition().getZ()+0.01);
		defineMaterial(	0.01, 0.01, 0.01, 1.00,	//Ambient
						0.39, 0.25, 0.05, 1.00,	//Diffuse
						0.00, 0.00, 0.00, 1.00,	//Specular
						0.00, 0.00, 0.00, 1.00,	//Emission
						128);					//SHININESS
		glColor3f(0.2275, 0.1490, 0.0314);
		Polygon::execute(2 * getSize().getX(), 10, gm->getSettings().getNrPolygons(), gm->getSettings().getNrPolygons());
	glPopMatrix();
}
Пример #5
0
void Car::draw(){
	class WHEELS{
	public:
		static void executeNew(GLdouble no_sides, GLdouble size){
			float graus = 2 * PI / no_sides;
			GLfloat cos_aux = cos(graus / 2);
			GLfloat sin_aux = sin(graus / 2);
			glPushMatrix();
			for (int a = 0; a < no_sides; a++){
				glBegin(GL_QUADS);
					glNormal3f(cos_aux, 0, sin_aux); glVertex3f(cos_aux*size, 1, sin_aux*size);		//1
					glNormal3f(cos_aux, 0, -sin_aux); glVertex3f(cos_aux*size, 1, -sin_aux*size);		//1
					glNormal3f(cos_aux, 0, -sin_aux); glVertex3f(cos_aux*size, -1, -sin_aux*size);	//1
					glNormal3f(cos_aux, 0, sin_aux); glVertex3f(cos_aux*size, -1, sin_aux*size);		//1
				glEnd();
				glRotatef(360 / no_sides, 0, 1, 0);
			}
			glPopMatrix();
			for(int i = 0; i < 2; i++){
				glPushMatrix();
					glTranslatef(0, (i == 0) ? 1 : -1, 0);
					glBegin(GL_POLYGON);
					glNormal3f(0, (i == 0) ? 1 : -1, 0);
					for (int a = 0; a < no_sides; a++)
						glVertex3f(cos(graus * a + graus / 2)*size, 0, sin(graus * a + graus / 2)*size);
					glEnd();
				glPopMatrix();
			}
		}
	};

	glPushMatrix();
		glTranslated(getPosition().getX(), getPosition().getY(), getPosition().getZ() + getSize().getZ() / 2);
		if (gm->getSettings().getDebug()){
			glPushMatrix();
			glScalef(getSize().getX() * 2, getSize().getY() * 2, getSize().getZ() * 2);
			glutWireCube(1);
			glPopMatrix();
		}
		if (getSpeed().getX() < 0) glRotatef(180, 0, 0, 1);
		glTranslated(-getSize().getX(), 0, 0);
			
		//WHEELS
		defineMaterial(0.00, 0.00, 0.00, 1.00,	//Ambient
			0.01, 0.01, 0.01, 1.00,	//Diffuse
			0.50, 0.50, 0.50, 1.00,	//Specular
			0.00, 0.00, 0.00, 1.00,	//Emission
			32);					//SHININESS
		glColor3f(0.01, 0.01, 0.01);
		for (int i = 0; i < 2; i++){
			glPushMatrix();
				glTranslatef(0.0, (i == 0) ? -getSize().getY() : getSize().getY(), 0.0);
				glPushMatrix();
					glTranslatef(2, 0, 0);
					WHEELS::executeNew(8, 2);
				glPopMatrix();
				glPushMatrix();
					glTranslatef(2 * getSize().getX() - 2, 0, 0);
					WHEELS::executeNew(8, 2);
				glPopMatrix();
			glPopMatrix();
		}
		defineMaterial(_color.getX()*0.1, _color.getY()*0.1, _color.getZ()*0.1, 1.00,	//Ambient
			_color.getX(), _color.getY(), _color.getZ(), 1.00,	//Diffuse
			_color.getX(), _color.getY(), _color.getZ(), 1.00,	//Specular
			0.00, 0.00, 0.00, 1.00,	//Emission
			77);					//SHININESS
		glColor3f(_color.getX(), _color.getY(), _color.getZ());
		for (int i = 0; i < 2; i++){
			glPushMatrix();
			glTranslatef(0.0, (i == 0) ? -getSize().getY() : getSize().getY(), 0.0);
					glBegin(GL_QUADS);
						glNormal3f(0,-1,0);
						glVertex3f(0,0,0);
						glVertex3f(2*getSize().getX(),0,0);
						glVertex3f(2*getSize().getX(),0,3);
						glVertex3f(0,0,3);
					glEnd();
			glPopMatrix();
		}
			
			glBegin(GL_POLYGON);
				glNormal3f(-1,0,0);
				glVertex3f(0,getSize().getY(),0);
				glVertex3f(0,getSize().getY(),3);
				glVertex3f(0,-getSize().getY(),3);
				glVertex3f(0,-getSize().getY(),0);
			glEnd();
			glBegin(GL_POLYGON);
				glNormal3f(1,0,0);
				glVertex3f(2*getSize().getX(),getSize().getY(),0);
				glVertex3f(2*getSize().getX(),getSize().getY(),3);
				glVertex3f(2*getSize().getX(),-getSize().getY(),3);
				glVertex3f(2*getSize().getX(),-getSize().getY(),0);
			glEnd();
			
			
			glBegin(GL_POLYGON); // Parte de baixo do carro
				glNormal3f(0,0,-1);
				glVertex3f(0,getSize().getY(),0);
				glVertex3f(2*getSize().getX(),getSize().getY(),0);
				glVertex3f(2*getSize().getX(),-getSize().getY(),0);
				glVertex3f(0,-getSize().getY(),0);
			glEnd();
			glBegin(GL_POLYGON); // Parte de cima do carro
				glNormal3f(0,0,1);
				glVertex3f(0,getSize().getY(),3);
				glVertex3f(2*getSize().getX(),getSize().getY(),3);
				glVertex3f(2*getSize().getX(),-getSize().getY(),3);
				glVertex3f(0,-getSize().getY(),3);
			glEnd();
			
			//defineMaterial(	0.05, 0.05, 0.05, 1.00,	//Ambient
			//				0.70, 0.70, 0.70, 1.00,	//Diffuse
			//				0.70, 0.70, 0.70, 1.00,	//Specular
			//				0.00, 0.00, 0.00, 1.00,	//Emission
			//				77);					//SHININESS
			//glColor3f(0.7,0.7,0.7);
			
			glBegin(GL_POLYGON); // Topo
				glNormal3f(0,0,1);
				glVertex3f(2*getSize().getX() - 6,-getSize().getY(),5);
				glVertex3f(3,-getSize().getY(),5);
				glVertex3f(3,getSize().getY(),5);
				glVertex3f(2*getSize().getX() - 6,getSize().getY(),5);
			glEnd();
			

			defineMaterial(	0.05,0.05,0.07, 1.00,	//Ambient
							0.18, 0.17, 0.23, 1.00,	//Diffuse
							0.33, 0.33, 0.35, 1.00,	//Specular
							0.00, 0.00, 0.00, 1.00,	//Emission
							77);					//SHININESS
			glColor3f(0.25,0.25,0.25);
			glBegin(GL_POLYGON); // Trapezio frente
				glNormal3f(0,-1,0);
				glVertex3f(2,-getSize().getY(),3);
				glVertex3f(2*getSize().getX() - 2,-getSize().getY(),3);
				glVertex3f(2*getSize().getX() - 6,-getSize().getY(),5);
				glVertex3f(3,-getSize().getY(),5);
			glEnd();
			

			glBegin(GL_POLYGON); // Trapezio traz
				glNormal3f(0,1,0);
				glVertex3f(2,getSize().getY(),3);
				glVertex3f(2*getSize().getX() - 2,getSize().getY(),3);
				glVertex3f(2*getSize().getX() - 6,getSize().getY(),5);
				glVertex3f(3,getSize().getY(),5);
			glEnd();
			glBegin(GL_POLYGON);
				glNormal3f(-2, 0, 1);
				glVertex3f(2, getSize().getY(), 3);
				glVertex3f(3, getSize().getY(), 5);
				glVertex3f(3, -getSize().getY(), 5);
				glVertex3f(2, -getSize().getY(), 3);
			glEnd();
			glBegin(GL_POLYGON);
				glNormal3f(2, 0, 4);
				glVertex3f(2 * getSize().getX() - 2, getSize().getY(), 3);
				glVertex3f(2 * getSize().getX() - 6, getSize().getY(), 5);
				glVertex3f(2 * getSize().getX() - 6, -getSize().getY(), 5);
				glVertex3f(2 * getSize().getX() - 2, -getSize().getY(), 3);
			glEnd();
		glPopMatrix();
}