当前位置: 首页>>代码示例>>C++>>正文


C++ CCamera::GenerateViewMatrix方法代码示例

本文整理汇总了C++中CCamera::GenerateViewMatrix方法的典型用法代码示例。如果您正苦于以下问题:C++ CCamera::GenerateViewMatrix方法的具体用法?C++ CCamera::GenerateViewMatrix怎么用?C++ CCamera::GenerateViewMatrix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CCamera的用法示例。


在下文中一共展示了CCamera::GenerateViewMatrix方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: BuildObjects

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);

}
开发者ID:Jungmu,项目名称:Direct_stusy,代码行数:40,代码来源:GameFramework.cpp

示例2: BuildObjects

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);
}
开发者ID:ricky626,项目名称:3D-Programming,代码行数:24,代码来源:GameFramework.cpp


注:本文中的CCamera::GenerateViewMatrix方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。