示例#1
0
文件: Camera.cpp 项目: arneboon/roxlu
Mat4 Camera::getInverseViewMatrix() {
	return affine_inverse(view_matrix);
}
示例#2
0
文件: Camera.cpp 项目: arneboon/roxlu
Mat4 Camera::getInverseViewProjectionMatrix() {
	Mat4 mvp = projection_matrix * view_matrix;
	return affine_inverse(mvp);
}
示例#3
0
SbMatrix
SbMatrix::inverse() const
{
    // Trivial case
    if (IS_IDENTITY(matrix))
	return SbMatrix::identity();

    // Affine case...
    SbMatrix affineAnswer;
    if (  affine_inverse( SbMatrix(matrix), affineAnswer ) )
	return affineAnswer;

    int         index[4];
    float       d, invmat[4][4], temp;
    SbMatrix	inverse = *this;
#ifdef DEBUGGING
    int         i, j;
#endif /* DEBUGGING */

    if(inverse.LUDecomposition(index, d)) {

#ifdef DEBUGGING
	for(j = 0; j < 4; j++) {
	    for(i = 0; i < 4; i++)
		invmat[j][i] = 0.0;
	    invmat[j][j] = 1.0;
	    inverse.LUBackSubstitution(index, invmat[j]);
	}
#else
	invmat[0][0] = 1.0;
	invmat[0][1] = 0.0;
	invmat[0][2] = 0.0;
	invmat[0][3] = 0.0;
	inverse.LUBackSubstitution(index, invmat[0]);
	invmat[1][0] = 0.0;
	invmat[1][1] = 1.0;
	invmat[1][2] = 0.0;
	invmat[1][3] = 0.0;
	inverse.LUBackSubstitution(index, invmat[1]);
	invmat[2][0] = 0.0;
	invmat[2][1] = 0.0;
	invmat[2][2] = 1.0;
	invmat[2][3] = 0.0;
	inverse.LUBackSubstitution(index, invmat[2]);
	invmat[3][0] = 0.0;
	invmat[3][1] = 0.0;
	invmat[3][2] = 0.0;
	invmat[3][3] = 1.0;
	inverse.LUBackSubstitution(index, invmat[3]);
#endif /* DEBUGGING */

#ifdef DEBUGGING
	// transpose invmat
	for(j = 0; j < 4; j++) {
	    for(i = 0; i < j; i++) {
		temp = invmat[i][j];
		invmat[i][j] = invmat[j][i];
		invmat[j][i] = temp;
	    }
	}
#else
#define SWAP(i,j) \
	temp = invmat[i][j]; \
	invmat[i][j] = invmat[j][i]; \
	invmat[j][i] = temp;

	SWAP(1,0);
	
	SWAP(2,0);
	SWAP(2,1);
	
	SWAP(3,0);
	SWAP(3,1);
	SWAP(3,2);
#undef SWAP	
#endif /* DEBUGGING */
#ifdef _MSC_VER
        inverse.setValue((const SbMat &)invmat);
#else
	inverse.setValue(invmat);
#endif
    }

    return inverse;
}