I'm trying to compute a matrix to have object always facing the camera. For the moment, my result look pretty good, the problem is that my original billboard scale isn't preserved (Every billboard have a size of 1/1).
Here is what I've done using this post:
glm::vec3 look = glm::normalize(camera->getPosition() - objectPosition); glm::vec3 right = glm::cross(up, look); glm::vec3 up2 = glm::cross(look, right); glm::mat4 transform; transform = glm::vec4(right, 0); transform = glm::vec4(up2, 0); transform = glm::vec4(look, 0); transform = glm::vec4(objectPosition, 1); glm::quat q = glm::quat_cast(transform); objectTransformable->setOrientationFromQuat(q);
I've tried to add something like that but the result is a bigger object with bad proportion:
transform = glm::scale( transform, objectScale );
To resume, I would like to extract orientation from result matrix to apply it on my transform object, something like Unity: