Example #1
0
void myInit()
{

	glActiveTexture(GL_TEXTURE0);
	//make the background look like the sky
	float blue[4] = {0.5,0.5,1.0,0.0};
	glClearColor(0.5, 0.5, 1.0, 0.0);

	glShadeModel(GL_SMOOTH);

	
	glEnable(GL_FOG);
	glFogfv(GL_FOG_COLOR,blue);
	glFogf(GL_FOG_MODE, GL_EXP2);
	glFogf(GL_FOG_START, 200);
	glFogf(GL_FOG_END, 1000);
	glFogf(GL_FOG_DENSITY, gFogDensity);

	//initial terrain
	myTerrain.initializeTerrain("../Data/Texture/Terrain/sand.tga", "../Data/Texture/Terrain/cactus.tga");

	//initial ground collision square
	groundCollSquare.setParameters(TVector(0.0, 1.0, 0.0), gCenterPoint);


	//initial tank
	tankHeightPos = myTerrain.GetHeight(gCenterPoint.X()+100.0, gCenterPoint.Z());

	myTank.setParameters("T-90.3DS", "../T-90/",TVector(gCenterPoint.X()-600.0, tankHeightPos + 9.0, gCenterPoint.Z()-20), 0.0, &myTerrain, &collisionBoxArray, &wall);
	myTank.initTank();	

	unsigned int brickTexture;

	createTexture("../Data/Texture/Brick/brick.bmp", brickTexture);

	wall.Init(myTank.getPosition().X() + 50, myTank.getPosition().Y()-8, myTank.getPosition().Z() + 20, NUM_BRICKS, brickTexture, &myTerrain);
}
Example #2
0
void caculateCameraView(unsigned int viewMode)
{
	switch(viewMode)
	{
	case 0:
		gRadViewAngle = M_PI*angleWithX/180.0 - M_PI;


		gCameraPosition.setX(myTank.getPosition().X() + 150*cos(gRadViewAngle));
		gCameraPosition.setY(myTank.getPosition().Y() + 30);
		gCameraPosition.setZ(myTank.getPosition().Z() - 150*sin(gRadViewAngle));

		camera.changePosition(gCameraPosition);
		camera.changeTarget(gCameraPosition.X() - 150.0*cos(gRadViewAngle), gCameraPosition.Y(), gCameraPosition.Z() + 150.0*sin(gRadViewAngle));
		break;
	case 1:
		gRadViewAngle = M_PI*myTank.getAngleWithX()/180.0  - M_PI;
		gCameraPosition.setX(myTank.getPosition().X() + 250*cos(gRadViewAngle));
		gCameraPosition.setY(myTank.getPosition().Y() + 50.0);
		gCameraPosition.setZ(myTank.getPosition().Z() - 250*sin(gRadViewAngle));

		camera.changePosition(gCameraPosition);
		camera.changeTarget(gCameraPosition.X() - 150.0*cos(gRadViewAngle), gCameraPosition.Y(), gCameraPosition.Z() + 150.0*sin(gRadViewAngle));
		break;
	case 2:
		gRadViewAngle = M_PI*myTank.getAngleWithX()/180.0  - M_PI*0.5;
		gCameraPosition.setX(myTank.getPosition().X() + 250*cos(gRadViewAngle));
		gCameraPosition.setY(myTank.getPosition().Y() + 50.0);
		gCameraPosition.setZ(myTank.getPosition().Z() - 250*sin(gRadViewAngle));

		camera.changePosition(gCameraPosition);
		camera.changeTarget(gCameraPosition.X() - 150.0*cos(gRadViewAngle), gCameraPosition.Y(), gCameraPosition.Z() + 150.0*sin(gRadViewAngle));
		break;
	case 3:
		gRadViewAngle = M_PI*myTank.getAngleWithX()/180.0;
		gCameraPosition.setX(myTank.getPosition().X() + 250*cos(gRadViewAngle));
		gCameraPosition.setY(myTank.getPosition().Y() + 50.0);
		gCameraPosition.setZ(myTank.getPosition().Z() - 250*sin(gRadViewAngle));

		camera.changePosition(gCameraPosition);
		camera.changeTarget(gCameraPosition.X() - 150.0*cos(gRadViewAngle), gCameraPosition.Y(), gCameraPosition.Z() + 150.0*sin(gRadViewAngle));
		break;
	}
}