本文整理汇总了C++中Matrix4x4::Inverse方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix4x4::Inverse方法的具体用法?C++ Matrix4x4::Inverse怎么用?C++ Matrix4x4::Inverse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix4x4
的用法示例。
在下文中一共展示了Matrix4x4::Inverse方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LookAt
Transform Transform::LookAt(const Vector3 &pos, const Vector3 &look, const Vector3 &up) {
Matrix4x4 camToWorld;
// Initialize fourth column of viewing matrix
camToWorld.matrix[0][3] = pos.x;
camToWorld.matrix[1][3] = pos.y;
camToWorld.matrix[2][3] = pos.z;
camToWorld.matrix[3][3] = 1;
// Initialize first three columns of viewing matrix
Vector3 dir, temp_up;
Vector3::Normalize(look - pos, dir);
Vector3::Normalize(up, temp_up);
Vector3 left;
Vector3::Normalize(Vector3::Cross(temp_up, dir),left);
Vector3 newUp = Vector3::Cross(dir, left);
camToWorld.matrix[0][0] = left.x;
camToWorld.matrix[1][0] = left.y;
camToWorld.matrix[2][0] = left.z;
camToWorld.matrix[3][0] = 0.;
camToWorld.matrix[0][1] = newUp.x;
camToWorld.matrix[1][1] = newUp.y;
camToWorld.matrix[2][1] = newUp.z;
camToWorld.matrix[3][1] = 0.;
camToWorld.matrix[0][2] = dir.x;
camToWorld.matrix[1][2] = dir.y;
camToWorld.matrix[2][2] = dir.z;
camToWorld.matrix[3][2] = 0.;
return Transform(camToWorld.Inverse(), camToWorld);
}
示例2: matrix
Transform::Transform(Matrix4x4& p_mat) : matrix(p_mat), matrix_inverse(p_mat.Inverse()){}