Hey everyone, im trying to get a 2d plane to face the camera (Billboards for particles) but im having some problems.
Im currently trying to construct a quaternion using angle axis to face the object to the camera but either the object is not completely facing the camera or the object flickers a lot
currently I am constructing the angle and axis with a vector from the object to the camera and the direction vector of the object (0,0,1)
glm::vec3 tocam = glm::normalize(camerapos - pos); float angle = std::acos(glm::dot(newdirection, tocam)); float a = fabs(glm::degrees(angle)); glm::vec3 axis = glm::cross(newdirection, tocam); currentrotation = glm::angleAxis(angle, axis); newdirection = currentrotation * direction; glm::mat4 RotationMatrix = glm::toMat4(currentrotation); glm::mat4 translationmatrix = glm::translate(glm::mat4(1.0f), pos); modelMatrix = translationmatrix * RotationMatrix;
Is my understanding of this incorrect? i very much believe that the angle calculation is correct but that im doing something wrong with the axis.
Thanks in advance for any help and feel free to explain in detail what im doing wrong (more i can learn the better) .
No comments:
Post a Comment