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


C++ CDXUTDirectionWidget::GetLightDirection方法代码示例

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


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

示例1: UpdateLightingEnvironment

//--------------------------------------------------------------------------------------
void UpdateLightingEnvironment()
{
    // Gather lighting options from the HUD
    g_vLightDirection = g_LightControl.GetLightDirection();
    g_fLightIntensity = g_SampleUI.GetSlider( IDC_LIGHT_SLIDER )->GetValue() / 100.0f;
    g_fEnvIntensity = g_SampleUI.GetSlider( IDC_ENV_SLIDER )->GetValue() / 1000.0f;

    // Create the spotlight
    D3DXSHEvalConeLight( D3DXSH_MAXORDER, &g_vLightDirection, D3DX_PI / 8.0f,
                         g_fLightIntensity, g_fLightIntensity, g_fLightIntensity,
                         m_fRLC, m_fGLC, m_fBLC );

    float fSkybox[3][D3DXSH_MAXORDER*D3DXSH_MAXORDER];

    // Scale the light probe environment contribution based on input options    
    D3DXSHScale( fSkybox[0], D3DXSH_MAXORDER, g_fSkyBoxLightSH[0], g_fEnvIntensity );
    D3DXSHScale( fSkybox[1], D3DXSH_MAXORDER, g_fSkyBoxLightSH[1], g_fEnvIntensity );
    D3DXSHScale( fSkybox[2], D3DXSH_MAXORDER, g_fSkyBoxLightSH[2], g_fEnvIntensity );

    // Combine the environment and the spotlight
    D3DXSHAdd( m_fRLC, D3DXSH_MAXORDER, m_fRLC, fSkybox[0] );
    D3DXSHAdd( m_fGLC, D3DXSH_MAXORDER, m_fGLC, fSkybox[1] );
    D3DXSHAdd( m_fBLC, D3DXSH_MAXORDER, m_fBLC, fSkybox[2] );
}
开发者ID:KNeal,项目名称:Oculus,代码行数:25,代码来源:LocalDeformablePRT.cpp

示例2: vLightGrndClr

//--------------------------------------------------------------------------------------
// Render the scene using the D3D11 device
//--------------------------------------------------------------------------------------
void CALLBACK OnD3D11FrameRender( ID3D11Device* pd3dDevice, ID3D11DeviceContext* pd3dImmediateContext, double fTime,
                                  float fElapsedTime, void* pUserContext )
{
    HRESULT hr;

    // 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;
    }

    // Clear the render target and depth stencil
    auto pRTV = DXUTGetD3D11RenderTargetView();
    pd3dImmediateContext->ClearRenderTargetView( pRTV, Colors::MidnightBlue );
    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 mProj  = g_Camera.GetProjMatrix();
    XMMATRIX mView  = g_Camera.GetViewMatrix();

    // Get the light direction
    XMVECTOR vLightDir = g_LightControl.GetLightDirection();

    // Render the light arrow so the user can visually see the light dir
    V( g_LightControl.OnRender( Colors::Yellow, mView, mProj, g_Camera.GetEyePt() ) );

    // Ambient Light
    static const XMVECTORF32 s_vLightColorA = { 0.1f, 0.1f, 0.1f, 1.0f };
    g_pAmbientLightColor->SetFloatVector( s_vLightColorA );
    g_pAmbientLightEnable->SetBool(true);

    // Hemi Ambient Light
    static const XMVECTORF32 s_vLightColorH1 = { 0.3f, 0.3f, 0.4f, 1.0f };
    g_pHemiAmbientLightColor->SetFloatVector( s_vLightColorH1 );
    g_pHemiAmbientLightEnable->SetBool(true);

    XMFLOAT4 vLightGrndClr( 0.05f, 0.05f, 0.05f, 1.f );
    g_pHemiAmbientLightGroundColor->SetFloatVector( reinterpret_cast<float*>( &vLightGrndClr ) );

    XMFLOAT4 vVec(0.0f, 1.0f, 0.0f, 1.0f);
    g_pHemiAmbientLightDirUp->SetFloatVector( reinterpret_cast<float*>( &vVec ) );

    // Directional Light
    g_pDirectionalLightColor->SetFloatVector( Colors::White );
    g_pDirectionalLightEnable->SetBool(true);

    XMFLOAT4 tmp;
    XMStoreFloat4( &tmp, vLightDir );
    tmp.w = 1.f;
    g_pDirectionalLightDir->SetFloatVector( reinterpret_cast<float*>( &tmp ) );

    // Environment Light - color comes from the texture
    g_pEnvironmentLightColor->SetFloatVector( Colors::Black );
    g_pEnvironmentLightEnable->SetBool(true);

    // Setup the Eye based on the DXUT camera
    XMVECTOR vEyePt = g_Camera.GetEyePt();
    XMVECTOR vDir = g_Camera.GetLookAtPt() - vEyePt;
    XMStoreFloat4( &tmp, vDir );
    tmp.w = 1.f;
    g_pEyeDir->SetFloatVector( reinterpret_cast<float*>( &tmp ) );

    //Get the mesh
    //IA setup
    pd3dImmediateContext->IASetInputLayout( g_pVertexLayout11 );
    UINT Strides[1];
    UINT Offsets[1];
    ID3D11Buffer* pVB[1];
    pVB[0] = g_Mesh11.GetVB11( 0, 0 );
    Strides[0] = ( UINT )g_Mesh11.GetVertexStride( 0, 0 );
    Offsets[0] = 0;
    pd3dImmediateContext->IASetVertexBuffers( 0, 1, pVB, Strides, Offsets );
    pd3dImmediateContext->IASetIndexBuffer( g_Mesh11.GetIB11( 0 ), g_Mesh11.GetIBFormat11( 0 ), 0 );
 
    // Set the per object constant data
    XMMATRIX mWorldViewProjection = mWorld * mView * mProj;

    // VS Per object
    XMFLOAT4X4 tmp4x4;
    XMStoreFloat4x4( &tmp4x4, mWorldViewProjection );
    g_pWorldViewProjection->SetMatrix( reinterpret_cast<float*>( &tmp4x4 ) );
    XMStoreFloat4x4( &tmp4x4, mWorld );
    g_pWorld->SetMatrix( reinterpret_cast<float*>( &tmp4x4 ) );

    // Setup the Shader Linkage based on the user settings for Lighting
    ID3DX11EffectClassInstanceVariable* pLightClassVar;
    
    // Ambient Lighting First - Constant or Hemi?
    if ( g_bHemiAmbientLighting )
    {
        pLightClassVar = g_pHemiAmbientLightClass;
    }
    else
    {
//.........这里部分代码省略.........
开发者ID:AndreAhmed,项目名称:directx-sdk-samples,代码行数:101,代码来源:DynamicShaderLinkageFX11.cpp

示例3: 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


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