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


C++ CModelViewerCamera::GetProjMatrix方法代码示例

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


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

示例1: OnFrameRender

//--------------------------------------------------------------------------------------
// This callback function will be called at the end of every frame to perform all the 
// rendering calls for the scene, and it will also be called if the window needs to be 
// repainted. After this function has returned, DXUT will call 
// IDirect3DDevice9::Present to display the contents of the next buffer in the swap chain
//--------------------------------------------------------------------------------------
void CALLBACK OnFrameRender( IDirect3DDevice9* pd3dDevice, double fTime, float fElapsedTime, void* pUserContext )
{
    // If the settings dialog is being shown, then
    // render it instead of rendering the app's scene
    if( g_SettingsDlg.IsActive() )
    {
        g_SettingsDlg.OnRender( fElapsedTime );
        return;
    }

    HRESULT hr;

    // Clear the render target and the zbuffer 
    V( pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_ARGB( 0, 50, 50, 50 ), 1.0f, 0 ) );

    // Render the scene
    if( SUCCEEDED( pd3dDevice->BeginScene() ) )
    {
        // Get the projection & view matrix from the camera class
        D3DXMATRIXA16 mViewProjection = ( *g_Camera.GetViewMatrix() ) * ( *g_Camera.GetProjMatrix() );

        g_Skybox.SetDrawSH( false );
        g_Skybox.Render( &mViewProjection, 1.0f, 1.0f );

        V( g_pEffect->SetMatrix( "g_mViewProjection", &mViewProjection ) );
        V( g_pEffect->SetFloat( "g_fTime", ( float )fTime ) );

        // Set the amount of transmitted light per color channel
        D3DXVECTOR3 vColorTransmit;
        vColorTransmit.x = g_SampleUI.GetSlider( IDC_RED_TRANSMIT_SLIDER )->GetValue() / 1000.0f;
        vColorTransmit.y = g_SampleUI.GetSlider( IDC_GREEN_TRANSMIT_SLIDER )->GetValue() / 1000.0f;
        vColorTransmit.z = g_SampleUI.GetSlider( IDC_BLUE_TRANSMIT_SLIDER )->GetValue() / 1000.0f;
        V( g_pEffect->SetFloatArray( "g_vColorTransmit", vColorTransmit, 3 ) );

        // for Cubic degree rendering
        V( g_pEffect->SetFloat( "g_fLightIntensity", g_fLightIntensity ) );
        V( g_pEffect->SetFloatArray( "g_vLightDirection", g_vLightDirection, 3 * sizeof( float ) ) );
        V( g_pEffect->SetFloatArray( "g_vLightCoeffsR", m_fRLC, 4 * sizeof( float ) ) );
        V( g_pEffect->SetFloatArray( "g_vLightCoeffsG", m_fGLC, 4 * sizeof( float ) ) );
        V( g_pEffect->SetFloatArray( "g_vLightCoeffsB", m_fBLC, 4 * sizeof( float ) ) );

        pd3dDevice->SetRenderState( D3DRS_FILLMODE, g_bWireFrame ? D3DFILL_WIREFRAME : D3DFILL_SOLID );

        DrawFrame( pd3dDevice, g_pFrameRoot );

        DXUT_BeginPerfEvent( DXUT_PERFEVENTCOLOR, L"HUD / Stats" ); // These events are to help PIX identify what the code is doing
        RenderText();
        V( g_HUD.OnRender( fElapsedTime ) );
        V( g_SampleUI.OnRender( fElapsedTime ) );
        V( g_LightControl.OnRender9( D3DXCOLOR( 1, 1, 1, 1 ), ( D3DXMATRIX* )g_Camera.GetViewMatrix(),
                                     ( D3DXMATRIX* )g_Camera.GetProjMatrix(), g_Camera.GetEyePt() ) );
        DXUT_EndPerfEvent();

        V( pd3dDevice->EndScene() );
    }
}
开发者ID:KNeal,项目名称:Oculus,代码行数:62,代码来源:LocalDeformablePRT.cpp

示例2: XMMatrixTranspose

//--------------------------------------------------------------------------------------
// Render the scene using the D3D11 device
//--------------------------------------------------------------------------------------
void CALLBACK OnD3D11FrameRender( ID3D11Device* pd3dDevice, ID3D11DeviceContext* pd3dImmediateContext,
                                  double fTime, float fElapsedTime, void* pUserContext )
{
	pd3dImmediateContext->ClearRenderTargetView(DXUTGetD3D11RenderTargetView(), Colors::MidnightBlue);
	pd3dImmediateContext->ClearDepthStencilView(DXUTGetD3D11DepthStencilView(), D3D11_CLEAR_DEPTH, 1.0, 0);
	
	XMMATRIX mview = g_camera.GetViewMatrix();
	XMMATRIX mproj = g_camera.GetProjMatrix();
	XMFLOAT4 LitDir = XMFLOAT4(-0.577f, 0.577f, -0.577f, 1.0f);
	XMFLOAT4 LitCol = XMFLOAT4(0.9f, 0.2f, 0.3f, 1.0f);

	/*
		SHADER CONSTANT BUFFER
	*/
	ConstantBuffer cb;
	XMStoreFloat4x4(&(cb.world), XMMatrixTranspose(g_mesh.World()));
	XMStoreFloat4x4(&(cb.view), XMMatrixTranspose(mview));
	XMStoreFloat4x4(&(cb.projection), XMMatrixTranspose(mproj));
	cb.litDir = LitDir;
	cb.litCol = LitCol;

	g_shader->RenderPrepare(&cb);

	g_mesh.Render();
}
开发者ID:contacoonta,项目名称:sgap-direct3d,代码行数:28,代码来源:DXUTMain.cpp

示例3: OnFrameRender

//--------------------------------------------------------------------------------------
// This callback function will be called at the end of every frame to perform all the 
// rendering calls for the scene, and it will also be called if the window needs to be 
// repainted. After this function has returned, DXUT will call 
// IDirect3DDevice9::Present to display the contents of the next buffer in the swap chain
//--------------------------------------------------------------------------------------
void CALLBACK OnFrameRender( IDirect3DDevice9* pd3dDevice, double fTime, float fElapsedTime, void* pUserContext )
{
    // If the settings dialog is being shown, then
    // render it instead of rendering the app's scene
    if( g_SettingsDlg.IsActive() )
    {
        g_SettingsDlg.OnRender( fElapsedTime );
        return;
    }

    HRESULT hr;
    D3DXMATRIXA16 mWorld;
    D3DXMATRIXA16 mView;
    D3DXMATRIXA16 mProj;
    D3DXMATRIXA16 mWorldViewProjection;


    // Clear the render target and the zbuffer 
    V( pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_ARGB( 0, 141, 153, 191 ), 1.0f, 0 ) );

    // Render the scene
    if( SUCCEEDED( pd3dDevice->BeginScene() ) )
    {
        // Get the projection & view matrix from the camera class
        mWorld = *g_Camera.GetWorldMatrix();
        mView = *g_Camera.GetViewMatrix();
        mProj = *g_Camera.GetProjMatrix();

        mWorldViewProjection = mWorld * mView * mProj;

        // Update the effect's variables. 
        V( g_pEffect->SetMatrix( g_hWorldViewProjection, &mWorldViewProjection ) );
        V( g_pEffect->SetMatrix( g_hWorld, &mWorld ) );
        V( g_pEffect->SetFloat( g_hTime, ( float )fTime ) );
        V( g_pEffect->SetValue( g_hCameraPosition, g_Camera.GetEyePt(), sizeof( D3DXVECTOR3 ) ) );

        UINT iCurSubset = ( UINT )( INT_PTR )g_SampleUI.GetComboBox( IDC_SUBSET )->GetSelectedData();

        // A subset of -1 was arbitrarily chosen to represent all subsets
        if( iCurSubset == -1 )
        {
            // Iterate through subsets, changing material properties for each
            for( UINT iSubset = 0; iSubset < g_MeshLoader.GetNumMaterials(); iSubset++ )
            {
                RenderSubset( iSubset );
            }
        }
        else
        {
            RenderSubset( iCurSubset );
        }

        RenderText();
        V( g_HUD.OnRender( fElapsedTime ) );
        V( g_SampleUI.OnRender( fElapsedTime ) );

        V( pd3dDevice->EndScene() );
    }
}
开发者ID:KNeal,项目名称:Oculus,代码行数:65,代码来源:MeshFromObj.cpp

示例4: OnFrameRender

//--------------------------------------------------------------------------------------
// Render the scene using the D3D9 device
//--------------------------------------------------------------------------------------
void CALLBACK OnFrameRender( IDirect3DDevice9* pd3dDevice, double fTime, float fElapsedTime, void* pUserContext )
{
    if( g_SettingsDlg.IsActive() )
    {
        g_SettingsDlg.OnRender( fElapsedTime );
        return;
    }

    HRESULT hr;
    D3DXMATRIXA16 mWorld;
    D3DXMATRIXA16 mView;
    D3DXMATRIXA16 mProj;
    D3DXMATRIXA16 mWorldViewProjection;

    // Clear the render target and the zbuffer 
    V( pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_ARGB( 0, 45, 50, 170 ), 1.0f, 0 ) );

    // Render the scene
    if( SUCCEEDED( pd3dDevice->BeginScene() ) )
    {
        // Get the projection & view matrix from the camera class
        mWorld = *g_Camera.GetWorldMatrix();
        mProj = *g_Camera.GetProjMatrix();
        mView = g_mView;

        mWorldViewProjection = mWorld * mView * mProj;

        // Update the effect's variables.  Instead of using strings, it would 
        // be more efficient to cache a handle to the parameter by calling 
        // ID3DXEffect::GetParameterByName
        V( g_pEffect->SetMatrix( "g_mWorldViewProjection", &mWorldViewProjection ) );
        V( g_pEffect->SetMatrix( "g_mWorld", &mWorld ) );
        V( g_pEffect->SetFloat( "g_fTime", ( float )fTime ) );

        g_pEffect->SetTechnique( "RenderScene" );
        UINT cPasses;
        g_pEffect->Begin( &cPasses, 0 );
        ID3DXMesh* pMesh = g_Mesh.GetMesh();
        for( UINT p = 0; p < cPasses; ++p )
        {
            g_pEffect->BeginPass( p );
            for( UINT m = 0; m < g_Mesh.m_dwNumMaterials; ++m )
            {
                g_pEffect->SetTexture( "g_txScene", g_Mesh.m_pTextures[m] );
                g_pEffect->CommitChanges();
                pMesh->DrawSubset( m );
            }
            g_pEffect->EndPass();
        }
        g_pEffect->End();

        RenderText();
        V( g_HUD.OnRender( fElapsedTime ) );
        V( g_SampleUI.OnRender( fElapsedTime ) );

        V( pd3dDevice->EndScene() );
    }
}
开发者ID:KNeal,项目名称:Oculus,代码行数:61,代码来源:CustomUI.cpp

示例5: lightDir

//--------------------------------------------------------------------------------------
// Render the scene using the D3D10 device
//--------------------------------------------------------------------------------------
void CALLBACK OnD3D10FrameRender( ID3D10Device* pd3dDevice, double fTime, float fElapsedTime, void* pUserContext )
{
    // Clear the render target
    float ClearColor[4] = { 0.9569f, 0.9569f, 1.0f, 0.0f };
    ID3D10RenderTargetView* pRTV = DXUTGetD3D10RenderTargetView();
    pd3dDevice->ClearRenderTargetView( pRTV, ClearColor );
    ID3D10DepthStencilView* pDSV = DXUTGetD3D10DepthStencilView();
    pd3dDevice->ClearDepthStencilView( pDSV, D3D10_CLEAR_DEPTH, 1.0, 0 );

    // Render the result
    D3DXMATRIX mWorld;
    D3DXMATRIX mView;
    D3DXMATRIX mProj;
    D3DXMATRIX mWorldView;
    D3DXMATRIX mWorldViewProj;
    mWorld = *g_Camera.GetWorldMatrix();
    mProj = *g_Camera.GetProjMatrix();
    mView = *g_Camera.GetViewMatrix();
    mWorldView = mWorld * mView;
    mWorldViewProj = mWorldView * mProj;

    // Set variables
    g_pmWorldViewProj->SetMatrix( ( float* )&mWorldViewProj );
    g_pmWorldView->SetMatrix( ( float* )&mWorldView );
    g_pmWorld->SetMatrix( ( float* )&mWorld );
    g_pmView->SetMatrix( ( float* )&mView );
    g_pmProj->SetMatrix( ( float* )&mProj );
    g_pDiffuseTex->SetResource( g_pMeshTexRV );
    D3DXVECTOR3 lightDir( -1,1,-1 );
    D3DXVECTOR3 viewLightDir;
    D3DXVec3TransformNormal( &viewLightDir, &lightDir, &mView );
    D3DXVec3Normalize( &viewLightDir, &viewLightDir );
    g_pViewSpaceLightDir->SetFloatVector( ( float* )&viewLightDir );

    // Set Input Assembler params
    UINT stride = g_VertStride;
    UINT offset = 0;
    pd3dDevice->IASetInputLayout( g_pVertexLayout );
    pd3dDevice->IASetPrimitiveTopology( D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST );
    pd3dDevice->IASetIndexBuffer( g_pIB, DXGI_FORMAT_R32_UINT, 0 );
    pd3dDevice->IASetVertexBuffers( 0, 1, &g_pVB, &stride, &offset );

    // Render using the technique g_pRenderTextured
    D3D10_TECHNIQUE_DESC techDesc;
    g_pRenderTextured->GetDesc( &techDesc );
    for( UINT p = 0; p < techDesc.Passes; p++ )
    {
        g_pRenderTextured->GetPassByIndex( p )->Apply( 0 );
        pd3dDevice->DrawIndexed( g_NumIndices, 0, 0 );
    }
}
开发者ID:KNeal,项目名称:Oculus,代码行数:54,代码来源:Exercise04.cpp

示例6: DrawTriangle

// Draw a simple triangle using custom shaders (g_pEffect)
void DrawTriangle(ID3D11DeviceContext* pd3dImmediateContext)
{
	XMMATRIX world = g_camera.GetWorldMatrix();
	XMMATRIX view  = g_camera.GetViewMatrix();
	XMMATRIX proj  = g_camera.GetProjMatrix();
	XMFLOAT4X4 mViewProj;
	XMStoreFloat4x4(&mViewProj, world * view * proj);
	g_pEffect->GetVariableByName("g_worldViewProj")->AsMatrix()->SetMatrix((float*)mViewProj.m);
	g_pEffect->GetTechniqueByIndex(0)->GetPassByIndex(0)->Apply(0, pd3dImmediateContext);
    
	pd3dImmediateContext->IASetVertexBuffers(0, 0, nullptr, nullptr, nullptr);
	pd3dImmediateContext->IASetIndexBuffer(nullptr, DXGI_FORMAT_R16_UINT, 0);
	pd3dImmediateContext->IASetInputLayout(nullptr);
	pd3dImmediateContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
	pd3dImmediateContext->Draw(3, 0);
}
开发者ID:thatPowderGuy,项目名称:GP_Exercises,代码行数:17,代码来源:main.cpp

示例7: RenderObjects

//--------------------------------------------------------------------------------------
// Render the scene using the D3D11 device
//--------------------------------------------------------------------------------------
void CALLBACK OnD3D11FrameRender( ID3D11Device* pd3dDevice, ID3D11DeviceContext* pd3dImmediateContext, double fTime,
                                 float fElapsedTime, void* pUserContext )
{
    // If the settings dialog is being shown, then render it instead of rendering the app's scene
    if( g_SettingsDlg.IsActive() )
    {
        g_SettingsDlg.OnRender( fElapsedTime );
        return;
    }       

    auto pRTV = DXUTGetD3D11RenderTargetView();
    pd3dImmediateContext->ClearRenderTargetView( pRTV, Colors::MidnightBlue );

    // Clear the depth stencil
    auto pDSV = DXUTGetD3D11DepthStencilView();
    pd3dImmediateContext->ClearDepthStencilView( pDSV, D3D11_CLEAR_DEPTH, 1.0, 0 );

    // Get the projection & view matrix from the camera class
    XMMATRIX mWorld = g_Camera.GetWorldMatrix();
    XMMATRIX mView = g_Camera.GetViewMatrix();
    XMMATRIX mProj = g_Camera.GetProjMatrix();

    g_BatchEffect->SetWorld( mWorld );
    g_BatchEffect->SetView( mView );
    g_BatchEffect->SetProjection( mProj );

    // Draw objects
    RenderObjects();

    // Render HUD
    DXUT_BeginPerfEvent( DXUT_PERFEVENTCOLOR, L"HUD / Stats" );
    g_HUD.OnRender( fElapsedTime );
    g_SampleUI.OnRender( fElapsedTime );
    RenderText();
    DXUT_EndPerfEvent();

    static ULONGLONG timefirst = GetTickCount64();
    if ( GetTickCount64() - timefirst > 5000 )
    {    
        OutputDebugString( DXUTGetFrameStats( DXUTIsVsyncEnabled() ) );
        OutputDebugString( L"\n" );
        timefirst = GetTickCount64();
    }
}
开发者ID:AndreAhmed,项目名称:directx-sdk-samples,代码行数:47,代码来源:Collision.cpp

示例8: V

//--------------------------------------------------------------------------------------
// Render the scene using the D3D9 device
//--------------------------------------------------------------------------------------
void CALLBACK OnD3D9FrameRender( IDirect3DDevice9* pd3dDevice, double fTime, float fElapsedTime, void* pUserContext )
{
    HRESULT hr;
    D3DXMATRIXA16 mWorld;
    D3DXMATRIXA16 mView;
    D3DXMATRIXA16 mProj;
    D3DXMATRIXA16 mWorldViewProjection;

    // If the settings dialog is being shown, then render it instead of rendering the app's scene
    if( g_SettingsDlg.IsActive() )
    {
        g_SettingsDlg.OnRender( fElapsedTime );
        return;
    }

    // Clear the render target and the zbuffer 
    V( pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_ARGB( 0, 45, 50, 170 ), 1.0f, 0 ) );

    // Render the scene
    if( SUCCEEDED( pd3dDevice->BeginScene() ) )
    {
        // Get the projection & view matrix from the camera class
        mWorld = *g_Camera.GetWorldMatrix();
        mProj = *g_Camera.GetProjMatrix();
        mView = *g_Camera.GetViewMatrix();

        mWorldViewProjection = mWorld * mView * mProj;

        // Update the effect's variables.  Instead of using strings, it would 
        // be more efficient to cache a handle to the parameter by calling 
        // ID3DXEffect::GetParameterByName
        V( g_pEffect9->SetMatrix( g_hmWorldViewProjection, &mWorldViewProjection ) );
        V( g_pEffect9->SetMatrix( g_hmWorld, &mWorld ) );
        V( g_pEffect9->SetFloat( g_hfTime, ( float )fTime ) );

        DXUT_BeginPerfEvent( DXUT_PERFEVENTCOLOR, L"HUD / Stats" ); // These events are to help PIX identify what the code is doing
        RenderText();
        V( g_HUD.OnRender( fElapsedTime ) );
        V( g_SampleUI.OnRender( fElapsedTime ) );
        DXUT_EndPerfEvent();

        V( pd3dDevice->EndScene() );
    }
}
开发者ID:capturePointer,项目名称:DllLoader,代码行数:47,代码来源:SimpleSample.cpp

示例9: sizeof

void CALLBACK OnD3D11FrameRender(ID3D11Device* pd3dDevice,
				ID3D11DeviceContext* pd3dImmediateContext,
				double fTime, float fElapsedTime, void* pUserContext)
{
	pd3dImmediateContext->ClearRenderTargetView(DXUTGetD3D11RenderTargetView(), Colors::DeepSkyBlue);
	pd3dImmediateContext->ClearDepthStencilView(DXUTGetD3D11DepthStencilView(), D3D11_CLEAR_DEPTH, 1.0f, 0);

	
	CONSTANTBUFFER cb;
	ZeroMemory(&cb, sizeof(CONSTANTBUFFER));
	XMMATRIX mat = XMLoadFloat4x4(&(g_mesh->getWorld()));	
	XMStoreFloat4x4(&cb.world, XMMatrixTranspose(mat));

	//cb.world =  g_mesh->getWorld();
	XMStoreFloat4x4(&cb.view, XMMatrixTranspose(g_camera.GetViewMatrix()));
	XMStoreFloat4x4(&cb.projection, XMMatrixTranspose(g_camera.GetProjMatrix()));

	/*
		1 0 0 0	Side (Right)
		0 1 0 0	Up
		0 0 1 0 Foward
		x y z 1 Position
	*/


	//1. XMMATRIX -> FLOAT4X4 
	XMVECTOR v = XMVectorSet(1.0f, 1.0f, 1.0f, 1.0f);
	XMVECTOR litpos = XMVector4Transform(v, g_matLight);
	litpos = XMVector4Normalize(litpos);
	XMStoreFloat4(&cb.litDir, litpos);
	cb.litCol = XMFLOAT4(0.7f, 0.7f, 0.6f, 1.0f);

	g_shader->RenderPrepare(&cb);
	g_mesh->Render();


	//
	mat = XMLoadFloat4x4(&(g_meshLight->getWorld()));
	XMStoreFloat4x4(&cb.world, XMMatrixTranspose(mat));
	g_shader->RenderPrepare(&cb);
	g_meshLight->Render();
	
}
开发者ID:contacoonta,项目名称:sgap-direct3d,代码行数:43,代码来源:DXUTMain.cpp

示例10: OnFrameMove

//--------------------------------------------------------------------------------------
// Handle updates to the scene.  This is called regardless of which D3D API is used
//--------------------------------------------------------------------------------------
void CALLBACK OnFrameMove( double fTime, float fElapsedTime, void* pUserContext )
{
    D3DXMATRIXA16 mWorld;
    D3DXMATRIXA16 mView;
    D3DXMATRIXA16 mProj;
    D3DXMATRIXA16 mWorldViewProjection;

    // Update the camera's position based on user input 
    g_Camera.FrameMove( fElapsedTime );

    // Get the projection & view matrix from the camera class
    mWorld = g_mCenterWorld * *g_Camera.GetWorldMatrix();
    mProj = *g_Camera.GetProjMatrix();
    mView = *g_Camera.GetViewMatrix();

    mWorldViewProjection = mWorld * mView * mProj;

    // Update the effect's variables 
    g_pEffect->SetMatrix( g_hWorldViewProjection, &mWorldViewProjection );
    g_pEffect->SetMatrix( g_hWorld, &mWorld );
    g_pEffect->SetFloat( g_hTime, ( float )fTime );
}
开发者ID:KNeal,项目名称:Oculus,代码行数:25,代码来源:CompiledEffect.cpp

示例11: RenderText

//--------------------------------------------------------------------------------------
// Render the scene using the D3D11 device
//--------------------------------------------------------------------------------------
void CALLBACK OnD3D11FrameRender(ID3D11Device* pd3dDevice, ID3D11DeviceContext* pd3dImmediateContext, double /*fTime*/,
    float fElapsedTime, void* /*pUserContext*/)
{
    // If the settings dialog is being shown, then render it instead of rendering the app's scene
    if (g_D3DSettingsDlg.IsActive())
    {
        g_D3DSettingsDlg.OnRender(fElapsedTime);
        return;
    }

    // Get the projection & view matrix from the camera class
    XMMATRIX mWorld;
    XMMATRIX mView;
    XMMATRIX mProj;
    XMMATRIX mWorldViewProjection;
    mWorld = g_Camera.GetWorldMatrix();
    mView = g_Camera.GetViewMatrix();
    mProj = g_Camera.GetProjMatrix();
    mWorldViewProjection = mWorld * mView * mProj;

    // Store off original render target and depth/stencil
    ID3D11RenderTargetView* pOrigRTV = NULL;
    ID3D11DepthStencilView* pOrigDSV = NULL;
    pd3dImmediateContext->OMGetRenderTargets(1, &pOrigRTV, &pOrigDSV);

    g_OIT.Render(pd3dImmediateContext, pd3dDevice, &g_Scene, mWorldViewProjection, pOrigRTV, pOrigDSV);

    pd3dImmediateContext->OMSetRenderTargets(1, &pOrigRTV, pOrigDSV);

    // Restore original render targets, and then draw UI
    SAFE_RELEASE(pOrigRTV);
    SAFE_RELEASE(pOrigDSV);

    DXUT_BeginPerfEvent(DXUT_PERFEVENTCOLOR, L"HUD / Stats");
    g_HUD.OnRender(fElapsedTime);
    g_SampleUI.OnRender(fElapsedTime);
    RenderText();
    DXUT_EndPerfEvent();
}
开发者ID:marselas,项目名称:Zombie-Direct3D-Samples,代码行数:42,代码来源:main.cpp

示例12: V

//--------------------------------------------------------------------------------------
// Render the scene using the D3D9 device
//--------------------------------------------------------------------------------------
void CALLBACK OnD3D9FrameRender( IDirect3DDevice9* pd3dDevice, double fTime, float fElapsedTime, void* pUserContext )
{
    HRESULT hr = S_OK;

    // If the settings dialog is being shown, then render it instead of rendering the app's scene
    if( g_SettingsDlg.IsActive() )
    {
        g_SettingsDlg.OnRender( fElapsedTime );
        return;
    }

    D3DXMATRIX mWorld = *g_Camera.GetWorldMatrix();
    D3DXMATRIX mView = *g_Camera.GetViewMatrix();
    D3DXMATRIX mProj = *g_Camera.GetProjMatrix();
    D3DXMATRIX mWorldViewProjection = mWorld * mView * mProj;

    // Clear the render target and the zbuffer 
    V( pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_ARGB( 0, 160, 160, 250 ), 1.0f, 0 ) );

    // Render the scene
    if( SUCCEEDED( pd3dDevice->BeginScene() ) )
    {
        g_pEffect9->SetMatrix( g_hmWorld, &mWorld );
        g_pEffect9->SetMatrix( g_hmWorldViewProjection, &mWorldViewProjection );
        g_pEffect9->SetTexture( g_htxDiffuse, g_pTexture9 );

        pd3dDevice->SetVertexDeclaration( g_pDecl9 );

        g_Mesh.Render( pd3dDevice, g_pEffect9, g_hRenderScene );

        DXUT_BeginPerfEvent( DXUT_PERFEVENTCOLOR, L"HUD / Stats" ); // These events are to help PIX identify what the code is doing
        RenderText();
        V( g_HUD.OnRender( fElapsedTime ) );
        V( g_SampleUI.OnRender( fElapsedTime ) );
        DXUT_EndPerfEvent();

        V( pd3dDevice->EndScene() );
    }
}
开发者ID:KNeal,项目名称:Oculus,代码行数:42,代码来源:DDSWithoutD3DX9.cpp

示例13: lightDir

//--------------------------------------------------------------------------------------
// Render the scene using the D3D10 device
//--------------------------------------------------------------------------------------
void CALLBACK OnD3D10FrameRender( ID3D10Device* pd3dDevice, double fTime, float fElapsedTime, void* pUserContext )
{
    // Clear the render target
    float ClearColor[4] = { 0.9569f, 0.9569f, 1.0f, 0.0f };
    ID3D10RenderTargetView* pRTV = DXUTGetD3D10RenderTargetView();
    pd3dDevice->ClearRenderTargetView( pRTV, ClearColor );
    ID3D10DepthStencilView* pDSV = DXUTGetD3D10DepthStencilView();
    pd3dDevice->ClearDepthStencilView( pDSV, D3D10_CLEAR_DEPTH, 1.0, 0 );

    D3DXMATRIX mWorld;
    D3DXMATRIX mView;
    D3DXMATRIX mProj;
    D3DXMATRIX mWorldView;
    D3DXMATRIX mWorldViewProj;
    mWorld = *g_Camera.GetWorldMatrix();
    mProj = *g_Camera.GetProjMatrix();
    mView = *g_Camera.GetViewMatrix();
    mWorldView = mWorld * mView;
    mWorldViewProj = mWorldView * mProj;

    // Set variables
    g_pmWorldViewProj->SetMatrix( ( float* )&mWorldViewProj );
    g_pmWorldView->SetMatrix( ( float* )&mWorldView );
    g_pmWorld->SetMatrix( ( float* )&mWorld );
    g_pmProj->SetMatrix( ( float* )&mProj );
    g_pDiffuseTex->SetResource( g_pMeshTexRV );
    D3DXVECTOR3 lightDir( -1,1,-1 );
    D3DXVECTOR3 viewLightDir;
    D3DXVec3TransformNormal( &viewLightDir, &lightDir, &mView );
    D3DXVec3Normalize( &viewLightDir, &viewLightDir );
    g_pViewSpaceLightDir->SetFloatVector( ( float* )&viewLightDir );

    // Get VB and IB
    UINT offset = 0;
    UINT stride = g_Mesh.GetVertexStride( 0, 0 );
    ID3D10Buffer* pVB = g_Mesh.GetVB10( 0, 0 );
    ID3D10Buffer* pIB = g_Mesh.GetAdjIB10( 0 );

    // Set Input Assembler params
    pd3dDevice->IASetInputLayout( g_pVertexLayout );

    pd3dDevice->IASetIndexBuffer( pIB, g_Mesh.GetIBFormat10( 0 ), 0 );
    pd3dDevice->IASetVertexBuffers( 0, 1, &pVB, &stride, &offset );
    pd3dDevice->IASetPrimitiveTopology( D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST_ADJ );

    // Render using the technique g_pRenderTextured
    SDKMESH_SUBSET* pSubset = NULL;

    D3D10_TECHNIQUE_DESC techDesc;
    g_pRenderTextured->GetDesc( &techDesc );
    for( UINT p = 0; p < techDesc.Passes; p++ )
    {
        g_pRenderTextured->GetPassByIndex( p )->Apply( 0 );
        for( UINT subset = 0; subset < g_Mesh.GetNumSubsets( 0 ); subset++ )
        {
            pSubset = g_Mesh.GetSubset( 0, subset );

            pd3dDevice->DrawIndexed( ( UINT )pSubset->IndexCount * 2, ( UINT )pSubset->IndexStart,
                                     ( UINT )pSubset->VertexStart );
        }
    }

    // Render the chess piece just for show
    // Render using the technique g_pRenderPiece
    g_pRenderPiece->GetDesc( &techDesc );
    for( UINT p = 0; p < techDesc.Passes; p++ )
    {
        g_pRenderPiece->GetPassByIndex( p )->Apply( 0 );
        for( UINT subset = 0; subset < g_Mesh.GetNumSubsets( 0 ); subset++ )
        {
            pSubset = g_Mesh.GetSubset( 0, subset );

            pd3dDevice->DrawIndexed( ( UINT )pSubset->IndexCount * 2, ( UINT )pSubset->IndexStart,
                                     ( UINT )pSubset->VertexStart );
        }
    }
}
开发者ID:KNeal,项目名称:Oculus,代码行数:80,代码来源:Exercise03.cpp

示例14: RenderSceneMesh

//--------------------------------------------------------------------------------------
// Render the scene using the D3D10 device
//--------------------------------------------------------------------------------------
void CALLBACK OnD3D10FrameRender( ID3D10Device* pd3dDevice, double fTime, float fElapsedTime, void* pUserContext )
{
    float ClearColor[4] = { 1.0f, 1.0f, 1.0f, 0.0f }; // R, G, B, A
    ID3D10RenderTargetView* pRTV = DXUTGetD3D10RenderTargetView();
    pd3dDevice->ClearRenderTargetView( pRTV, ClearColor );
    ID3D10DepthStencilView* pDSV = DXUTGetD3D10DepthStencilView();
    pd3dDevice->ClearDepthStencilView( pDSV, D3D10_CLEAR_DEPTH, 1.0, 0 );

    // If the settings dialog is being shown, then render it instead of rendering the app's scene
    if( g_D3DSettingsDlg.IsActive() )
    {
        g_D3DSettingsDlg.OnRender( fElapsedTime );
        return;
    }

    // Set our render target since we can't present multisampled ref
    ID3D10RenderTargetView* pOrigRT;
    ID3D10DepthStencilView* pOrigDS;
    pd3dDevice->OMGetRenderTargets( 1, &pOrigRT, &pOrigDS );
    ID3D10RenderTargetView* aRTViews[ 1 ] = { g_pRTRV };
    pd3dDevice->OMSetRenderTargets( 1, aRTViews, g_pDSRV );

    pd3dDevice->ClearRenderTargetView( g_pRTRV, ClearColor );
    pd3dDevice->ClearDepthStencilView( g_pDSRV, D3D10_CLEAR_DEPTH, 1.0, 0 );

    // Set Matrices
    D3DXMATRIX mWorldViewProj;
    D3DXMATRIX mWorldView;
    D3DXMATRIX mViewProj;
    D3DXMATRIX mWorld;
    D3DXMATRIX mView;
    D3DXMATRIX mProj;

    // Fix the camera motion for now
    D3DXMATRIX mBlurViewProj[MAX_TIME_STEPS];
    for( int i = 0; i < MAX_TIME_STEPS; i++ )
    {
        mView = *g_Camera.GetViewMatrix();
        mProj = *g_Camera.GetProjMatrix();
        mBlurViewProj[i] = mView * mProj;
    }
    g_pmBlurViewProj->SetMatrixArray( ( float* )mBlurViewProj, 0, MAX_TIME_STEPS );

    D3DXMatrixIdentity( &mWorld );
    mView = *g_Camera.GetViewMatrix();
    mProj = *g_Camera.GetProjMatrix();
    mViewProj = mView * mProj;
    mWorldViewProj = mWorld * mViewProj;
    mWorldView = mWorld * mView;

    g_pmWorldViewProj->SetMatrix( ( float* )&mWorldViewProj );
    g_pmViewProj->SetMatrix( ( float* )&mViewProj );
    g_pmWorldView->SetMatrix( ( float* )&mWorldView );

    RenderSceneMesh( pd3dDevice, &g_SceneMesh, false );
    RenderFanMesh( pd3dDevice, &g_FanMesh, fTime, false );
    if( g_bRenderOgre )
        RenderSkinnedMesh( pd3dDevice, &g_AnimMesh, fTime, false );

    for( UINT iMesh = 0; iMesh < g_NumLinkedMeshes; iMesh++ )
        RenderLinkedMesh( pd3dDevice, &g_pLinkedMeshes[iMesh], &g_AnimMesh, g_MeshLinkages[iMesh].iBone, fTime,
                          false );

    if( g_bUseMotionBlur )
    {
        RenderFanMesh( pd3dDevice, &g_FanMesh, fTime, true );
        if( g_bRenderOgre )
            RenderSkinnedMesh( pd3dDevice, &g_AnimMesh, fTime, true );

        for( UINT iMesh = 0; iMesh < g_NumLinkedMeshes; iMesh++ )
            RenderLinkedMesh( pd3dDevice, &g_pLinkedMeshes[iMesh], &g_AnimMesh, g_MeshLinkages[iMesh].iBone, fTime,
                              true );
    }

    //MSAA resolve
    ID3D10Resource* pRT;
    pOrigRT->GetResource( &pRT );
    D3D10_RENDER_TARGET_VIEW_DESC rtDesc;
    pOrigRT->GetDesc( &rtDesc );
    pd3dDevice->ResolveSubresource( pRT, D3D10CalcSubresource( 0, 0, 1 ), g_pRenderTarget, D3D10CalcSubresource( 0, 0,
                                                                                                                 1 ),
                                    rtDesc.Format );
    SAFE_RELEASE( pRT );

    // Use our Old RT again
    aRTViews[0] = pOrigRT;
    pd3dDevice->OMSetRenderTargets( 1, aRTViews, pOrigDS );
    SAFE_RELEASE( pOrigRT );
    SAFE_RELEASE( pOrigDS );

    DXUT_BeginPerfEvent( DXUT_PERFEVENTCOLOR, L"HUD / Stats" );
    RenderText();
    g_HUD.OnRender( fElapsedTime );
    g_SampleUI.OnRender( fElapsedTime );
    DXUT_EndPerfEvent();
}
开发者ID:marselas,项目名称:Zombie-Direct3D-Samples,代码行数:99,代码来源:MotionBlur10.cpp

示例15: V

//--------------------------------------------------------------------------------------
// Render the scene using the D3D9 device
//--------------------------------------------------------------------------------------
void CALLBACK OnD3D9FrameRender( IDirect3DDevice9* pd3dDevice, double fTime, float fElapsedTime, void* pUserContext )
{
    // If the settings dialog is being shown, then render it instead of rendering the app's scene
    if( g_D3DSettingsDlg.IsActive() )
    {
        g_D3DSettingsDlg.OnRender( fElapsedTime );
        return;
    }

    HRESULT hr;
    D3DXMATRIXA16 mWorldViewProjection;
    D3DXVECTOR3 vLightDir;
    D3DXCOLOR vLightDiffuse;
    UINT iPass, cPasses;
    D3DXMATRIXA16 mWorld;
    D3DXMATRIXA16 mView;
    D3DXMATRIXA16 mProj;

    // Clear the render target and the zbuffer 
    V( pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DXCOLOR( 0.0f, 0.25f, 0.25f, 0.55f ), 1.0f,
                          0 ) );
    
    //pd3dDevice->SetSamplerState(0, D3DSAMP_SRGBTEXTURE, TRUE);
    //pd3dDevice->SetRenderState( D3DRS_SRGBWRITEENABLE, TRUE );
        // Render the scene
    if( SUCCEEDED( pd3dDevice->BeginScene() ) )
    {
        // Get the projection & view matrix from the camera class
        mWorld = g_mCenterMesh * *g_Camera.GetWorldMatrix();
        mProj = *g_Camera.GetProjMatrix();
        mView = *g_Camera.GetViewMatrix();

        mWorldViewProjection = mWorld * mView * mProj;

        g_fLightScale = 1.0;
        vLightDir = g_LightControl.GetLightDirection();
        vLightDiffuse = g_fLightScale * D3DXCOLOR( 1, 1, 1, 1 );

        V( g_pEffect9->SetValue( g_hLightDir, &vLightDir, sizeof( D3DXVECTOR3 ) * 1 ) );
        V( g_pEffect9->SetValue( g_hLightDiffuse, &vLightDiffuse, sizeof( D3DXVECTOR4 ) * 1 ) );

        // Update the effect's variables.  Instead of using strings, it would 
        // be more efficient to cache a handle to the parameter by calling 
        // ID3DXEffect::GetParameterByName
        V( g_pEffect9->SetMatrix( g_hmWorldViewProjection, &mWorldViewProjection ) );
        V( g_pEffect9->SetMatrix( g_hmWorld, &mWorld ) );

        D3DXCOLOR vWhite = D3DXCOLOR( 1, 1, 1, 1 );
        V( g_pEffect9->SetValue( g_hMaterialDiffuseColor, &vWhite, sizeof( D3DXCOLOR ) ) );
        V( g_pEffect9->SetFloat( g_hfTime, ( float )fTime ) );
        V( g_pEffect9->SetInt( g_hnNumLights, g_nNumActiveLights ) );

        // Render the scene with this technique as defined in the .fx file
        switch( g_nNumActiveLights )
        {
            case 1:
                V( g_pEffect9->SetTechnique( g_hRenderSceneWithTexture1Light ) ); break;
            case 2:
                V( g_pEffect9->SetTechnique( g_hRenderSceneWithTexture2Light ) ); break;
            case 3:
                V( g_pEffect9->SetTechnique( g_hRenderSceneWithTexture3Light ) ); break;
        }

        // Apply the technique contained in the effect and render the mesh
        V( g_pEffect9->Begin( &cPasses, 0 ) );
        for( iPass = 0; iPass < cPasses; iPass++ )
        {
            V( g_pEffect9->BeginPass( iPass ) );
            V( g_pMesh9->DrawSubset( 0 ) );
            V( g_pEffect9->EndPass() );
        }
        V( g_pEffect9->End() );

        g_HUD.OnRender( fElapsedTime );
        g_SampleUI.OnRender( fElapsedTime );

        RenderText();

        V( pd3dDevice->EndScene() );
    }
}
开发者ID:Igings,项目名称:A-3D-game-in-a-2D-paradigm,代码行数:84,代码来源:BasicHLSL9.cpp


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