c++ - Camera is tilting when trying to rotate quaternion - Stack Overflow

时间: 2025-01-06 admin 业界

I'm trying to write a simple camera controller for my c++ project that uses glm and quaternions. The thing is that the camera keeps tilting after a little bit of looking around. Here is an image

And here is the code for the camera rotating:

if (MouseOffset.x)
{
    m_Parent->Transform.Rotation = glm::normalize(m_Parent->Transform.Rotation * glm::angleAxis(MouseOffset.x * m_Sensitivity * static_cast<float>(DeltaTime), YAxis));
}

if (MouseOffset.y)
{
    m_Parent->Transform.Rotation = glm::normalize(m_Parent->Transform.Rotation * glm::angleAxis(MouseOffset.y * m_Sensitivity * static_cast<float>(DeltaTime), XAxis));
}
最新文章