本文整理汇总了C++中CModelViewerCamera::GetEyePt方法的典型用法代码示例。如果您正苦于以下问题:C++ CModelViewerCamera::GetEyePt方法的具体用法?C++ CModelViewerCamera::GetEyePt怎么用?C++ CModelViewerCamera::GetEyePt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CModelViewerCamera
的用法示例。
在下文中一共展示了CModelViewerCamera::GetEyePt方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
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() );
}
}
示例2: 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() );
}
}
示例3: 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
{
//.........这里部分代码省略.........
示例4: if
//--------------------------------------------------------------------------------------
// 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;
}
// WVP
XMMATRIX mProj = g_Camera.GetProjMatrix();
XMMATRIX mView = g_Camera.GetViewMatrix();
XMMATRIX mViewProjection = mView * mProj;
// Update per-frame variables
D3D11_MAPPED_SUBRESOURCE MappedResource;
pd3dImmediateContext->Map( g_pcbPerFrame, 0, D3D11_MAP_WRITE_DISCARD, 0, &MappedResource );
auto pData = reinterpret_cast<CB_PER_FRAME_CONSTANTS*>( MappedResource.pData );
XMStoreFloat4x4( &pData->mViewProjection, XMMatrixTranspose( mViewProjection ) );
XMStoreFloat3( &pData->vCameraPosWorld, g_Camera.GetEyePt() );
pData->fTessellationFactor = (float)g_fSubdivs;
pd3dImmediateContext->Unmap( g_pcbPerFrame, 0 );
// Clear the render target and depth stencil
auto pRTV = DXUTGetD3D11RenderTargetView();
pd3dImmediateContext->ClearRenderTargetView( pRTV, Colors::Black );
auto pDSV = DXUTGetD3D11DepthStencilView();
pd3dImmediateContext->ClearDepthStencilView( pDSV, D3D11_CLEAR_DEPTH, 1.0, 0 );
// Set state for solid rendering
pd3dImmediateContext->RSSetState( g_pRasterizerStateSolid );
// Render the meshes
// Bind all of the CBs
pd3dImmediateContext->VSSetConstantBuffers( g_iBindPerFrame, 1, &g_pcbPerFrame );
pd3dImmediateContext->HSSetConstantBuffers( g_iBindPerFrame, 1, &g_pcbPerFrame );
pd3dImmediateContext->DSSetConstantBuffers( g_iBindPerFrame, 1, &g_pcbPerFrame );
pd3dImmediateContext->PSSetConstantBuffers( g_iBindPerFrame, 1, &g_pcbPerFrame );
// Set the shaders
pd3dImmediateContext->VSSetShader( g_pVertexShader, nullptr, 0 );
// For this sample, choose either the "integer", "fractional_even",
// or "fractional_odd" hull shader
if (g_iPartitionMode == PARTITION_INTEGER)
pd3dImmediateContext->HSSetShader( g_pHullShaderInteger, nullptr, 0 );
else if (g_iPartitionMode == PARTITION_FRACTIONAL_EVEN)
pd3dImmediateContext->HSSetShader( g_pHullShaderFracEven, nullptr, 0 );
else if (g_iPartitionMode == PARTITION_FRACTIONAL_ODD)
pd3dImmediateContext->HSSetShader( g_pHullShaderFracOdd, nullptr, 0 );
pd3dImmediateContext->DSSetShader( g_pDomainShader, nullptr, 0 );
pd3dImmediateContext->GSSetShader( nullptr, nullptr, 0 );
pd3dImmediateContext->PSSetShader( g_pPixelShader, nullptr, 0 );
// Optionally draw the wireframe
if( g_bDrawWires )
{
pd3dImmediateContext->PSSetShader( g_pSolidColorPS, nullptr, 0 );
pd3dImmediateContext->RSSetState( g_pRasterizerStateWireframe );
}
// Set the input assembler
// This sample uses patches with 16 control points each
// Although the Mobius strip only needs to use a vertex buffer,
// you can use an index buffer as well by calling IASetIndexBuffer().
pd3dImmediateContext->IASetInputLayout( g_pPatchLayout );
UINT Stride = sizeof( BEZIER_CONTROL_POINT );
UINT Offset = 0;
pd3dImmediateContext->IASetVertexBuffers( 0, 1, &g_pControlPointVB, &Stride, &Offset );
pd3dImmediateContext->IASetPrimitiveTopology( D3D11_PRIMITIVE_TOPOLOGY_16_CONTROL_POINT_PATCHLIST );
// Draw the mesh
pd3dImmediateContext->Draw( ARRAYSIZE(g_MobiusStrip), 0 );
pd3dImmediateContext->RSSetState( g_pRasterizerStateSolid );
// Render the HUD
DXUT_BeginPerfEvent( DXUT_PERFEVENTCOLOR, L"HUD / Stats" );
g_HUD.OnRender( fElapsedTime );
g_SampleUI.OnRender( fElapsedTime );
RenderText();
DXUT_EndPerfEvent();
}
示例5: 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[MAX_LIGHTS];
D3DXCOLOR vLightDiffuse[MAX_LIGHTS];
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 ) );
// 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;
// Render the light arrow so the user can visually see the light dir
for( int i = 0; i < g_nNumActiveLights; i++ )
{
D3DXCOLOR arrowColor = ( i == g_nActiveLight ) ? D3DXCOLOR( 1, 1, 0, 1 ) : D3DXCOLOR( 1, 1, 1, 1 );
V( g_LightControl[i].OnRender9( arrowColor, &mView, &mProj, g_Camera.GetEyePt() ) );
vLightDir[i] = g_LightControl[i].GetLightDirection();
vLightDiffuse[i] = g_fLightScale * D3DXCOLOR( 1, 1, 1, 1 );
}
V( g_pEffect9->SetValue( g_hLightDir, vLightDir, sizeof( D3DXVECTOR3 ) * MAX_LIGHTS ) );
V( g_pEffect9->SetValue( g_hLightDiffuse, vLightDiffuse, sizeof( D3DXVECTOR4 ) * MAX_LIGHTS ) );
// 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() );
}
}
示例6: DXUTGetFPS
void CALLBACK OnD3D11FrameRender(ID3D11Device* pd3dDevice, ID3D11DeviceContext* pd3dImmediateContext, double fTime,
float fElapsedTime, void* pUserContext)
{
pd3dImmediateContext->ClearRenderTargetView(DXUTGetD3D11RenderTargetView(), Colors::Black);
pd3dImmediateContext->ClearDepthStencilView(DXUTGetD3D11DepthStencilView(), D3D11_CLEAR_DEPTH, 1.0, 0);
XMMATRIX mworld = g_camera.GetWorldMatrix();
XMMATRIX mview = g_camera.GetViewMatrix();
XMMATRIX mproj = g_camera.GetProjMatrix();
g_BatchEffect->SetView(mview);
g_BatchEffect->SetProjection(mproj);
// Draw Grids
const XMVECTORF32 xaxis = { 50.f, 0.f, 0.f };
const XMVECTORF32 yaxis = { 0.f, 0.f, 50.f };
DrawGrid(xaxis, yaxis, g_XMZero, 50, 50, Colors::Azure);
// Draw Font
g_dwtext->Render(L"га╥╧юс = ", DXUTGetFPS(), 10, 10);
XMVECTOR worldPos;
XMVECTOR worldDir;
//g_input->getMousePosWorld(worldPos, worldDir, mview, mproj, TRUE);
g_input->Pick(worldPos, worldDir, mworld, mview, mproj);
/*
POSITION
*/
WCHAR strformat[256] = {};
XMFLOAT3 pos;
XMStoreFloat3(&pos, worldPos);
swprintf(strformat, L"pos = %f , %f , %f", pos.x, pos.y, pos.z);
g_dwtext->Render(strformat, 0, 10, 30);
/*
DIRECTION
*/
XMFLOAT3 dir;
XMStoreFloat3(&dir, worldDir);
swprintf(strformat, L"dir = %f , %f , %f", dir.x, dir.y, dir.z);
g_dwtext->Render(strformat, 0, 10, 50);
/*
CURSOR POSITION
*/
POINT pt = g_input->getMousePos();
swprintf(strformat, L"cursor = %d , %d", pt.x, pt.y );
g_dwtext->Render(strformat, 0, 10, 70);
XMVECTOR eye = g_camera.GetEyePt();
XMFLOAT3 feye;
XMStoreFloat3(&feye, eye);
swprintf(strformat, L"eye = %f , %f , %f", feye.x, feye.y, feye.z);
g_dwtext->Render(strformat, 0, 10, 90);
XMVECTOR lookat = g_camera.GetLookAtPt();
XMFLOAT3 flookat;
XMStoreFloat3(&flookat, lookat);
swprintf(strformat, L"lookat = %f , %f , %f", flookat.x, flookat.y, flookat.z);
g_dwtext->Render(strformat, 0, 10, 110);
XMVECTOR axis1 = XMVectorSet( pos.x, pos.y, pos.z, 0.0f);
XMVECTOR axis2 = XMVectorSet(dir.x, dir.y, dir.z, 0.0f);
DrawCenterGrid(axis1, axis2);
XMMATRIX wpos = XMMatrixTranslation(pos.x, pos.y, pos.z);
g_ShapePos->Draw(wpos, mview, mproj, Colors::LawnGreen);
XMMATRIX wdir = XMMatrixTranslation(dir.x, dir.y, dir.z);
g_ShapeDir->Draw(wdir, mview, mproj, Colors::OrangeRed);
}
示例7: V
//--------------------------------------------------------------------------------------
// Render the scene using the D3D10 device
//--------------------------------------------------------------------------------------
void CALLBACK OnD3D10FrameRender( ID3D10Device* 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;
}
//
// Clear the back buffer
//
float ClearColor[4] = { .0f, 0.0f, 0.0f, 1.0f } ; // red, green, blue, alpha
ID3D10RenderTargetView* pRTV = DXUTGetD3D10RenderTargetView();
pd3dDevice->ClearRenderTargetView( pRTV, ClearColor );
//
// Clear the depth stencil
//
ID3D10DepthStencilView* pDSV = DXUTGetD3D10DepthStencilView();
pd3dDevice->ClearDepthStencilView( pDSV, D3D10_CLEAR_DEPTH, 1.0, 0 );
//
// Update the Cull Mode (non-FX method) setup the render state
//
pd3dDevice->RSSetState( g_pRasterStates[ 0 ] );
HRESULT hr;
D3DXMATRIXA16 mWorld;
D3DXMATRIXA16 mView;
D3DXMATRIXA16 mProj;
D3DXMATRIXA16 mWorldViewProjection;
// 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_pWorldViewProjection->SetMatrix( (float*)&mWorldViewProjection ) );
V( g_pWorld->SetMatrix( (float*)&mWorld ) );
V( g_pTime->SetFloat( (float)fTime ) );
V( g_pCameraPosition->SetFloatVector( (float*)g_Camera.GetEyePt() ) );
// Blend
pd3dDevice->OMSetDepthStencilState(0, 0);
float blendFactor[] = {0.0f, 0.0f, 0.0f, 0.0f};
pd3dDevice->OMSetBlendState(0, blendFactor, 0xffffffff);
//
// Set the Vertex Layout
//
pd3dDevice->IASetInputLayout( g_pVertexLayout );
UINT iCurSubset = ( UINT )( INT_PTR )g_SampleUI.GetComboBox( IDC_SUBSET )->GetSelectedData();
//
// Render the mesh
//
// Stop render the loader mesh
bool drawLoaderMesh = true;
if (drawLoaderMesh) {
if ( iCurSubset == -1 )
{
for ( UINT iSubset = 0; iSubset < g_MeshLoader.GetNumSubsets(); ++iSubset )
{
RenderSubset( iSubset );
}
} else
{
RenderSubset( iCurSubset );
}
}
//
// Render the Cube
//
//UINT cubeAttributCount;
// This is not efficiency this procedure will always call to the GPU
// To get the number of suset.
//g_TrialCube->GetAttributeTable(NULL, &cubeAttributCount);
//for (UINT iSubset = 0; iSubset < cubeAttributCount; iSubset++)
//{
// g_TrialCube->DrawSubset(iSubset);
//}
//g_TrialCube->DrawSubset(0);
pd3dDevice->RSSetState( g_pRasterStates[ g_eSceneRasterizerMode ] );
pd3dDevice->OMSetBlendState(g_TransparentBS, blendFactor, 0xffffffff);
//g_pBox->draw();
bool drawAABBLevel=false;
//.........这里部分代码省略.........
示例8: V
//--------------------------------------------------------------------------------------
// Render the scene using the D3D10 device
//--------------------------------------------------------------------------------------
void CALLBACK OnD3D10FrameRender( ID3D10Device* 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;
}
//
// Clear the back buffer
//
float ClearColor[4] = { 0.3f, 0.3f, 0.3f, 1.0f } ; // red, green, blue, alpha
ID3D10RenderTargetView* pRTV = DXUTGetD3D10RenderTargetView();
pd3dDevice->ClearRenderTargetView( pRTV, ClearColor );
//
// Clear the depth stencil
//
ID3D10DepthStencilView* pDSV = DXUTGetD3D10DepthStencilView();
pd3dDevice->ClearDepthStencilView( pDSV, D3D10_CLEAR_DEPTH, 1.0, 0 );
HRESULT hr;
D3DXMATRIXA16 mWorld;
D3DXMATRIXA16 mView;
D3DXMATRIXA16 mProj;
D3DXMATRIXA16 mWorldViewProjection;
// 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_pWorldViewProjection->SetMatrix( (float*)&mWorldViewProjection ) );
V( g_pWorld->SetMatrix( (float*)&mWorld ) );
V( g_pTime->SetFloat( (float)fTime ) );
V( g_pCameraPosition->SetFloatVector( (float*)g_Camera.GetEyePt() ) );
//
// Set the Vertex Layout
//
pd3dDevice->IASetInputLayout( g_pVertexLayout );
UINT iCurSubset = ( UINT )( INT_PTR )g_SampleUI.GetComboBox( IDC_SUBSET )->GetSelectedData();
//
// Render the mesh
//
if ( iCurSubset == -1 )
{
for ( UINT iSubset = 0; iSubset < g_MeshLoader.GetNumSubsets(); ++iSubset )
{
RenderSubset( iSubset );
}
} else
{
RenderSubset( iCurSubset );
}
DXUT_BeginPerfEvent( DXUT_PERFEVENTCOLOR, L"HUD / Stats" );
RenderText();
g_HUD.OnRender( fElapsedTime );
g_SampleUI.OnRender( fElapsedTime );
DXUT_EndPerfEvent();
}