use*_*578 9 opengl transform glm-math
我想通过glm :: mat4(camera.rotationMatrix)转换glm :: vec3(camera.target).我尝试乘以这给我一个错误:错误:'originalTarget*((Camera*)this中的'operator*'不匹配 - > Camera :: rotationMatrix'.我想我不能乘以vec3*mat4.GLM有一些功能可以改变它吗?其他方式进行转换?
代码:
void Camera::Update(void)
{
// Aplicamos la rotacion sobre el target
glm::vec3 originalTarget = target;
glm::vec3 rotatedTarget = originalTarget * rotationMatrix;
// Aplicamos la rotacion sobre el Up
glm::vec3 originalUp = up;
glm::vec3 rotatedUp = originalUp * rotationMatrix;
// Establecemos las matrices de vista y proyeccion
view = lookAt(
position, //eye
rotatedTarget, //direction
rotatedUp //up
);
projection = perspective(
FOV,
(float) getParent()->getEngine()->GetCurrentWidth() / getParent()->getEngine()->GetCurrentWidth() ,
near_plane,
far_plane);
}
Run Code Online (Sandbox Code Playgroud)
Xym*_*ech 13
您想先将第4个元素a 转换glm::vec3
为glm::vec4
a 0
,然后将它们相乘.
glm::vec4 v(originalUp, 0);
Run Code Online (Sandbox Code Playgroud)