c++ - 如何用 glm 旋转相机视图?
问题描述
我试图旋转我的相机,目的是看到一个物体在我的凸轮周围旋转,我开发的问题是它不起作用。
所以我尝试使用 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;
}
我希望看到我的网格围绕相机旋转,但我只让凸轮围绕网格旋转。
解决方案
推荐阅读
- api - 即使在应用程序被杀死后 Flutter 后台处理
- flutter - Android、iOS 和 web 中的“A RenderFlex 底部溢出 21 个像素”
- c# - 在 DataGridRow 中绑定 UserControl 属性
- python-3.x - 未加载 Smtp 电子邮件
- reactjs - 滚动侦听器的 useEffect 清理
- vb.net - 当光标在区域内移动时,不需要的光标闪烁
- android - 当用户触摸下拉菜单时隐藏软键盘
- microservices - 在 saga 模式中,每个微服务的本地事务是否会立即影响数据库?
- jenkins - Mitmproxy 从 https 降级到 http
- sql - 按日期选择表现最好的销售代表