/** Draws the ocean */ void GOcean::Draw() { if(Patches.empty()) return; D3D11GraphicsEngine* engine = (D3D11GraphicsEngine *)Engine::GraphicsEngine; engine->SetDefaultStates(); FFTOceanSimulator->updateDisplacementMap(Engine::GAPI->GetTimeSeconds()); engine->DrawOcean(this); }
/** Updates the view */ void SV_GMeshInfoView::UpdateView() { if(IsHidden()) return; D3D11GraphicsEngine* g = (D3D11GraphicsEngine *)Engine::GraphicsEngine; D3DXMatrixPerspectiveFovLH(&ObjectProjMatrix, (float)D3DXToRadian(FOV), GetSize().height / GetSize().width, 0.01f, 10000.0f); D3DXMatrixTranspose(&ObjectProjMatrix, &ObjectProjMatrix); g->SetDefaultStates(); Engine::GAPI->GetRendererState()->RasterizerState.CullMode = GothicRasterizerStateInfo::CM_CULL_NONE; Engine::GAPI->GetRendererState()->RasterizerState.SetDirty(); D3DXMATRIX oldProj = Engine::GAPI->GetProjTransform(); // Set transforms Engine::GAPI->SetWorldTransform(ObjectWorldMatrix); Engine::GAPI->SetViewTransform(ObjectViewMatrix); Engine::GAPI->SetProjTransform(ObjectProjMatrix); // Set Viewport D3D11_VIEWPORT oldVP; UINT numVP = 1; g->GetContext()->RSGetViewports(&numVP, &oldVP); D3D11_VIEWPORT vp; vp.TopLeftX = 0; vp.TopLeftY = 0; vp.Width = GetSize().width; vp.Height = GetSize().height; vp.MinDepth = 0.0f; vp.MaxDepth = 1.0f; g->GetContext()->RSSetViewports(1, &vp); // Clear g->GetContext()->ClearRenderTargetView(RT->GetRenderTargetView(), (float *)&D3DXVECTOR4(0,0,0,0)); g->GetContext()->ClearDepthStencilView(DS->GetDepthStencilView(), D3D11_CLEAR_DEPTH, 1.0f, 0); // Bind RTV g->GetContext()->OMSetRenderTargets(1, RT->GetRenderTargetViewPtr(), DS->GetDepthStencilView()); // Setup shaders g->SetActiveVertexShader("VS_Ex"); g->SetActivePixelShader("PS_DiffuseAlphaTest"); switch(RenderMode) { case RM_Lit: g->SetActivePixelShader("PS_Preview_TexturedLit"); DrawMeshes(); break; case RM_Textured: g->SetActivePixelShader("PS_Preview_Textured"); DrawMeshes(); break; case RM_TexturedWireFrame: g->SetActivePixelShader("PS_Preview_Textured"); DrawMeshes(); // No break here, render wireframe right after case RM_Wireframe: g->SetActivePixelShader("PS_Preview_White"); Engine::GAPI->GetRendererState()->RasterizerState.Wireframe = true; Engine::GAPI->GetRendererState()->RasterizerState.SetDirty(); DrawMeshes(); Engine::GAPI->GetRendererState()->RasterizerState.Wireframe = false; Engine::GAPI->GetRendererState()->RasterizerState.SetDirty(); break; } // Reset viewport g->GetContext()->RSSetViewports(1, &oldVP); Engine::GAPI->SetProjTransform(oldProj); // Update panel Panel->SetD3D11TextureAsImage(RT->GetTexture(), INT2(RT->GetSizeX(), RT->GetSizeY())); }