예제 #1
0
void DirectxEngine::Render(const IScene& scene, float timer)
{
    RenderSceneMap(scene, timer);
    RenderPreEffects(scene.Post());
    RenderBlur(scene.Post());
    RenderPostProcessing(scene.Post());
    m_data->swapchain->Present(0, 0);
}
예제 #2
0
void GameScene::DrawScene(const tt::GameContext& context)
{
	auto pGfxService = MyServiceLocator::GetInstance()->GetService<IGraphicsService>();
	
	pGfxService->PrepareShadowGeneration();
	for(auto pObj : m_Objects)
		pObj->GenerateShadows(context);
	
	pGfxService->GetGraphicsDevice()->ResetRenderTarget();
	
	pGfxService->PrepareDeferredShading();
	
	for(auto pObj : m_Objects){
		pObj->Draw(context);
		//pObj->DrawObject(context);
	}
	
	pGfxService->CompositeDeferredShading(context);
	
	//Render FPS
	m_pDefaultFont->DrawText(std::tstring(_T("FPS: ")) + to_tstring(context.FramesPerSecond) + _T("\nSPF: ") + to_tstring(context.GameTimer.GetElapsedSeconds() ), 
							tt::Vector2(5,0), 
							tt::Vector4(1,1,0,1) );
		
	pGfxService->GetSpriteBatch()->Flush(context);

	auto particlesSprite = ParticleEmitterComponent::RenderDeferred(context);
	//pGfxService->GetSpriteBatch()->Draw(particlesSprite);
	//pGfxService->GetSpriteBatch()->Flush(context);
	
	if(!m_PostProEffects.empty() ){
		auto postProSprite = pGfxService->RenderPostProcessing(context, m_PostProEffects);

		pGfxService->GetSpriteBatch()->Draw(postProSprite);
		pGfxService->GetSpriteBatch()->Flush(context);
	}
}
예제 #3
0
bool GraphicsManager::Frame(Camera* cam, Input* input, int fps, int cpumanager, float frameTime, int mouseX, int mouseY)
{
	bool result, collision = false;
	bool keydown;
	m_Camera = cam;


	// Perform collision detection logic.  This is very hacky and an example of bad code design.
	m_MouseX = mouseX;
	m_MouseY = mouseY;
	// Do object frame processing.

	//float height = m_ObjectTerrain->GetTerrain()->GetHeightAtPosition(cam->GetPosition().x, cam->GetPosition().z);



	if( cam->GetPosition().y > 50.0f)
	{
		cam->SetPosition( cam->GetPosition().x, 50.0f, cam->GetPosition().z) ;
	}
	
	if (input->IsLeftMousePressed() == true)
	{
		for (std::vector<Object*>::iterator iter = m_collidables.begin(); iter != m_collidables.end(); ++iter)
		{
			collision = TestPickingCollision(mouseX, mouseY, *iter);
			if (collision==true)
			{
				Object * Sphere = *iter;
				//sphere->SetPosition(D3DXVECTOR3(cam->GetPosition().x, cam->GetPosition().y, cam->GetPosition().z + 5.0f));
				ObjectExplosionParticle * Explosion = new ObjectExplosionParticle(m_D3D);
				Explosion->SetPosition(Sphere->GetPosition());

				m_ExplosionParticles.push_back(Explosion);
				m_collidables.erase(iter);
				break;
			}

		}
	}

	if (input->IsRightMousePressed() == true)
	{
		for (std::vector<Object*>::iterator iter = m_collidables.begin(); iter != m_collidables.end(); ++iter)
		{
			collision = TestPickingCollision(mouseX, mouseY, *iter);
			if (collision==true)
			{
				Object * Sphere = *iter;
				//sphere->SetPosition(D3DXVECTOR3(cam->GetPosition().x, cam->GetPosition().y, cam->GetPosition().z + 5.0f));
				ObjectFireParticle * Fire = new ObjectFireParticle(m_D3D);
				Fire->SetPosition(Sphere->GetPosition());

				m_FireParticles.push_back(Fire);
				m_collidables.erase(iter);
				break;
			}
		}
	}
	keydown = input->IsRightMousePressed();
	if (keydown&&(!m_collisionCheck))
	{
		convolutionCheck++;
		m_collisionCheck = true;
		if (convolutionCheck == 1)
		{
			m_convolutionRow1 = D3DXVECTOR4(0.0f, -1.0f, 0.0f, 0.0f);
			m_convolutionRow2 = D3DXVECTOR4(-1.0f, 5.0f, -1.0f, 0.0f);
			m_convolutionRow3 = D3DXVECTOR4(0.0f, -1.0f, 0.0f, 0.0f);
		}
		else if (convolutionCheck == 2)
		{
			m_convolutionRow1 = D3DXVECTOR4(0.0f, 0.0f, 0.0f, 0.0f);
			m_convolutionRow2 = D3DXVECTOR4(-1.0f, 1.0f, 0.0f, 0.0f);
			m_convolutionRow3 = D3DXVECTOR4(0.0f, 0.0f, 0.0f, 0.0f);
		}
		else if (convolutionCheck == 3)
		{
			m_convolutionRow1 = D3DXVECTOR4(0.0f, 1.0f, 0.0f, 0.0f);
			m_convolutionRow2 = D3DXVECTOR4(1.0f, -4.0f, 1.0f, 0.0f);
			m_convolutionRow3 = D3DXVECTOR4(0.0f, 1.0f, 0.0f, 0.0f);
		}
		else if (convolutionCheck == 4)
		{
			m_convolutionRow1 = D3DXVECTOR4(-2.0f, -1.0f, 0.0f, 0.0f);
			m_convolutionRow2 = D3DXVECTOR4(-1.0f, 1.0f, 1.0f, 0.0f);
			m_convolutionRow3 = D3DXVECTOR4(0.0f, 1.0f, 2.0f, 0.0f);
		}
		else if (convolutionCheck > 4)
		{
			convolutionCheck = 1;
		}		
	}
	else 
	{
		m_collisionCheck = false;
	}

	// Perform object frame processing.
	m_ObjectText1->Frame(m_D3D, fps, cpumanager, mouseX, mouseY, collision);
	m_ObjectClouds->Frame();
	m_ObjectWater->Frame();

	//m_ObjectExplosionParticle->Frame(m_D3D, frameTime);

	for (std::vector<ObjectExplosionParticle*>::iterator iter = m_ExplosionParticles.begin(); iter != m_ExplosionParticles.end(); ++iter)
	{
		ObjectExplosionParticle * Explosion = *iter;
		Explosion->Frame(m_D3D, frameTime);
	}

	for (std::vector<ObjectFireParticle*>::iterator iter = m_FireParticles.begin(); iter != m_FireParticles.end(); ++iter)
	{
		ObjectFireParticle * Fire = *iter;
		Fire->Frame(m_D3D, frameTime);
	}

	m_frameTime = frameTime;

	// Render the scene with post processing
	result = RenderPostProcessing(cam);
	if(!result)
	{
		return false;
	}

	// Render the scene with no post processing
	//result = RenderPreProcessing(cam);
	//if(!result)
	//{
	//	return false;
	//}

	return true;
}