Inverse of view matrix(right-handed look-at matrix) for pick

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
cymx2
Posts: 5
Joined: Tue Jul 04, 2006 7:56 am

Inverse of view matrix(right-handed look-at matrix) for pick

Post by cymx2 »

I need Inverse of view matrix (right-handed look-at matrix) for screen pick,but irrlicht's matrix only have matrix4::buildCameraLookAtMatrixRH(),no it's inverse matrix. so I write a inverse matrix,is right??

(*this)(0,0) = xaxis.X;
(*this)(1,0) = xaxis.Y;
(*this)(2,0) = xaxis.Z;
(*this)(3,0) = 0;

(*this)(0,1) = yaxis.X;
(*this)(1,1) = yaxis.Y;
(*this)(2,1) = yaxis.Z;
(*this)(3,1) = 0;

(*this )(0,2) = zaxis.X;
(*this)(1,2) = zaxis.Y;
(*this)(2,2) = zaxis.Z;
(*this)(3,2) = 0;

(*this)(0,3) = position;
(*this)(1,3) = position;
(*this)(2,3) = position;
(*this)(3,3) = 1.0f;

CameraLookAtMatrixRH=M(xaxis,yaxis,zaxis)*M(-position)
so Inverse(CameraLookAtMatrixRH)=M(position)*T(M(xaxis,yaxis,zaxis))

over is right???
needforhint
Posts: 322
Joined: Tue Aug 30, 2005 10:34 am
Location: slovakia

Post by needforhint »

why don't you use inverse() method of matrix class????
what is this thing...
Baal Cadar
Posts: 377
Joined: Fri Oct 28, 2005 10:28 am
Contact:

Post by Baal Cadar »

Use either matrix4::makeInverse() or matrix4::getInverse(). What you tried to do yourself is not the inverse of a matrix, but the transpose, which is not the same. inverse is much more difficult and expensive to compute and by no means the same.
No offense :)
cymx2
Posts: 5
Joined: Tue Jul 04, 2006 7:56 am

Post by cymx2 »

M(xaxis,yaxis,zaxis) * Inverse(M(xaxis,yaxis,zaxis))=E
M(xaxis,yaxis,zaxis) * Transpose(M(xaxis,yaxis,zaxis) )=E
so:
Inverse(M(xaxis,yaxis,zaxis))=Transpose(M(xaxis,yaxis,zaxis) )

CameraLookAtMatrixRH=M(xaxis,yaxis,zaxis)*M(-position) (right multiply)

so:
Inverse(CameraLookAtMatrixRH)=M(position)*Transpose(M(xaxis,yaxis,zaxis))

I think I am right,I multiply the two matrix-----M(xaxis,yaxis,zaxis)*M(-position) and M(position)*Transpose(M(xaxis,yaxis,zaxis)) ,result is rihgt!

matrix4::makeInverse() is too slow,view matrix is often change
elander
Posts: 193
Joined: Tue Oct 05, 2004 11:37 am

Post by elander »

I realy don't undertstand much of view matrices yet (still have to revise this subject) but there are situtations where the inverse calculation can be simplified by using the transpose.
Post Reply