diff --git a/enginecustom/applicationclass.cpp b/enginecustom/applicationclass.cpp index 86631e4..f4e9acc 100644 --- a/enginecustom/applicationclass.cpp +++ b/enginecustom/applicationclass.cpp @@ -26,7 +26,6 @@ bool ApplicationClass::Initialize(int screenWidth, int screenHeight, HWND hwnd) char textureFilename[128]; bool result; - // Create the Direct3D object. m_Direct3D = new D3DClass; if (!m_Direct3D) @@ -49,7 +48,7 @@ bool ApplicationClass::Initialize(int screenWidth, int screenHeight, HWND hwnd) } // Set the initial position of the camera. - m_Camera->SetPosition(0.0f, 0.0f, -5.0f); + m_Camera->SetPosition(0.0f, 0.0f, -10.0f); m_Camera->SetRotation(0.0f, 0.0f, 10.0f); // Set the file name of the model. @@ -156,7 +155,7 @@ bool ApplicationClass::Frame() bool ApplicationClass::Render(float rotation) { - XMMATRIX worldMatrix, viewMatrix, projectionMatrix; + XMMATRIX worldMatrix, viewMatrix, projectionMatrix, rotateMatrix, translateMatrix, scaleMatrix, srMatrix; bool result; @@ -170,19 +169,37 @@ bool ApplicationClass::Render(float rotation) m_Direct3D->GetWorldMatrix(worldMatrix); m_Camera->GetViewMatrix(viewMatrix); m_Direct3D->GetProjectionMatrix(projectionMatrix); - // Rotate the world matrix by the rotation value so that the triangle will spin. - worldMatrix = XMMatrixRotationY(rotation); - // Put the model vertex and index buffers on the graphics pipeline to prepare them for drawing. + // Render the first cube + scaleMatrix = XMMatrixScaling(0.5f, 0.5f, 0.5f); + rotateMatrix = XMMatrixRotationX(rotation); + translateMatrix = XMMatrixTranslation(-2.0f, 0.0f, 0.0f); + srMatrix = XMMatrixMultiply(scaleMatrix, rotateMatrix); + worldMatrix = XMMatrixMultiply(srMatrix, translateMatrix); + m_Model->Render(m_Direct3D->GetDeviceContext()); - - // Render the model using the light shader. result = m_LightShader->Render(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, m_Model->GetTexture(), m_Light->GetDirection(), m_Light->GetDiffuseColor()); if (!result) { return false; } + + // Render the second cube + scaleMatrix = XMMatrixScaling(1.5f, 1.5f, 1.5f); + rotateMatrix = XMMatrixRotationY(rotation); + translateMatrix = XMMatrixTranslation(2.0f, 0.0f, 0.0f); + srMatrix = XMMatrixMultiply(scaleMatrix, rotateMatrix); + worldMatrix = XMMatrixMultiply(srMatrix, translateMatrix); + + m_Model->Render(m_Direct3D->GetDeviceContext()); + result = m_LightShader->Render(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, m_Model->GetTexture(), + m_Light->GetDirection(), m_Light->GetDiffuseColor()); + if (!result) + { + return false; + } + // Present the rendered scene to the screen. m_Direct3D->EndScene(); @@ -202,4 +219,4 @@ int ApplicationClass::GetScreenWidth() const int ApplicationClass::GetScreenHeight() const { return GetSystemMetrics(SM_CYSCREEN); -} \ No newline at end of file +}