diff --git a/enginecustom/applicationclass.cpp b/enginecustom/applicationclass.cpp index 8ea3373..8ccc0fb 100644 --- a/enginecustom/applicationclass.cpp +++ b/enginecustom/applicationclass.cpp @@ -553,6 +553,25 @@ bool ApplicationClass::Frame(InputClass* Input) return false; } + // Obtenez la position de la souris + Input->GetMouseLocation(mouseX, mouseY); + + // Calculez la distance parcourue par la souris depuis le dernier frame + float deltaX = mouseX - m_previousMouseX; + float deltaY = mouseY - m_previousMouseY; + + // Mettez à jour les positions précédentes de la souris + m_previousMouseX = mouseX; + m_previousMouseY = mouseY; + + // Utilisez deltaX et deltaY pour ajuster la rotation de la caméra + float rotationSpeed = 0.1f; // Ajustez cette valeur pour changer la vitesse de rotation + float rotationX = m_Camera->GetRotation().x + deltaY * rotationSpeed; + float rotationY = m_Camera->GetRotation().y + deltaX * rotationSpeed; + + // Mettez à jour la rotation de la caméra + m_Camera->SetRotation(rotationX, rotationY, 0.0f); + // Update the system stats. m_Timer->Frame(); @@ -742,6 +761,25 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z) return false; } + scaleMatrix = XMMatrixScaling(1.0f, 1.0f, 1.0f); // Build the scaling matrix. + rotateMatrix = XMMatrixRotationY(0); // Build the rotation matrix. + translateMatrix = XMMatrixTranslation(0, 0.0f, -10.0f); // Build the translation matrix. + + // Multiply the scale, rotation, and translation matrices together to create the final world transformation matrix. + srMatrix = XMMatrixMultiply(scaleMatrix, rotateMatrix); + worldMatrix = XMMatrixMultiply(srMatrix, translateMatrix); + + // Render the model using the multitexture shader. + m_Model->Render(m_Direct3D->GetDeviceContext()); + + //Normal Mapping + result = m_NormalMapShader->Render(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, + m_Model->GetTexture(0), m_Model->GetTexture(1), m_Light->GetDirection(), m_Light->GetDiffuseColor()); + if (!result) + { + return false; + } + // Enable the Z buffer and disable alpha blending now that 2D rendering is complete. m_Direct3D->TurnZBufferOn(); m_Direct3D->DisableAlphaBlending(); diff --git a/enginecustom/applicationclass.h b/enginecustom/applicationclass.h index e02b162..373660c 100644 --- a/enginecustom/applicationclass.h +++ b/enginecustom/applicationclass.h @@ -86,6 +86,8 @@ private: ModelListClass* m_ModelList; PositionClass* m_Position; FrustumClass* m_Frustum; + float m_previousMouseX; + float m_previousMouseY; }; #endif diff --git a/enginecustom/inputclass.cpp b/enginecustom/inputclass.cpp index d220be9..c69a6d5 100644 --- a/enginecustom/inputclass.cpp +++ b/enginecustom/inputclass.cpp @@ -234,12 +234,12 @@ void InputClass::ProcessInput() m_mouseX += m_mouseState.lX; m_mouseY += m_mouseState.lY; - // Ensure the mouse location doesn't exceed the screen width or height. - if (m_mouseX < 0) { m_mouseX = 0; } - if (m_mouseY < 0) { m_mouseY = 0; } + //// Ensure the mouse location doesn't exceed the screen width or height. + //if (m_mouseX < 0) { m_mouseX = 0; } + //if (m_mouseY < 0) { m_mouseY = 0; } - if (m_mouseX > m_screenWidth) { m_mouseX = m_screenWidth; } - if (m_mouseY > m_screenHeight) { m_mouseY = m_screenHeight; } + //if (m_mouseX > m_screenWidth) { m_mouseX = m_screenWidth; } + //if (m_mouseY > m_screenHeight) { m_mouseY = m_screenHeight; } return; }