glm:无法使用 quaternion.hpp 中的 toMat4

glm: cannot use toMat4 from quaternion.hpp

我在尝试使用 glm 时遇到错误。 glm 工作的一些功能。但是我不能使用所有重载和四元数相关的东西。

    1>src\foo.cpp(369): error C2039: 'toMat4': is not a member of 'glm'
    1>          d:\..\glm\glm\gtc\type_ptr.inl(35): note: see declaration of 'glm'
    1>src\foo.cpp(369): error C3861: 'toMat4': identifier not found

有了这个:

    #include <glm/glm.hpp> //vec3, vec4, ivec4, mat4
    #include <glm/common.hpp> //vec3, vec4, ivec4, mat4
    #include <glm/gtc/matrix_transform.hpp>
    #include <glm/gtc/type_ptr.hpp>
    #include <glm/gtc/quaternion.hpp>

    glm::mat4 t1 = glm::translate(glm::mat4x4(), -piv);
    glm::mat4 rot = glm::toMat4(trafo.orientation);
    glm::mat4 t2 = glm::translate(glm::mat4x4(), piv);

在文档中它被列在 glm::gtx 命名空间中。看这里:

https://glm.g-truc.net/0.9.0/api/a00184.html

但您也可以使用:

detail::tmat4x4<T> glm::gtc::quaternion::mat4_cast  (   detail::tquat< T > const &      x   )   

你已经收录了。看这里:

https://glm.g-truc.net/0.9.0/api/a00135.html#ae2d14d52f9fef3da00cf867f9e2e3dfa