GateDemo::GateDemo(HINSTANCE hInstance, std::string winCaption, D3DDEVTYPE devType, DWORD requestedVP) : D3DApp(hInstance, winCaption, devType, requestedVP) { if(!checkDeviceCaps()) { MessageBox(0, "checkDeviceCaps() Failed", 0, 0); PostQuitMessage(0); } mGfxStats = new GfxStats(); mCameraRadius = 6.0f; mCameraRotationY = 1.2 * D3DX_PI; mCameraHeight = 3.0f; mLightVecW = D3DXVECTOR3(0.0, 0.707f, -0.707f); mDiffuseLight = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f); mAmbientLight = D3DXCOLOR(0.6f, 0.6f, 0.6f, 1.0f); mSpecularLight = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f); mGroundMtrl.ambient = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f); mGroundMtrl.diffuse = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f); mGroundMtrl.spec = D3DXCOLOR(0.4f, 0.4f, 0.4f, 1.0f); mGroundMtrl.specPower = 8.0f; mGateMtrl.ambient = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f); mGateMtrl.diffuse = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f); mGateMtrl.spec = D3DXCOLOR(0.0f, 0.0f, 0.0f, 1.0f); mGateMtrl.specPower = 8.0f; D3DXMatrixIdentity(&mGroundWorld); D3DXMatrixIdentity(&mGateWorld); HR(D3DXCreateTextureFromFile(gd3dDevice, "ground0.dds", &mGroundTex)); HR(D3DXCreateTextureFromFile(gd3dDevice, "gatea.dds", &mGateTex)); buildGridGeometry(); buildGateGeometry(); mGfxStats->addVertices(mNumGridVertices); mGfxStats->addTriangles(mNumGridTriangles); // Add gate quad vertices. mGfxStats->addVertices(4); mGfxStats->addTriangles(2); buildFX(); onResetDevice(); InitAllVertexDeclarations(); }
MultiTexDemo::MultiTexDemo(HINSTANCE hInstance, std::string winCaption, D3DDEVTYPE devType, DWORD requestedVP) : D3DApp(hInstance, winCaption, devType, requestedVP) { if(!checkDeviceCaps()) { MessageBox(0, "checkDeviceCaps() Failed", 0, 0); PostQuitMessage(0); } mGfxStats = new GfxStats(); mCameraRadius = 6.0f; mCameraRotationY = 1.2 * D3DX_PI; mCameraHeight = 3.0f; mLightVecW = D3DXVECTOR3(0.0, 0.707f, -0.707f); mDiffuseMtrl = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f); mDiffuseLight = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f); mAmbientMtrl = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f); mAmbientLight = D3DXCOLOR(0.6f, 0.6f, 0.6f, 1.0f); mSpecularMtrl = D3DXCOLOR(0.4f, 0.4f, 0.4f, 1.0f); mSpecularLight = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f); mSpecularPower = 8.0f; D3DXMatrixIdentity(&mWorld); // Load textures from file. HR(D3DXCreateTextureFromFile(gd3dDevice, "grass0.dds", &mTex0)); HR(D3DXCreateTextureFromFile(gd3dDevice, "stone2.dds", &mTex1)); HR(D3DXCreateTextureFromFile(gd3dDevice, "ground0.dds", &mTex2)); HR(D3DXCreateTextureFromFile(gd3dDevice, "blendmap.jpg", &mBlendMap)); buildGridGeometry(); mGfxStats->addVertices(mNumGridVertices); mGfxStats->addTriangles(mNumGridTriangles); buildFX(); onResetDevice(); InitAllVertexDeclarations(); }
EngineMain::EngineMain(HINSTANCE hInstance, std::wstring winCaption, D3DDEVTYPE devType, DWORD requestedVP) : D3DApp(hInstance, winCaption, devType, requestedVP) { if(!checkDeviceCaps()) { MessageBox(0, L"checkDeviceCaps() Failed", 0, 0); PostQuitMessage(0); } Shaders::InitAll(); InitAllVertexDeclarations(); m_GfxStats = new GfxStats(); m_DirLight.Direction = D3DXVECTOR3(0.0f, 1.0f, 2.0f); D3DXVec3Normalize(&m_DirLight.Direction, &m_DirLight.Direction); m_DirLight.Ambient = D3DXCOLOR(0.5f, 0.5f, 0.5f, 1.0f); m_DirLight.Diffuse = D3DXCOLOR(0.8f, 0.8f, 0.8f, 1.0f); m_DirLight.Specular = D3DXCOLOR(0.8f, 0.8f, 0.8f, 1.0f); camera.SetPosition(D3DXVECTOR3(0.0f, 0.0f, -10.0f)); camera.SetTarget(D3DXVECTOR3(0.0f, 3.0f, 0.0f)); camera.SetRotation(D3DXVECTOR3(0.0f, 1.0f, 0.0f)); dwarf = new Model(L"dwarf.x"); skull = new Model(L"skullocc.x"); tiny = new Model(L"tiny.x"); m_GfxStats->addVertices(skull->m_Model->GetNumVertices()); m_GfxStats->addTriangles(skull->m_Model->GetNumFaces()); m_GfxStats->addVertices(dwarf->m_Model->GetNumVertices()); m_GfxStats->addTriangles(dwarf->m_Model->GetNumFaces()); m_GfxStats->addVertices(tiny->m_Model->GetNumVertices()); m_GfxStats->addTriangles(tiny->m_Model->GetNumFaces()); skull->InitModel(D3DXVECTOR3(-4.0f, 3.0f, 100.0f), D3DXVECTOR3(0.0f, 0.0f, 1.0f), 0.0f); skull->Scale(0.5f); dwarf->InitModel(D3DXVECTOR3(0.0f, 3.0f, -10.0f), D3DXVECTOR3(0.0f, 0.0f, 1.0f), 0.0f); dwarf->Scale(1.0f); tiny->InitModel(D3DXVECTOR3(0.0f, 3.0f, -10.0f), D3DXVECTOR3(0.0f, 0.0f, 1.0f), 0.0f); tiny->Scale(0.01f); #pragma region Grid mLightVecW = D3DXVECTOR3(0.0, 0.707f, -0.707f); mDiffuseMtrl = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f); mDiffuseLight = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f); mAmbientMtrl = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f); mAmbientLight = D3DXCOLOR(0.6f, 0.6f, 0.6f, 1.0f); mSpecularMtrl = D3DXCOLOR(0.4f, 0.4f, 0.4f, 1.0f); mSpecularLight = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f); mSpecularPower = 8.0f; std::wstring groundTex = utf8ToUTF16(std::string("../Render/models/ground0.dds")); HR(D3DXCreateTextureFromFile(g_d3dDevice, groundTex.c_str(), &mGroundTex)); buildFX(); buildGridGeometry(); #pragma endregion onResetDevice(); }