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


C++ SmartPtr::GetCamera方法代码示例

本文整理汇总了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;
}
开发者ID:kovacik,项目名称:DeepZoom,代码行数:24,代码来源:CameraMoveTool.cpp

示例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;
}
开发者ID:kovacik,项目名称:DeepZoom,代码行数:85,代码来源:RenderableImage.cpp


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