Пример #1
0
void APlayerHUD::DrawHUD()
{
	Super::DrawHUD();

	//DrawActorOverlays(FVector::ZeroVector, FRotator::ZeroRotator);
	DrawMinimap();
}
Пример #2
0
bool Display(float timeDelta)
{
	if( Device )
	{
		//update audio
		AudioUpdate();

		//keyboard
		if( ::GetAsyncKeyState('W') & 0x8000f)
		{
			TheCamera.walk(40.0f * timeDelta);
			//D3DXMATRIX forwardMovement;
			//D3DXMatrixRotationY(&forwardMovement, avatarYaw);
			//D3DXVECTOR3 v(0,0,forwardSpeed);
			//D3DXVECTOR4 vec4;
			//D3DXVec3Transform(&vec4, &v, &forwardMovement);
			//avatarDirection.x = v.x = vec4.x;
			//avatarDirection.y = v.y = vec4.y;
			//avatarDirection.z = v.z = vec4.z;
			//AvatarPosition.z += v.z;
			//AvatarPosition.x += v.x;
		}
		if( ::GetAsyncKeyState('S') & 0x8000f)
		{
			TheCamera.walk(-40.0f * timeDelta);
			//D3DXMATRIX forwardMovement;
			//D3DXMatrixRotationY(&forwardMovement, avatarYaw);
			//D3DXVECTOR3 v(0,0,-forwardSpeed);
			//D3DXVECTOR4 vec4;
			//D3DXVec3Transform(&vec4, &v, &forwardMovement);
			//avatarDirection.x = v.x = vec4.x;
			//avatarDirection.y = v.y = vec4.y;
			//avatarDirection.z = v.z = vec4.z;
			//AvatarPosition.z += v.z;
			//AvatarPosition.x += v.x;
		}
		if( ::GetAsyncKeyState('A') & 0x8000f)
		{
			TheCamera.yaw(-4.0f * timeDelta);
			//avatarYaw -= rotationSpeed;
		}
		if( ::GetAsyncKeyState('D') & 0x8000f)
		{
			TheCamera.yaw(4.0f * timeDelta);
			//avatarYaw -= rotationSpeed;
		}
		if( ::GetAsyncKeyState('I') & 0x8000f)
		{
			TheCamera.pitch(-4.0f * timeDelta);
		}
		if( ::GetAsyncKeyState('K') & 0x8000f)
		{
			TheCamera.pitch(4.0f * timeDelta);
		}

		D3DXVECTOR3 f = TheCamera.GetPosition();
		if(f.x > 190)
			f.x = 190;
		if(f.x < -190)
			f.x = -190;
		
		if(f.z > 190)
			f.z = 190;
		if(f.z < -190)
			f.z = -190;

		//if(f.y > 390)
		//	f.y = 390;
		//if(f.y < 10)
		//	f.y = 10;
		float height = TheTerrain->getHeight(f.x, f.z);
		f.y = height + 5.0f;


		TheCamera.setPosition(&f);

		//camera stuff
		D3DXMATRIX V, o;
		TheCamera.getViewMatrix(&V);
		Device->SetTransform(D3DTS_VIEW, &V);

		//UpdateCameraThirdPerson();
		//
		// Draw the scene:
		//
		Device->Clear(0, 0, 
			D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER | D3DCLEAR_STENCIL,
			0xff000000, 1.0f, 0L);

		Device->BeginScene();
				
		D3DXMATRIX I;
		D3DXMatrixIdentity(&I);
		if(TheTerrain)
			TheTerrain->draw(&I, false);

		//Device->SetTexture(0, Armor)
D3DXMATRIX i, tripler, grow;

		Collides();

		DisplayTime();
		DisplayRemaining();

		//
		//Barrels1
		//
		if(BoolTrash[0])
		{
		
		D3DXMatrixTranslation(&tripler, TrashPositions[0].x + 0,TrashPositions[0].y, TrashPositions[0].z-10);
		D3DXMatrixScaling(&grow, .05,.05,.05);
		D3DXMatrixMultiply(&tripler, &grow, &tripler);
		Device->SetTransform(D3DTS_WORLD, &tripler);
		Barrels.Draw(NULL);
		}

		//
		//Barrels2
		//
		if(BoolTrash[1])
		{
		D3DXMatrixTranslation(&tripler, TrashPositions[1].x +0,TrashPositions[1].y,TrashPositions[1].z-10);
		D3DXMatrixScaling(&grow, .05,.05,.05);
		D3DXMatrixMultiply(&tripler, &grow, &tripler);
		Device->SetTransform(D3DTS_WORLD, &tripler);
		Barrels.Draw(NULL);
		}
		//
		//Dalek1
		//
		if(BoolTrash[2])
		{
		D3DXMatrixTranslation(&tripler, TrashPositions[2].x +0,TrashPositions[2].y+8,TrashPositions[2].z-10);
		D3DXMatrixScaling(&grow, .05,.05,.05);
		D3DXMatrixMultiply(&tripler, &grow, &tripler);
		Device->SetTransform(D3DTS_WORLD, &tripler);
		Dalek.Draw(NULL);
		}
		//
		//Dalek2
		//
		if(BoolTrash[3])
		{
		D3DXMatrixTranslation(&tripler,TrashPositions[3].x +0,TrashPositions[3].y+8,TrashPositions[3].z-10);
		D3DXMatrixScaling(&grow, .05,.05,.05);
		D3DXMatrixMultiply(&tripler, &grow, &tripler);
		Device->SetTransform(D3DTS_WORLD, &tripler);
		Dalek.Draw(NULL);
		}
		//
		//Tank1
		//		
		if(BoolTrash[4])
		{
		D3DXMatrixTranslation(&tripler, TrashPositions[4].x +40,TrashPositions[4].y+14,TrashPositions[4].z+0);
		D3DXMatrixScaling(&grow, .1,.1,.1);
		D3DXMatrixMultiply(&tripler, &grow, &tripler);
		Device->SetTransform(D3DTS_WORLD, &tripler);
		tank.Draw(NULL);
		}
		//
		//Tank2
		//
		if(BoolTrash[5])
		{
		D3DXMatrixTranslation(&tripler, TrashPositions[5].x +40,TrashPositions[5].y+14,TrashPositions[5].z+0);
		D3DXMatrixScaling(&grow, .1,.1,.1);
		D3DXMatrixMultiply(&tripler, &grow, &tripler);
		Device->SetTransform(D3DTS_WORLD, &tripler);
		tank.Draw(NULL);
		}

		//
		//Table1
		//		
		if(BoolTrash[6])
		{
		D3DXMatrixTranslation(&tripler, TrashPositions[6].x +0,TrashPositions[6].y,TrashPositions[6].z-10);
		D3DXMatrixScaling(&grow, 10,10,10);
		D3DXMatrixMultiply(&tripler, &grow, &tripler);
		Device->SetTransform(D3DTS_WORLD, &tripler);
		Table.Draw(NULL);
		}
		//
		//Table2
		//
		if(BoolTrash[7])
		{
		D3DXMatrixTranslation(&tripler, TrashPositions[7].x +0,TrashPositions[7].y,TrashPositions[7].z-10);
		D3DXMatrixScaling(&grow,10,10,10);
		D3DXMatrixMultiply(&tripler, &grow, &tripler);
		Device->SetTransform(D3DTS_WORLD, &tripler);
		Table.Draw(NULL);
		}
		//
		//Ton1
		//
		if(BoolTrash[8])
		{
		D3DXMatrixTranslation(&tripler, TrashPositions[8].x +0,TrashPositions[8].y,TrashPositions[8].z-10);
		D3DXMatrixScaling(&grow,10,10,10);
		D3DXMatrixMultiply(&tripler, &grow, &tripler);
		Device->SetTransform(D3DTS_WORLD, &tripler);
		Ton.Draw(NULL);
		}
		//
		//Ton2
		//
		if(BoolTrash[9])
		{
		D3DXMatrixTranslation(&tripler, TrashPositions[9].x +0,TrashPositions[8].y,TrashPositions[9].z-10);
		D3DXMatrixScaling(&grow,10,10,10);
		D3DXMatrixMultiply(&tripler, &grow, &tripler);
		Device->SetTransform(D3DTS_WORLD, &tripler);
		Ton.Draw(NULL);
		}

		for(int i = 0; i < numbertrees; i++)
		{
			D3DXMatrixTranslation(&tripler, TreePositions[i].x +0,TreePositions[i].y,TreePositions[i].z-10);
			D3DXMatrixScaling(&grow,5,5,5);
			D3DXMatrixMultiply(&tripler, &grow, &tripler);
			Device->SetTransform(D3DTS_WORLD, &tripler);
			Tree.Draw(NULL);
		}

		if(messageDone)
		{
		if(allfound)
		{
			sprintf(buffers, "Seconds taken to find all objects: %i", seconds);
			::MessageBoxA(0, buffers, "Congratulations", 0);
			//::PostQuitMessage(0);
			messageDone = false;
		}
		}

		renderSkybox(Device, TheCamera);
		DrawMinimap();

		Device->EndScene();
		Device->Present(0, 0, 0, 0);
	}

	if(GetTickCount() - dwFinalTick > 1000)
	{
		seconds = seconds + 1;
		dwInitialTick = dwFinalTick;
		dwFinalTick = GetTickCount();

		countDown = countDown+ 1;
	}
	return true;
}
void Animate(void)
{

	// limpa a janela
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	// Reset the matrix
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	if (!arcCam){
		//MOVIMENTO E ROTAÇÃO DA CAMARA COM TECLADO E RATO
		// Move the camera to our location in space
		glRotatef(cam->getXRot(), 1.0f, 0.0f, 0.0f); // Rotate our camera on the x-axis (looking up and down)
		glRotatef(cam->getYRot(), 0.0f, 1.0f, 0.0f); // Rotate our camera on the  y-axis (looking left and right)
		// Translate the ModelView matrix to the position of our camera - everything should now be drawn relative
		// to this position!
		glTranslatef(-cam->getXPos(), -cam->getYPos(), -cam->getZPos());
	}
	else{
		//Camara orbital
		arcCamX = arcCamRadius * sin(arcCamAngle);
		arcCamZ = arcCamRadius * cos(arcCamAngle);
		gluLookAt(arcCamX, 30, arcCamZ, 0, 0, 0, 0, 1, 0);
		arcCamAngle += 0.01;
		if (arcCamAngle > 2 * PI){
			arcCamAngle = 0;
		}
	}


	if (spinMode) {

		//Controla a velocidade da simulação
		if (holdingMoreSimulationSpeed && simulationSpeed > 15){
			simulationSpeed -= simulationSpeedChangeAcceleration;
			simulationSpeedChangeAcceleration += 0.1;
		}
		if (holdingLessSimulationSpeed){
			simulationSpeed += simulationSpeedChangeAcceleration;
			simulationSpeedChangeAcceleration += 0.1;
			if (simulationSpeed > 5000){
				spinMode = false;
				simulationSpeed = 5000;
			}
		}

		//Atualiza a posição dos planetas e luas
		UpdatePlanetas();
		UpdateLuas();

	}

	applyLights();

	glViewport(0, 0, width, height);
	ResizeWindow(width, height);

	glEnable(GL_TEXTURE_2D);

	//Desenha os planetas e luas
	DrawPlanetas(false);
	DrawLuas();

	//Desenhar displayLists de estrelas
	glCallList(displayListIndex);

	glPushMatrix();

	//Mover oara posição da camara
	if (!arcCam){
		glTranslatef(cam->getXPos(), 0, cam->getZPos());
	}
	else{
		glTranslatef(arcCamX, arcCamY, arcCamZ);
	}

	//Desenhar a skybox na posição da camara - a skybox acompanha o movimento da camara
	DrawSkybox();

	glPopMatrix();

	//Desenhar anéis de saturno
	DrawRings();

	//Desenhar minimap
	DrawMinimap();

	glfwSwapBuffers(); // Swap the buffers to display the scene (so we don't have to watch it being drawn!)

}