Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void SetRow(int row, vec3& inVec) {
- m[row*4+0] = inVec.x;
- m[row*4+1] = inVec.y;
- m[row*4+2] = inVec.z;
- }
- // Set the rotation and scale
- vec3 r1 = xform.rotation[0]; r1.x *= xform.scale;
- vec3 r2 = xform.rotation[1]; r2.y *= xform.scale;
- vec3 r3 = xform.rotation[2]; r3.z *= xform.scale;
- t.SetRow(0, r1);
- t.SetRow(1, r2);
- t.SetRow(2, r3);
- t = t.Inverse(); // Invert the rotation
- // Set the translation
- t[3] = xform.translation.x;
- t[7] = xform.translation.y;
- t[11] = xform.translation.z;
- Mat4 ToInverseMatrix() {
- Mat4 m;
- m[0]=rotation[0].x * scale; m[1]=rotation[0].y; m[2]=rotation[0].z;
- m[4]=rotation[1].x; m[5]=rotation[1].y * scale; m[6]=rotation[1].z;
- m[8]=rotation[2].x; m[9]=rotation[2].y; m[10]=rotation[2].z * scale;
- m = m.Inverse();
- m[3]=translation.x;
- m[7]=translation.y;
- m[11]=translation.z;
- return m;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement