如何用glm旋转摄像机视图?

问题描述 投票:2回答:1

我正在尝试旋转我的相机,目的是看到一个物体围绕我的凸轮旋转,旋转矩阵,我发现问题是它不起作用。

所以我尝试使用glm :: rotation矩阵并输入值

m_View = glm::rotate(m_View, a * glm::radians(180.0f), glm::vec3(0.0f, 1.0f, 0.0f))

但它也不起作用:

void CCam::setView()
{

    Front = glm::normalize(Eye - At);
    Right = glm::normalize(glm::cross(Up, Front));
    up = glm::cross(Front, Right); // Up Verdadero


    m_View = glm::lookAt(
        Eye,    // Camera Position
        (Eye + Front),      // Where the camera looks
        up      // This is another way to say camera is not rotated 
    );


    newAt = glm::vec4(At, 1.0f);


    //m_View = m_View * GLMatrixRotationY(a);
    m_View = glm::rotate(m_View, a * glm::radians(180.0f), glm::vec3(0.0f, 1.0f, 0.0f));
}

glm::mat4 CCam::GLMatrixRotationX(float Angle)
{
    matrizRotacionX = glm::mat4(
        1, 0, 0, 0,
        0, cos(Angle), -sin(Angle), 0,
        0, sin(Angle), cos(Angle), 0,
        0, 0, 0, 1
    );

    return matrizRotacionX;
}

我希望看到我的网状物在相机周围旋转,但我只让凸轮围绕网状物旋转。

c++ opengl glm-math
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.