Example #1
0
void CGameFramework::BuildObjects()
{
	m_pScene = new CScene();

	//플레이어 객체를 생성한다.
	m_pPlayer = new CPlayer();

	//카메라 객체를 생성하고 뷰-포트를 설정한다. 
	CCamera *pCamera = new CCamera();
	pCamera->CreateShaderVariables(m_pd3dDevice);
	pCamera->SetViewport(m_pd3dDeviceContext, 0, 0, m_nWndClientWidth, m_nWndClientHeight, 0.0f, 1.0f);
	//투영 변환 행렬을 생성한다. 
	pCamera->GenerateProjectionMatrix(1.0f, 500.0f, float(m_nWndClientWidth) / float(m_nWndClientHeight), 90.0f);
	//카메라 변환 행렬을 생성한다. 
	D3DXVECTOR3 d3dxvEyePosition = D3DXVECTOR3(150.0f, 150.0f, -250.0f);
	D3DXVECTOR3 d3dxvLookAt = D3DXVECTOR3(0.0f, 0.0f, 0.0f);
	D3DXVECTOR3 d3dxvUp = D3DXVECTOR3(0.0f, 1.0f, 0.0f);
	pCamera->GenerateViewMatrix(d3dxvEyePosition, d3dxvLookAt, d3dxvUp);
	//카메라 객체를 플레이어 객체에 설정한다. 
	m_pScene->SetCamera(pCamera);
	m_pPlayer->SetCamera(pCamera);
	m_pPlayer->CreateShaderVariables(m_pd3dDevice);

	if (m_pScene) m_pScene->BuildObjects(m_pd3dDevice);

	D3DXCOLOR d3dxcColor(1.0f, 0.0f, 0.0f, 1.0f);
	D3D11_BUFFER_DESC bd;
	ZeroMemory(&bd, sizeof(bd));
	bd.Usage = D3D11_USAGE_DYNAMIC;
	bd.ByteWidth = sizeof(D3DXCOLOR);
	bd.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
	bd.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
	D3D11_SUBRESOURCE_DATA d3dSubResource;
	d3dSubResource.pSysMem = &d3dxcColor;
	d3dSubResource.SysMemPitch = 0;
	d3dSubResource.SysMemSlicePitch = 0;
	m_pd3dDevice->CreateBuffer(&bd, &d3dSubResource, &m_pd3dcbColor);
	m_pd3dDeviceContext->PSSetConstantBuffers(PS_SLOT_COLOR, 1, &m_pd3dcbColor);

}
void CGameFramework::BuildObjects()
{
	m_pScene = new CScene();

	//플레이어 객체를 생성한다.
	m_pPlayer = new CPlayer();

	//카메라 객체를 생성하고 뷰-포트를 설정한다. 
	CCamera *pCamera = new CCamera();
	pCamera->CreateShaderVariables(m_pd3dDevice);
	pCamera->SetViewport(m_pd3dDeviceContext, 0, 0, m_nWndClientWidth, m_nWndClientHeight, 0.0f, 1.0f);
	//투영 변환 행렬을 생성한다. 
	pCamera->GenerateProjectionMatrix(1.0f, 500.0f, float(m_nWndClientWidth) / float(m_nWndClientHeight), 90.0f);
	//카메라 변환 행렬을 생성한다. 
	D3DXVECTOR3 d3dxvEyePosition = D3DXVECTOR3(0.0f, 0.0f, -55.0f);
	D3DXVECTOR3 d3dxvLookAt = D3DXVECTOR3(0.0f, 0.0f, 0.0f);
	D3DXVECTOR3 d3dxvUp = D3DXVECTOR3(0.0f, 1.0f, 0.0f);
	pCamera->GenerateViewMatrix(d3dxvEyePosition, d3dxvLookAt, d3dxvUp);
	//카메라 객체를 플레이어 객체에 설정한다. 
	m_pPlayer->SetCamera(pCamera);
	m_pPlayer->CreateShaderVariables(m_pd3dDevice);

	if (m_pScene) m_pScene->BuildObjects(m_pd3dDevice);
}