本文整理汇总了C++中SmartPtr::GetCamera方法的典型用法代码示例。如果您正苦于以下问题:C++ SmartPtr::GetCamera方法的具体用法?C++ SmartPtr::GetCamera怎么用?C++ SmartPtr::GetCamera使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SmartPtr
的用法示例。
在下文中一共展示了SmartPtr::GetCamera方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetCameraFromViewController
HRESULT CameraMoveTool::GetCameraFromViewController(__in IViewController *pView, __deref_out_opt ISceneObjectCamera **ppCamera)
{
HRESULT hr;
SmartPtr<IViewControllerScene> spViewSceneController;
hr = pView->QueryInterface(&spViewSceneController);
if (SUCCEEDED(hr))
{
SmartPtr<IRenderer> spRenderer;
hr = spViewSceneController->GetRenderer(&spRenderer);
if (SUCCEEDED(hr))
{
SmartPtr<ISceneObjectCamera> spCamera;
hr = spRenderer->GetCamera(&spCamera);
if (SUCCEEDED(hr))
{
hr = spCamera.CopyToOpt(ppCamera);
}
}
}
return hr;
}
示例2: Draw
HRESULT RenderableImage::Draw(UINT passIndex, __in IRendererHandler *pRenderer)
{
UNREFERENCED_PARAMETER(passIndex);
HRESULT hr;
// Get suitable renderer
SmartPtr<IRenderer> spRenderer;
hr = pRenderer->QueryInterface(&spRenderer);
IF_FAILED_RETURN(hr);
// Calibrate
//
SmartPtr<ICalibrable> spCalibrable = m_spSceneObject.CastTo<ICalibrable>();
if (spCalibrable && !spCalibrable->IsCalibrated())
{
XMMATRIX viewMatrix, projectionMatrix;
SmartPtr<ISceneObjectCamera> spCamera;
hr = spRenderer->GetCamera(&spCamera);
IF_FAILED_RETURN(hr);
hr = CalibrateCamera(spCamera);
IF_FAILED_RETURN(hr);
spCalibrable->SetCalibrated();
}
SmartPtr<IRendererHandler> spRendererHandler(pRenderer);
XMMATRIX viewMatrix, projectionMatrix;
hr = spRendererHandler->GetCameraMatrices(&viewMatrix, &projectionMatrix);
IF_FAILED_RETURN(hr);
// Get object world transform
XMMATRIX worldMatrix = m_spSceneObject->GetWorldTransform();
UINT screenWidth = 0, screenHeight = 0;
spRenderer->GetWindowWidthAndHeight(screenWidth, screenHeight);
SmartPtr<ISceneObjectCamera> spCamera;
hr = spRenderer->GetCamera(&spCamera);
IF_FAILED_RETURN(hr);
UINT level = 0;
hr = DetermineLevelFromCamera(spCamera, (FLOAT)screenWidth, (FLOAT)screenHeight, level);
IF_FAILED_RETURN(hr);
// Get suitable shader
SmartPtr<IShader> spShader;
hr = pRenderer->GetShaderInterface(__uuidof(ITextureShader), &spShader);
IF_FAILED_RETURN(hr);
for (UINT i = 0; i < m_LevelTiles[level].Length(); ++i)
{
if (m_LevelTiles[level][i]->IsVisible(viewMatrix, projectionMatrix, worldMatrix, (FLOAT)screenWidth, (FLOAT)screenHeight))
{
SmartPtr<ID3D11ShaderResourceView> spTexture;
hr = m_LevelTiles[level][i]->LockTexture(&spTexture);
IF_FAILED_RETURN(hr);
// Fill shader constants with transformation matrices
hr = spShader.CastTo<ITextureShader>()->SetShaderParametersAndTexture(worldMatrix, viewMatrix, projectionMatrix, spTexture);
IF_FAILED_RETURN(hr);
spShader->SetVertextAndPixelShader();
D3D_PRIMITIVE_TOPOLOGY primitiveTopology;
UINT vertexCount = 0, indexCount = 0;
SmartPtr<ID3D11Buffer> spVertexBuffer, spIndexBuffer;
hr = m_LevelTiles[level][i]->GetBuffersAndPrimitiveTopology(&spVertexBuffer, vertexCount, &spIndexBuffer, indexCount, primitiveTopology);
IF_FAILED_RETURN(hr);
ID3D11Buffer* vertexBuffer = spVertexBuffer;
pRenderer->DrawIndexedPrimitive(&vertexBuffer, sizeof(TexturedVertexType), spIndexBuffer, DXGI_FORMAT_R32_UINT,
indexCount, primitiveTopology);
}
else
{
m_LevelTiles[level][i]->ReleaseTexture();
}
}
return hr;
}