【问题标题】:Efficient 3D rotation using vector of angles使用角度向量的高效 3D 旋转
【发布时间】:2019-09-18 11:23:14
【问题描述】:

我想知道是否有更好的方法来实现以下目标:

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 是角度向量,类似于 Unity 引擎执行游戏对象旋转的方式。

【问题讨论】:

标签: c++ opengl game-engine glm-math


【解决方案1】:

感谢@meowgoesthedog 这可以通过以下方式实现。

ModelMatrix = ModelMatrix * glm::eulerAngleXYZ(glm::radians(rotation.x), glm::radians(rotationVec.y), glm::radians(rotationVec.z));

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-18
    • 2020-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多