glm-math

Rotate and translate object in local and global orientation using glm

假装没事ソ 提交于 2019-11-26 11:25:32
问题 i am trying to implement functions, where i can rotate/ translate an object in local or global orientation, like in 3D modeling software, using glm. Something like this: void Rotate(float x, float y, float z, bool localOrientation); but I dont know how to get it working. Local rotation rotation should just be something like this(?): m_Orientation *= glm::rotate(x, glm::vec3(1,0,0); m_Orientation *= glm::rotate(y, glm::vec3(0,1,0); m_Orientation *= glm::rotate(z, glm::vec3(0,0,1); // (m

Transform the modelMatrix

谁都会走 提交于 2019-11-26 02:25:33
问题 It is easy to set the ViewMatrix with glm: glm::lookAt(Position, Direction, UpVector); but if I try to use the funktion with the modelMatrix, I\'ll get comfusing values (the Model is not in the correct position and also the rotation looks wrong). I just want to set an object the same way than setting the camera. Can I use the lookAt funktion and make some changes afterwards? Or does I have to program an own funtion for that? And if so, how? I fixed the position with this: m_Orientation = glm:

Normal mapping gone horribly wrong

末鹿安然 提交于 2019-11-26 01:02:31
问题 I tried to implement normal mapping in my opengl application but I can\'t get it to work. This is the diffuse map (which I add a brown color to) and this is the normal map. In order to get the tangent and bitangent (in other places called binormals?) vectors, I run this function for every triangle in my mesh: void getTangent(const glm::vec3 &v0, const glm::vec3 &v1, const glm::vec3 &v2, const glm::vec2 &uv0, const glm::vec2 &uv1, const glm::vec2 &uv2, std::vector<glm::vec3> &vTangents, std: