Hi, Robert,

    OK, I think I figured out why the matrix from makeLookAt() is 
transposed. It must have been intended to be used as the view matrix, 
which is the inverse of the regular rotation matrix and happens to 
be exactly the rotation matrix transposed. By using Matrix::makeRotate() 
I do get the rotation matrix in the post-multiplication convention.

    Best Regards,

    Yefei

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:osg-users-
> [EMAIL PROTECTED] On Behalf Of Robert Osfield
> Sent: Friday, November 30, 2007 3:10 AM
> To: OpenSceneGraph Users
> Subject: Re: [osg-users] Matrix::makeLookAt confusion
> 
> HI Yefei,
> 
> The OSG's makeLookAt() implements everything exactly the same as
> gluLookAt so OpenGL docs will be a good guide.  The only difference
> you'll see if there is transpose between the two.
> 
> Robert.
> 
> On Nov 30, 2007 12:23 AM, Yefei He <[EMAIL PROTECTED]> wrote:
> > Hi, Robert,
> >
> >     I'm doing some object rotation and translation stuff on my own so
> I
> > looked at the OSG math code for inspiration. From what I read before
> > OSG uses post multiplication, meaning if I want to transform a vector
> I
> > need to do a V * M or, in OSG functions, M.preMult(V), where V is the
> > vector and M is the transformation matrix. This multiplication order
> seems
> > to be supported by how a translation matrix is created, by assigning
> the
> > translation values to the bottom row of the matrix. But, I got
> confused
> > when examining the method of setting the matrix by look at values. In
> > Matrix_implementation::makeLookAt(eye, center, up), it calculates the
> > forward, up and side vectors f, u, and s. I assume it used the OpenGL
> > convention of -z as the default forward direction and +y the default
> up
> > direction. Then, it sets the rotation matrix R as:
> >
> > s[0] u[0] -f[0]   0
> > s[1] u[1] -f[1]   0
> > s[2] u[2] -f[2]   0
> >    0    0     0   1
> >
> > But, with this matrix, if I apply it to the default forward vector F0
> of
> > (0, 0, -1, 1) via post multiplication, i.e. doing an F0 * R, I get
> (s[0],
> > u[0], f[0], 1), instead of the correct value of the current forward
> vector
> > (f[0], f[1], f[2], 1). I need to do a pre multiplication or R * F0 to
> get
> > the correct value.
> >
> >     Is my understanding of makeLookAt() wrong? Does the matrix
> generated
> > by makeLookAt() mean something else? Or, does OSG use a clever way of
> > setting translation in the post mult convention by rotation in the
> pre
> > mult convention, and always separating them out when applying the
> > transformation? Can some OSGers help me clear my head on this? Thanks!
> >
> >     Best Regards,
> >
> >     Yefei
> >
> >
> >
> >
> >
> > _______________________________________________
> > osg-users mailing list
> > osg-users@lists.openscenegraph.org
> > http://lists.openscenegraph.org/listinfo.cgi/osg-users-
> openscenegraph.org
> >
> _______________________________________________
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-
> openscenegraph.org


_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to