//-------------------------------------------------------------------------------- BOOL CMFCwithD3D11Doc::OnNewDocument() { if (!CDocument::OnNewDocument()) return FALSE; // TODO: add reinitialization code here // (SDI documents will reuse this document) pScene = new Glyph3::Scene(); pActor = new Glyph3::Actor(); Glyph3::GeometryPtr pGeometry = Glyph3::GeometryLoaderDX11::loadMS3DFile2( L"box.ms3d" ); pGeometry->LoadToBuffers(); pGeometry->SetPrimitiveType( D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST ); pActor->GetBody()->Visual.SetGeometry( pGeometry ); pActor->GetBody()->Visual.SetMaterial( Glyph3::MaterialGeneratorDX11::GeneratePhong( *Glyph3::RendererDX11::Get() ) ); pActor->GetBody()->Controllers.Attach( new Glyph3::RotationController<Glyph3::Entity3D>( Glyph3::Vector3f::Random(), 1.0f ) ); pScene->AddActor( pActor ); pScene->Update( 0.0f ); return TRUE; }
BOOL CStudy_MFCDoc::OnNewDocument() { if (!CDocument::OnNewDocument()) return FALSE; // TODO: add reinitialization code here // (SDI documents will reuse this document) m_fontData.fontColor = RGB(0, 0, 0); m_fontData.fontName = _T("Arial"); m_fontData.minFontSize = 12; m_fontData.maxFontSize = 24; m_fontData.magnifyLevel = 2; m_fontData.sampleText = _T("The quick brown fox jumps over the lazy dog. 0123456789"); pScene = new Glyph3::Scene(); pActor = new Glyph3::Actor(); Glyph3::GeometryPtr pGeometry = Glyph3::GeometryPtr(new Glyph3::GeometryDX11()); Glyph3::GeometryGeneratorDX11::GenerateFullScreenQuad(pGeometry); pGeometry->LoadToBuffers(); // Set up shaders and material Glyph3::MaterialPtr pMaterial = Glyph3::MaterialPtr(new Glyph3::MaterialDX11()); pDiscretePathEffect = new Glyph3::RenderEffectDX11(); pDiscretePathEffect->SetVertexShader(Glyph3::RendererDX11::Get()->LoadShader(Glyph3::VERTEX_SHADER, std::wstring(L"EuclideanPath.hlsl"), std::wstring(L"VSMAIN"), std::wstring(L"vs_5_0"))); pDiscretePathEffect->SetPixelShader(Glyph3::RendererDX11::Get()->LoadShader(Glyph3::PIXEL_SHADER, std::wstring(L"EuclideanPath.hlsl"), std::wstring(L"PS_DISCRETE_PATH_FREEMAN"), std::wstring(L"ps_5_0"))); pFullConnectedDiscretePathEffect = new Glyph3::RenderEffectDX11(); pFullConnectedDiscretePathEffect->SetVertexShader(Glyph3::RendererDX11::Get()->LoadShader(Glyph3::VERTEX_SHADER, std::wstring(L"EuclideanPath.hlsl"), std::wstring(L"VSMAIN"), std::wstring(L"vs_5_0"))); pFullConnectedDiscretePathEffect->SetPixelShader(Glyph3::RendererDX11::Get()->LoadShader(Glyph3::PIXEL_SHADER, std::wstring(L"EuclideanPath.hlsl"), std::wstring(L"PS_ADV_FULL_CONNECTED_POINT"), std::wstring(L"ps_5_0"))); pEuclideanPathEffect = new Glyph3::RenderEffectDX11(); pEuclideanPathEffect->SetVertexShader(Glyph3::RendererDX11::Get()->LoadShader(Glyph3::VERTEX_SHADER, std::wstring(L"EuclideanPath.hlsl"), std::wstring(L"VSMAIN"), std::wstring(L"vs_5_0"))); pEuclideanPathEffect->SetPixelShader(Glyph3::RendererDX11::Get()->LoadShader(Glyph3::PIXEL_SHADER, std::wstring(L"EuclideanPath.hlsl"), std::wstring(L"PS_EUCLIDEAN_PATH_FREEMAN"), std::wstring(L"ps_5_0"))); pMagnifyPathEffect = new Glyph3::RenderEffectDX11(); pMagnifyPathEffect->SetVertexShader(Glyph3::RendererDX11::Get()->LoadShader(Glyph3::VERTEX_SHADER, std::wstring(L"EuclideanPath.hlsl"), std::wstring(L"VSMAIN"), std::wstring(L"vs_5_0"))); pMagnifyPathEffect->SetPixelShader(Glyph3::RendererDX11::Get()->LoadShader(Glyph3::PIXEL_SHADER, std::wstring(L"EuclideanPath.hlsl"), std::wstring(L"PS_MAGNIFY"), std::wstring(L"ps_5_0"))); pFinalEffect = new Glyph3::RenderEffectDX11(); pFinalEffect->SetVertexShader(Glyph3::RendererDX11::Get()->LoadShader(Glyph3::VERTEX_SHADER, std::wstring(L"EuclideanPath.hlsl"), std::wstring(L"VSMAIN"), std::wstring(L"vs_5_0"))); pFinalEffect->SetPixelShader(Glyph3::RendererDX11::Get()->LoadShader(Glyph3::PIXEL_SHADER, std::wstring(L"EuclideanPath.hlsl"), std::wstring(L"PS_FINAL"), std::wstring(L"ps_5_0"))); pMaterial->Params[Glyph3::VT_PERSPECTIVE].bRender = true; pMaterial->Params[Glyph3::VT_PERSPECTIVE].pEffect = pDiscretePathEffect; pMaterial->Params[Glyph3::VT_LINEAR_DEPTH_NORMAL].bRender = true; pMaterial->Params[Glyph3::VT_LINEAR_DEPTH_NORMAL].pEffect = pFullConnectedDiscretePathEffect; pMaterial->Params[Glyph3::VT_GBUFFER].bRender = true; pMaterial->Params[Glyph3::VT_GBUFFER].pEffect = pEuclideanPathEffect; pMaterial->Params[Glyph3::VT_LIGHTS].bRender = true; pMaterial->Params[Glyph3::VT_LIGHTS].pEffect = pMagnifyPathEffect; pMaterial->Params[Glyph3::VT_FINALPASS].bRender = true; pMaterial->Params[Glyph3::VT_FINALPASS].pEffect = pFinalEffect; // Create the scene; pActor->GetBody()->Visual.SetGeometry(pGeometry); pActor->GetBody()->Visual.SetMaterial(pMaterial); pScene->AddActor(pActor); pScene->Update(0.0f); return TRUE; }