glm::transform

glm::mat4 Tx = glm::translate(glm::mat4(1.0f), glm::vec3(3.0f, 0.0f, 0.0f));
glm::mat4 Rz = glm::rotate(glm::mat4(1.0f), 45.0f, glm::vec3(0.0f, 0.0f, 1.0f));
glm::mat4 S = glm::scale(glm::mat4(1.0f), glm::vec3(0.5f, 0.7f, 1.0f));
glm::mat4 TRS = Tx * Rz * S; // Scale XY, and then Rotate Z, and then Translate X

위의 코드는 아래의 코드와 동일한 행렬의 곱 연산을 수행한다.

glm::mat4 T = glm::translate(glm::mat4(1.0f), glm::vec3(3.0f, 0.0f, 0.0f)); // T
glm::mat4 TR = glm::rotate(T, 45.0f, glm::vec3(0.0f, 0.0f, 1.0f)); // T * R
glm::mat4 TRS = glm::scale(TR, glm::vec3(0.5f, 0.7f, 1.0f)); // T * R * S

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *