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


C++ CFirstPersonCamera::GetWorldRight方法代码示例

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


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

示例1: renderSprites

// Render the given sprites. They must already be sorted into back-to-front order.
void SpriteRenderer::renderSprites(ID3D11DeviceContext* context, const std::vector<SpriteVertex>& sprites, const CFirstPersonCamera& camera) {

	HRESULT hr;

	if (sprites.size() > 1) {
		std::cout;
	}

	D3D11_BOX box;
	box.left = 0; box.right = sprites.size() * sizeof(SpriteVertex);
	box.top = 0; box.bottom = 1; box.front = 0; box.back = 1;
	context->UpdateSubresource(m_pVertexBuffer, 0, &box, sprites.data(), 0, 0);

	// Bind the vertex buffer to the input assembler stage 
	unsigned int strides[] = { sizeof(SpriteVertex), }, offsets[] = { 0, };
	context->IASetVertexBuffers(0, 1, &m_pVertexBuffer, strides, offsets);
	// Set the Input Layout
	context->IASetInputLayout(m_pInputLayout);
	context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_POINTLIST);

	// Load variables to shader
	SAFE_GET_MATRIX(m_pEffect, "g_ViewProjection", g_ViewProjection);
	SAFE_GET_VECTOR(m_pEffect, "g_CamRVec", camRightVec);
	SAFE_GET_VECTOR(m_pEffect, "g_CamUVec", camUpVec);
	SAFE_GET_RESOURCE(m_pEffect, "g_SprTexGatling", sprTexGatling);
	SAFE_GET_RESOURCE(m_pEffect, "g_SprTexPlasma", sprTexPlasma);
	SAFE_GET_RESOURCE(m_pEffect, "g_SprTexBoom", sprTexBoom);

	// Set view and projection transformations to get sprites to the right positions in world space
	DirectX::XMMATRIX viewProj = camera.GetViewMatrix() * camera.GetProjMatrix();
	V(g_ViewProjection->SetMatrix((float*)&viewProj));
	
	// Set Textures
	V(sprTexGatling->SetResource(m_spriteSRV[0]));
	V(sprTexPlasma->SetResource(m_spriteSRV[1]));
	V(sprTexBoom->SetResource(m_spriteSRV[2]));
	
	// Get camera's right and up vector
	V(camRightVec->SetFloatVector((float*)&camera.GetWorldRight()));
	V(camUpVec->SetFloatVector((float*)&camera.GetWorldUp()));

	// Apply the pass from the effect
	V(m_pEffect->GetTechniqueByName("sRender")->GetPassByName("P0")->Apply(0, context));

	// Draw
	context->Draw(sprites.size(), 0);
}
开发者ID:SS2015TUMGED,项目名称:GED,代码行数:48,代码来源:SpriteRenderer.cpp


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