6

I have extracted the upper left 3x3 rotation matrice of a mat4:

glm::mat4 model;  
glm::mat3 rot = glm::mat3(model);

Now I want the identity matrix with the upper left being my new mat3

enter image description here

What is the simplest way of doing so?

glm::mat4 result;
result[0] = glm::vec4(rot[0], 0);
result[1] = glm::vec4(rot[1], 0);
result[2] = glm::vec4(rot[2], 0);
result[3] = glm::vec4(0, 0, 0, 1);

Is there a better way?

1 Answer 1

9

Try if this works for you:

glm::mat4 result = glm::mat4(rot);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.