我想知道是否有更好的方法来实现以下目标:
ModelMatrix = glm::rotate(ModelMatrix, glm::radians(rotationVec.x), glm::vec3(1.0f, 0.0f, 0.0f));
ModelMatrix = glm::rotate(ModelMatrix, glm::radians(rotationVec.y), glm::vec3(0.0f, 1.0f, 0.0f));
ModelMatrix = glm::rotate(ModelMatrix, glm::radians(rotationVec.z), glm::vec3(0.0f, 0.0f, 1.0f));
是否有更有效的方法可以通过单个函数调用来实现相同的计算?
rotationVec
是一个角度 vector ,类似于 Unity 引擎如何进行游戏对象旋转。
最佳答案
感谢@meowgoesthedog 这可以通过以下方式实现。
ModelMatrix = ModelMatrix * glm::eulerAngleXYZ(glm::radians(rotation.x), glm::radians(rotationVec.y), glm::radians(rotationVec.z));
关于c++ - 使用角度 vector 进行高效 3D 旋转,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57991636/