Beispiel #1
0
void DemoState::Draw()
{

	Game::iterator it = Game::iterator("Camera");
	if (!it.seekName("DemoCam"))
	{
		assert(0);
	}
	GameObject* GO = it;
	((Camera*)GO)->Use();
	Game::instance()->DrawObjects();
	timer += DisplayManager::instance()->getDtSecs();
	if (timer < 0)
	{
		glDisable(GL_DEPTH_TEST);
		glDepthMask(GL_FALSE);
		glMatrixMode(GL_PROJECTION);
		GLfloat f[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
		glGetFloatv(GL_PROJECTION_MATRIX,f);
		glLoadIdentity();
		glMatrixMode(GL_MODELVIEW);
		glLoadIdentity();

		Splash->UseThisTexture();
		Billboard b;
		b.Draw();
		Splash->UseNoTexture();
		glEnable(GL_DEPTH_TEST);
		glDepthMask(GL_TRUE);
		glMatrixMode(GL_PROJECTION);
		glLoadMatrixf(f);

	}
	if (timer > 1)
	{
		timer = -1;
	}



}
void drawScene()
{// covert speed to string
	string speedword = to_string(speed);

	string SpeedPhrase = "Speed: ";
	SpeedPhrase.append(speedword);
	string Direction = "Direction: ";
	Direction.append(carHeading);
	glColor3f(1, 0, 0);
	//print words
	glWindowPos2i((winWidth / 2) -125, winHeight - (sHeight*1.2));
	printString(SpeedPhrase);
	glWindowPos2i((winWidth / 2) + 75, winHeight - (sHeight*1.2));
	printString(Direction);


	// Draw terrain
	glCallList(terrainID);

	glEnable(GL_LIGHTING);
	trafficLight.setMaterials();
	
	/*vector<string> test;
	test=trafficLight.GetMaterialNames();
	for (int i = 0; i < test.size(); i++)
		cout << "name: " << test[i] << endl;*/
	// North-East (NS_Signal)
	glPushMatrix();
	glTranslatef(10, 0, -10.5);
	glScalef(1/3.28/12, 1/3.28/12, 1/3.28/12);
	trafficLight.setSignal(NS_Signal);
	trafficLight.Draw();
	glPopMatrix();
	
	
	glPushMatrix();
	glTranslatef(10, 0, -10);
	glRotatef(-45, 0, 1, 0);
	glCallList(surveillanceCameraID);
	glPopMatrix();

	// North-West (WE_Signal)
///board 1
	//glColor3f(1, 1, 0);
	glPushMatrix();
	board.Draw();
	glPopMatrix();
// board 2
	glPushMatrix();
	board2.Draw();
	glPopMatrix();

	glPushMatrix();
	glTranslatef(-10, 0, -10.5);
	glScalef(1 / 3.28 / 12, 1 / 3.28 / 12, 1 / 3.28 / 12);
	glRotatef(90, 0, 1, 0);
	trafficLight2.setSignal(WE_Signal);
	trafficLight2.Draw();
	glPopMatrix();

	glPushMatrix();
	glTranslatef(-10, 0, -10);
	glRotatef(45, 0, 1, 0);
	glCallList(surveillanceCameraID);
	glPopMatrix();
	
	// South-East (WE_Signal)
	glPushMatrix();
	glTranslatef(10, 0, 10);
	glScalef(1 / 3.28 / 12, 1 / 3.28 / 12, 1 / 3.28 / 12);
	glRotatef(-90, 0, 1, 0);
	trafficLight3.setSignal(WE_Signal);
	trafficLight3.Draw();
	glPopMatrix();

	glPushMatrix();
	glTranslatef(10, 0, 10.5);
	glRotatef(-135, 0, 1, 0);
	glCallList(surveillanceCameraID);
	glPopMatrix();

	// South West(SN_Signal)
	glPushMatrix();
	glTranslatef(-10, 0, 10);
	glScalef(1 / 3.28 / 12, 1 / 3.28 / 12, 1 / 3.28 / 12);
	glRotatef(180, 0, 1, 0);
	trafficLight4.setSignal(NS_Signal);
	trafficLight4.Draw();
	glPopMatrix();

	glPushMatrix();
	glTranslatef(-10, 0, 10.5);
	glRotatef(135, 0, 1, 0);
	glCallList(surveillanceCameraID);
	glPopMatrix();

	// Draw the car.
	glPushMatrix();
	glTranslatef(carPosition.x, carPosition.y, carPosition.z);
	glRotatef(carDirection, 0, 1, 0);
	glCallList(carID);
	glPopMatrix();



	
}