I have a object placed on a mouse ray. I want align object toward to camera, clear rotation with saving another components of camera as scale and translation. Ofcourse, I could to make it without any matrix transformation based on mouse position, but I need 3d object. What is a best way to do that? My calculations MVP sends to shaders and I guessing I need to prepare View matrix without rotation components. Something like that (find that on stackoverflow) :
glm::mat4 newView = view;
float d = sqrt((newView [0][0] * newView [0][0]) + (newView [1][0] * newView [1][0]) + (newView [2][0] * newView [2][0]));
newView [0][0] = d;
newView [0][1] = 0;
newView [0][2] = 0;
newView [0][3] = 0;
newView [1][0] = 0;
newView [1][1] = d;
newView [1][2] = 0;
newView [1][3] = 0;
newView [2][0] = 0;
newView [2][1] = 0;
newView [2][2] = d;
newView [2][3] = 0;
Is it correct? Is it a best way for my purpose? Thanks!