2013-09-26 5 views
4

그래서 내 객체의 방향을 glm :: fquat에 저장하고이를 사용하여 내 모델을 회전시키고 싶습니다. 내가 어떻게 그럴 수 있니? glm 쿼터니언을 회전 행렬로 변환하고 OpenGL과 함께 사용

난이 시도 :

glPushMatrix(); 
    glTranslatef(position.x, position.y, position.z); 
    glMultMatrixf(glm::mat4_cast(orientation)); 
    glCallList(modelID); 
glPopMatrix(); 

을하지만 난이 오류가있어 :

error: cannot convert 'glm::detail::tmat4x4<float>' to 'const GLfloat* {aka const float*}' for argument '1' to 'void glMultMatrixf(const GLfloat*)'| 

메신저 분명히을 할 수있는 올바른 방법이 뭐죠 그래서 뭔가 잘못하고 있습니까?

답변

3

GLM은 mat4GLfloat*으로 자동 변환하지 않으므로 you have to help it along a bit입니다.

이 시도 :

이것은 또한 수도
#include <glm/gtc/type_ptr.hpp> 
glMultMatrixf(glm::value_ptr(glm::mat4_cast(orientation))); 

작업 :

glMultMatrixf(&glm::mat4_cast(orientation)[0][0]); 
+0

덕분에 많이! 이 두 가지 방법 모두 작동합니다. 캔트는 내가 그걸 이해한다고. 그러나 그것은 효과적이다. 그게 전부 중요 :) – user2820068