void DXBox::DrawBox(ID3D11DeviceContext* md3dImmediateContext, ID3DX11EffectTechnique* activeTech, DX11Camera mCam) { //Perform matrix operations for stored scale and position XMMATRIX mBoxRotation = XMMatrixRotationRollPitchYaw(mRotation.GetZ(), mRotation.GetY(), mRotation.GetX()); XMMATRIX mBoxScale = XMMatrixScaling(mScale.GetX(), mScale.GetY(), mScale.GetZ()); XMMATRIX mBoxPosition = XMMatrixTranslation(mPosition.GetX(), mPosition.GetY(), mPosition.GetZ()); XMStoreFloat4x4(&mBoxWorld, XMMatrixMultiply(XMMatrixMultiply(mBoxRotation,mBoxScale), mBoxPosition)); UINT stride = sizeof(Vertex::Basic32); UINT offset = 0; md3dImmediateContext->IASetVertexBuffers(0, 1, &mBoxVB, &stride, &offset); md3dImmediateContext->IASetIndexBuffer(mBoxIB, DXGI_FORMAT_R32_UINT, 0); // Draw the box. XMMATRIX world = XMLoadFloat4x4(&mBoxWorld); XMMATRIX worldInvTranspose = MathHelper::InverseTranspose(world); XMMATRIX worldViewProj = world * mCam.View() * mCam.Proj(); Effects::BasicFX->SetWorld(world); Effects::BasicFX->SetWorldInvTranspose(worldInvTranspose); Effects::BasicFX->SetWorldViewProj(worldViewProj); Effects::BasicFX->SetTexTransform(XMLoadFloat4x4(&mTexTransform)); Effects::BasicFX->SetMaterial(mBoxMat); Effects::BasicFX->SetDiffuseMap(boxDiffuseTexture); activeTech->GetPassByIndex(0)->Apply(0, md3dImmediateContext); md3dImmediateContext->DrawIndexed(mBoxIndexCount, mBoxIndexOffset, mBoxVertexOffset); }
void ZombieForce::DrawScene() { md3dImmediateContext->ClearRenderTargetView(mRenderTargetView, reinterpret_cast<const float*>(&Colors::Blue)); md3dImmediateContext->ClearDepthStencilView(mDepthStencilView, D3D11_CLEAR_DEPTH|D3D11_CLEAR_STENCIL, 1.0f, 0); md3dImmediateContext->IASetInputLayout(InputLayouts::Basic32); md3dImmediateContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); UINT stride = sizeof(Vertex::Basic32); UINT offset = 0; mCam.UpdateViewMatrix(); XMMATRIX view = mCam.View(); XMMATRIX proj = mCam.Proj(); XMMATRIX viewProj = mCam.ViewProj(); // Set per frame constants. Effects::BillboardFX->SetDirLights(mDirLights); Effects::BillboardFX->SetEyePosW(mCam.GetPosition()); Effects::BillboardFX->SetCubeMap(mSky->CubeMapSRV()); //ID3DX11EffectTechnique* activeTech = Effects::BasicFX->Light2TexTech; ID3DX11EffectTechnique* activeTech = Effects::BillboardFX->Light2TexTech; D3DX11_TECHNIQUE_DESC techDesc; activeTech->GetDesc( &techDesc ); for(UINT p = 0; p < techDesc.Passes; ++p) { pyramid->DrawPyramid(md3dImmediateContext,activeTech, mCam); //myFirstSphere->DrawSphere(md3dImmediateContext,activeTech, mCam); myFirstPlane->DrawPlane(md3dImmediateContext,activeTech, mCam); //myFirstGeoSphere->DrawGeoSphere(md3dImmediateContext,activeTech, mCam); //myFirstCylinder->DrawCylinder(md3dImmediateContext,activeTech, mCam); for(unsigned int i = 0; i < spheres.size(); ++i) { spheres[i]->DrawSphere(md3dImmediateContext,activeTech, mCam); } for(unsigned int i = 0; i < boxes.size(); ++i) { boxes[i]->DrawBox(md3dImmediateContext,activeTech, mCam); } CMESHMANAGER->Render(md3dImmediateContext, activeTech, mCam); } mSky->Draw(md3dImmediateContext, mCam); // restore default states, as the SkyFX changes them in the effect file. md3dImmediateContext->RSSetState(0); md3dImmediateContext->OMSetDepthStencilState(0, 0); HR(mSwapChain->Present(0, 0)); }