Advertisement
expired6978

xf

Jun 28th, 2014
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.88 KB | None | 0 0
  1.     void SetRow(int row, vec3& inVec) {
  2.         m[row*4+0] = inVec.x;
  3.         m[row*4+1] = inVec.y;
  4.         m[row*4+2] = inVec.z;
  5.     }
  6.  
  7. // Set the rotation and scale
  8. vec3 r1 = xform.rotation[0]; r1.x *= xform.scale;
  9. vec3 r2 = xform.rotation[1]; r2.y *= xform.scale;
  10. vec3 r3 = xform.rotation[2]; r3.z *= xform.scale;
  11. t.SetRow(0, r1);
  12. t.SetRow(1, r2);
  13. t.SetRow(2, r3);
  14. t = t.Inverse(); // Invert the rotation
  15. // Set the translation
  16. t[3] = xform.translation.x;
  17. t[7] = xform.translation.y;
  18. t[11] = xform.translation.z;
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.     Mat4 ToInverseMatrix() {
  27.         Mat4 m;
  28.         m[0]=rotation[0].x * scale;                     m[1]=rotation[0].y;         m[2]=rotation[0].z;
  29.         m[4]=rotation[1].x;                     m[5]=rotation[1].y * scale;         m[6]=rotation[1].z;
  30.         m[8]=rotation[2].x;                     m[9]=rotation[2].y;         m[10]=rotation[2].z * scale;
  31.         m = m.Inverse();
  32.         m[3]=translation.x;
  33.         m[7]=translation.y;
  34.         m[11]=translation.z;
  35.         return m;
  36.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement