Results 1 to 5 of 5

Thread: 3ds max camera matrix to openGL gluLookAt

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2011
    Posts
    2

    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.

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    1,135

    Re: 3ds max camera matrix to openGL gluLookAt

    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?

  3. #3
    Junior Member Newbie
    Join Date
    Dec 2011
    Posts
    2

    Re: 3ds max camera matrix to openGL gluLookAt

    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.

  4. #4
    Senior Member Regular Contributor
    Join Date
    Nov 2003
    Location
    Czech Republic
    Posts
    317

    Re: 3ds max camera matrix to openGL gluLookAt

    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.
    Code :
    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()

  5. #5
    Senior Member OpenGL Pro
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    1,135

    Re: 3ds max camera matrix to openGL gluLookAt

    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.

Similar Threads

  1. Implementing camera using gluLookAt(...)
    By Pr0gMa in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 11-04-2014, 05:17 PM
  2. Replies: 4
    Last Post: 09-15-2014, 11:07 AM
  3. OpenGL First Person Camera, non-gluLookAt()
    By SRive in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 03-18-2012, 12:02 AM
  4. Replies: 2
    Last Post: 08-29-2005, 12:24 PM
  5. using own camera matrix vs gluLookAt
    By paul_kelly2000 in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 02-05-2002, 08:24 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean