-----------------------------------------------------------------------
| 112 | |
| 113 | //----------------------------------------------------------------------- |
| 114 | void Matrix4x4::makeInverseTransform(const Vector3& position, const Vector3& scale, const Quaternion& orientation) |
| 115 | { |
| 116 | // Invert the parameters |
| 117 | Vector3 inv_translate = -position; |
| 118 | Vector3 inv_scale(1 / scale.x, 1 / scale.y, 1 / scale.z); |
| 119 | Quaternion inv_rot = orientation.inverse(); |
| 120 | |
| 121 | // Because we're inverting, order is translation, rotation, scale |
| 122 | // So make translation relative to scale & rotation |
| 123 | inv_translate = inv_rot * inv_translate; // rotate |
| 124 | inv_translate *= inv_scale; // scale |
| 125 | |
| 126 | // Next, make a 3x3 rotation matrix |
| 127 | Matrix3x3 rot3x3; |
| 128 | inv_rot.toRotationMatrix(rot3x3); |
| 129 | |
| 130 | // Set up final matrix with scale, rotation and translation |
| 131 | m_mat[0][0] = inv_scale.x * rot3x3[0][0]; |
| 132 | m_mat[0][1] = inv_scale.x * rot3x3[0][1]; |
| 133 | m_mat[0][2] = inv_scale.x * rot3x3[0][2]; |
| 134 | m_mat[0][3] = inv_translate.x; |
| 135 | m_mat[1][0] = inv_scale.y * rot3x3[1][0]; |
| 136 | m_mat[1][1] = inv_scale.y * rot3x3[1][1]; |
| 137 | m_mat[1][2] = inv_scale.y * rot3x3[1][2]; |
| 138 | m_mat[1][3] = inv_translate.y; |
| 139 | m_mat[2][0] = inv_scale.z * rot3x3[2][0]; |
| 140 | m_mat[2][1] = inv_scale.z * rot3x3[2][1]; |
| 141 | m_mat[2][2] = inv_scale.z * rot3x3[2][2]; |
| 142 | m_mat[2][3] = inv_translate.z; |
| 143 | |
| 144 | // No projection term |
| 145 | m_mat[3][0] = 0; |
| 146 | m_mat[3][1] = 0; |
| 147 | m_mat[3][2] = 0; |
| 148 | m_mat[3][3] = 1; |
| 149 | } |
| 150 | //----------------------------------------------------------------------- |
| 151 | void Matrix4x4::decomposition(Vector3& position, Vector3& scale, Quaternion& orientation) const |
| 152 | { |
nothing calls this directly
no test coverage detected