tests mouvements de la camera
rotation de la camera, peut etre amelioree ?????
This commit is contained in:
parent
41fdb55b04
commit
5cce3b4905
@ -553,6 +553,25 @@ bool ApplicationClass::Frame(InputClass* Input)
|
|||||||
return false;
|
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.
|
// Update the system stats.
|
||||||
m_Timer->Frame();
|
m_Timer->Frame();
|
||||||
|
|
||||||
@ -742,6 +761,25 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z)
|
|||||||
return false;
|
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.
|
// Enable the Z buffer and disable alpha blending now that 2D rendering is complete.
|
||||||
m_Direct3D->TurnZBufferOn();
|
m_Direct3D->TurnZBufferOn();
|
||||||
m_Direct3D->DisableAlphaBlending();
|
m_Direct3D->DisableAlphaBlending();
|
||||||
|
@ -86,6 +86,8 @@ private:
|
|||||||
ModelListClass* m_ModelList;
|
ModelListClass* m_ModelList;
|
||||||
PositionClass* m_Position;
|
PositionClass* m_Position;
|
||||||
FrustumClass* m_Frustum;
|
FrustumClass* m_Frustum;
|
||||||
|
float m_previousMouseX;
|
||||||
|
float m_previousMouseY;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -234,12 +234,12 @@ void InputClass::ProcessInput()
|
|||||||
m_mouseX += m_mouseState.lX;
|
m_mouseX += m_mouseState.lX;
|
||||||
m_mouseY += m_mouseState.lY;
|
m_mouseY += m_mouseState.lY;
|
||||||
|
|
||||||
// Ensure the mouse location doesn't exceed the screen width or height.
|
//// Ensure the mouse location doesn't exceed the screen width or height.
|
||||||
if (m_mouseX < 0) { m_mouseX = 0; }
|
//if (m_mouseX < 0) { m_mouseX = 0; }
|
||||||
if (m_mouseY < 0) { m_mouseY = 0; }
|
//if (m_mouseY < 0) { m_mouseY = 0; }
|
||||||
|
|
||||||
if (m_mouseX > m_screenWidth) { m_mouseX = m_screenWidth; }
|
//if (m_mouseX > m_screenWidth) { m_mouseX = m_screenWidth; }
|
||||||
if (m_mouseY > m_screenHeight) { m_mouseY = m_screenHeight; }
|
//if (m_mouseY > m_screenHeight) { m_mouseY = m_screenHeight; }
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user