3ds max camera matrix to openGL gluLookAt

Hi everyone i’m having a problem, i’ve got a model from 3ds max and i’m drawing it in my opengl scene. The X model coord i’m multipling by -1, and swaping Y with Z. Model looks good. Now i have a camera rotation:

R= [-0.00787758403400 -0.99987368071328 -0.01380457484584][-0.05022239161841 -0.01339197533679 0.99864826960082][-0.99870699158958 0.00856023442823 -0.05011055115063]
And camera position:
C=[-666.49300000000005, -28.12390000000000, 11.28040000000000]

Now i think in 3ds max the transformation matrix looks like:
[R]
[C]
:
[-0.00787758403400 -0.99987368071328 -0.01380457484584 ]
[-0.05022239161841 -0.01339197533679 0.99864826960082 ]
[-0.99870699158958 0.00856023442823 -0.05011055115063 ]
[-666.49300000000005 -28.12390000000000 11.28040000000000 ]

Also i have a focal length:
f=1549.17 but i don’t know is it important.

This camera is looking at the model. Now what should i do with this matrix to get the same view in my openGL project?

What is the position of the camera, what is the target that camera is looking at and what is the up vector that i need to gluLookAt(). I was searching in the internet but i couldn’t find anything.

Why don’t you use the matrix directly? At first glance, it seems like a perfectly valid row major view matrix. Are you doing fixed-function or shaders?

I’ve found that the openGL has column major and the 3ds max has row major(i’m not sure) so i have to change this matrix, also GL has Y axis Up and -Z axis through screen, 3ds max has Y Up.

Two steps are required. To swap the orientation (Z up to Y up), you must multiply the matrix by rotation matrix that rotates around X axis by -PI.


Rx=
[ 1 0 0 0 ]
[ 0 0 1 0 ]
[ 0 -1 0 0]
[ 0 0 0 1]

M' = M * Rx

Then to get matrix in column major order just simply make a transposed matrix or call glLoadTransposeMatrixf() instead of glLoadMatrixf()

Oops, my bad. I meant to say “column major”. The matrix above actually has the layout OpenGL works with. You’ll need to create a 4x4 matrix where the rotational part and translation occupy the left 4x3 part of the matrix and the last column is (0 0 0 1). Then apply mforts change of basis and you should be done.