//-------------------------------------------------------------------------------------- // Handle updates to the scene. This is called regardless of which D3D API is used //-------------------------------------------------------------------------------------- void CALLBACK OnFrameMove( double fTime, FLOAT fElapsedTime, void* pUserContext ) { UNREFERENCED_PARAMETER(pUserContext); UNREFERENCED_PARAMETER(fTime); // Update the camera's position based on user input g_LightCamera.FrameMove( fElapsedTime ); g_ViewerCamera.FrameMove( fElapsedTime ); }
void CALLBACK OnFrameMove( IDirect3DDevice9* pd3dDevice, double fTime, float fElapsedTime, void* pUserContext ) { // Update the camera's position based on user input g_Camera.FrameMove( fElapsedTime ); OnMyAppFrameMove( pd3dDevice, fTime, fElapsedTime, pUserContext ); }
//-------------------------------------------------------------------------------------- // When the user changes scene, recreate these components as they are scene // dependent. //-------------------------------------------------------------------------------------- HRESULT CreateD3DComponents( ID3D11Device* pd3dDevice) { HRESULT hr; auto pd3dImmediateContext = DXUTGetD3D11DeviceContext(); V_RETURN( g_DialogResourceManager.OnD3D11CreateDevice( pd3dDevice, pd3dImmediateContext ) ); V_RETURN( g_D3DSettingsDlg.OnD3D11CreateDevice( pd3dDevice ) ); g_pTxtHelper = new CDXUTTextHelper( pd3dDevice, pd3dImmediateContext, &g_DialogResourceManager, 15 ); static const XMVECTORF32 s_vecEye = { 105.0f, 14.0f, -3.0f, 0.f }; static const XMVECTORF32 s_vecLookAt = { 0.0f, -7.5f, 0.0f, 0.f }; XMFLOAT3 vMin = XMFLOAT3( -1000.0f, -1000.0f, -1000.0f ); XMFLOAT3 vMax = XMFLOAT3( 1000.0f, 1000.0f, 1000.0f ); g_ViewerCamera.SetViewParams( s_vecEye, s_vecLookAt ); g_ViewerCamera.SetRotateButtons( true, false, false); g_ViewerCamera.SetScalers( 0.01f, 10.0f ); g_ViewerCamera.SetDrag( true ); g_ViewerCamera.SetEnableYAxisMovement( true ); g_ViewerCamera.SetClipToBoundary( true, &vMin, &vMax ); g_ViewerCamera.FrameMove( 0 ); static const XMVECTORF32 s_lightEye = { -320.0f, 300.0f, -220.3f, 0.f }; g_LightCamera.SetViewParams( s_lightEye, g_XMZero ); g_LightCamera.SetRotateButtons( true, false, false ); g_LightCamera.SetScalers( 0.01f, 50.0f ); g_LightCamera.SetDrag( true ); g_LightCamera.SetEnableYAxisMovement( true ); g_LightCamera.SetClipToBoundary( true, &vMin, &vMax ); g_LightCamera.SetProjParams( XM_PI / 4, 1.0f, 0.1f , 1000.0f); g_LightCamera.FrameMove( 0 ); // Get the final sizes uint32_t width = DXUTGetDXGIBackBufferSurfaceDesc()->Width; uint32_t height = DXUTGetDXGIBackBufferSurfaceDesc()->Height; g_Scene.Init( pd3dDevice, pd3dImmediateContext, &g_MeshPowerPlant, width, height); return S_OK; }
//-------------------------------------------------------------------------------------- // When the user changes scene, recreate these components as they are scene // dependent. //-------------------------------------------------------------------------------------- HRESULT CreateD3DComponents(ID3D11Device* pd3dDevice) { HRESULT hr; ID3D11DeviceContext* pd3dImmediateContext = DXUTGetD3D11DeviceContext(); V_RETURN(g_DialogResourceManager.OnD3D11CreateDevice(pd3dDevice, pd3dImmediateContext)); V_RETURN(g_D3DSettingsDlg.OnD3D11CreateDevice(pd3dDevice)); g_pTxtHelper = new CDXUTTextHelper(pd3dDevice, pd3dImmediateContext, &g_DialogResourceManager, 15); XMVECTOR vecEye = XMVectorSet(100.0f, 5.0f, 5.0f, 0); XMVECTOR vecAt = XMVectorSet(0.0f, 0.0f, 0.0f, 0); XMFLOAT3 vMin = XMFLOAT3(-1000.0f, -1000.0f, -1000.0f); XMFLOAT3 vMax = XMFLOAT3(1000.0f, 1000.0f, 1000.0f); g_ViewerCamera.SetViewParams(vecEye, vecAt); g_ViewerCamera.SetRotateButtons(TRUE, FALSE, FALSE); g_ViewerCamera.SetScalers(0.01f, 10.0f); g_ViewerCamera.SetDrag(true); g_ViewerCamera.SetEnableYAxisMovement(true); g_ViewerCamera.SetClipToBoundary(TRUE, &vMin, &vMax); g_ViewerCamera.FrameMove(0); vecEye = XMVectorSet(-320.0f, 300.0f, -220.3f, 0); vecAt = XMVectorSet(0.0f, 0.0f, 0.0f, 0); g_LightCamera.SetViewParams(vecEye, vecAt); g_LightCamera.SetRotateButtons(TRUE, FALSE, FALSE); g_LightCamera.SetScalers(0.01f, 50.0f); g_LightCamera.SetDrag(true); g_LightCamera.SetEnableYAxisMovement(true); g_LightCamera.SetClipToBoundary(TRUE, &vMin, &vMax); g_LightCamera.SetProjParams(XM_PI / 4, 1.0f, 0.1f, 1000.0f); g_LightCamera.FrameMove(0); g_CascadedShadow.Init(pd3dDevice, pd3dImmediateContext, g_pSelectedMesh, &g_ViewerCamera, &g_LightCamera, &g_CascadeConfig); return S_OK; }
//-------------------------------------------------------------------------------------- // Handle updates to the scene. This is called regardless of which D3D API is used //-------------------------------------------------------------------------------------- void CALLBACK OnFrameMove(double fTime, float fElapsedTime, void* pUserContext) { SceneMesh *pSceneMesh = g_Scenes[g_CurrentSceneId].pMesh; g_UseOrbitalCamera = pSceneMesh && pSceneMesh->UseOrbitalCamera(); if (g_UseOrbitalCamera) { g_OrbitalCamera.FrameMove(fElapsedTime); } else { g_FirstPersonCamera.FrameMove(fElapsedTime); } }
//-------------------------------------------------------------------------------------- // Create any D3D11 resources that depend on the back buffer //-------------------------------------------------------------------------------------- HRESULT CALLBACK OnD3D11ResizedSwapChain( ID3D11Device* pd3dDevice, IDXGISwapChain* pSwapChain, const DXGI_SURFACE_DESC* pBackBufferSurfaceDesc, void* pUserContext ) { HRESULT hr; V_RETURN( g_DialogResourceManager.OnD3D11ResizedSwapChain( pd3dDevice, pBackBufferSurfaceDesc ) ); V_RETURN( g_D3DSettingsDlg.OnD3D11ResizedSwapChain( pd3dDevice, pBackBufferSurfaceDesc ) ); // Setup the camera's projection parameters float fAspectRatio = pBackBufferSurfaceDesc->Width / ( FLOAT )pBackBufferSurfaceDesc->Height; g_Camera.SetProjParams( D3DX_PI / 4, fAspectRatio, 2.0f, 4000.0f ); // g_Camera.SetWindow( pBackBufferSurfaceDesc->Width, pBackBufferSurfaceDesc->Height ); // g_Camera.SetButtonMasks( MOUSE_MIDDLE_BUTTON, MOUSE_WHEEL, MOUSE_LEFT_BUTTON ); D3DXVECTOR3 vMin = D3DXVECTOR3( -1000.0f, -1000.0f, -1000.0f ); D3DXVECTOR3 vMax = D3DXVECTOR3( 1000.0f, 1000.0f, 1000.0f ); g_Camera.SetRotateButtons(TRUE, FALSE, FALSE); g_Camera.SetScalers( 0.01f, 30.0f ); g_Camera.SetDrag( true ); g_Camera.SetEnableYAxisMovement( true ); g_Camera.SetClipToBoundary( TRUE, &vMin, &vMax ); g_Camera.FrameMove( 0 ); g_HUD.SetLocation( pBackBufferSurfaceDesc->Width - 170, 0 ); g_HUD.SetSize( 170, 170 ); g_SampleUI.SetLocation( pBackBufferSurfaceDesc->Width - 170, pBackBufferSurfaceDesc->Height - 300 ); g_SampleUI.SetSize( 170, 300 ); //Turn off backface culling D3D11_RASTERIZER_DESC rsDesc; ZeroMemory(&rsDesc,sizeof(D3D11_RASTERIZER_DESC) ); rsDesc.CullMode = D3D11_CULL_NONE; rsDesc.FillMode = D3D11_FILL_SOLID; //rsDesc.FillMode = D3D11_FILL_WIREFRAME; ID3D11RasterizerState *pRasterizerState = NULL; pd3dDevice->CreateRasterizerState(&rsDesc, &pRasterizerState); DXUTGetD3D11DeviceContext()->RSSetState(pRasterizerState); SAFE_RELEASE(pRasterizerState); return S_OK; }
//-------------------------------------------------------------------------------------- // Handle updates to the scene. This is called regardless of which D3D API is used //-------------------------------------------------------------------------------------- void CALLBACK OnFrameMove( double fTime, float fElapsedTime, void* pUserContext ) { // g_fElapsedTime = fElapsedTime; // Update the camera's position based on user input g_Camera.FrameMove( fElapsedTime ); //g_pCamera->Move(); // Updates particle system particleSystem.update( fElapsedTime ); // Changes the color of the model over time step += fElapsedTime * 0.5f; particleModel->setParam(PARAM_RED,0.6f + 0.4f * sin(step)); particleModel->setParam(PARAM_GREEN,0.6f + 0.4f * sin(step + D3DX_PI * 2.0f / 3.0f)); particleModel->setParam(PARAM_BLUE,0.6f + 0.4f * sin(step + D3DX_PI * 4.0f / 3.0f)); }
//-------------------------------------------------------------------------------------- // This callback function will be called once at the beginning of every frame. This is the // best location for your application to handle updates to the scene, but is not // intended to contain actual rendering calls, which should instead be placed in the // OnFrameRender callback. //-------------------------------------------------------------------------------------- void CALLBACK OnFrameMove( double fTime, float fElapsedTime, void* pUserContext ) { // Update the camera's position based on user input g_Camera.FrameMove( fElapsedTime ); }
//-------------------------------------------------------------------------------------- // Handle updates to the scene. This is called regardless of which D3D API is used //-------------------------------------------------------------------------------------- void CALLBACK OnFrameMove(double /*fTime*/, FLOAT fElapsedTime, void* /*pUserContext*/) { // Update the camera's position based on user input g_LightCamera.FrameMove(fElapsedTime); g_ViewerCamera.FrameMove(fElapsedTime); }