[osg-users] LookAt() function parameter meanings..

Ravi Mathur ravidavi at utexas.edu
Mon Aug 13 07:32:19 PDT 2018


Hey Martin,

You are not interpreting the parameters properly. Look at the header for
Matrixd.cpp:

  /** Set the position and orientation to be a view matrix,
    * using the same convention as gluLookAt.
  */
  void makeLookAt(const Vec3d& eye,const Vec3d& center,const Vec3d& up    );

It follows the same convention and algorithm as gluLookAt(), so you can
look at the many online reference pages for that (microsoft
<https://docs.microsoft.com/en-us/windows/desktop/opengl/glulookat>, khronos
<https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/gluLookAt.xml>).
There is no question about its correctness or compatibility with OpenGL,
since OSG has been used with OpenGL in hundreds of projects for like 20
years. :D

To very directly answer your question, "eye" is the eye position (or camera
if you prefer), "center" is a point towards which the eye is looking, and
therefore the look vector points from eye towards center. This look vector
is the negative z-axis of OpenGL. The "up" vector specifies the direction
of the positive y-axis. The x-axis is then defined as y-cross-z, which is
the default OpenGL right-handed system. HOWEVER, OSG takes it a step
further and maps the y-axis to the look vector (into the screen). With this
simple rotation, x points right and z points up, which remains
right-handed. I'm guessing this is done because many OSG applications
represent physical (real-world) systems, in which the z-axis often does
point up. (Robert or someone else can correct me if that's not the reason)

Ravi

On Mon, Aug 13, 2018 at 10:07 AM Rowley, Marlin R <marlin.r.rowley at lmco.com>
wrote:

> All,
>
>
>
> I’m very confused by the parameters passed into this function.  I am going
> over some of the legacy code and saw this line of code:
>
>
>
> osg::Matrixd frustumView;
>
> frustumView.makeLookAt(VIEW_POS, mDirection, mUp);
>
>
>
> saw the docs, it’s described like this:
>
>
>
> void makeLookAt(const Vec3d& eye,const Vec3d& center,const Vec3d& up);
>
>
>
> So in this context, I would think that “eye” represents the look vector.
> However, it seems to work like a position vector.  The “center” parameter
> expects a direction vector (0, -1, 0) where the look vector is along the
> -yaxis.
>
>
>
> This matrix will not translate to OpenGL properly since it’s coordinate
> system is based off of a right handed coordinate frame.
>
>
>
> Questions:
>
>
>
>    1. Am I interpreting these parameters properly?
>    2. How would I convert this system to the OpenGL right-handed system?
>
>
>
> ----------------------------------------
>
> Marlin Rowley
>
> Software Engineer, Staff
>
> [image: cid:image002.jpg at 01D39374.DEC5A2E0]
>
> *Missiles and Fire Control*
>
> 972-603-1931 (office)
>
> 214-926-0622 (mobile)
>
> marlin.r.rowley at lmco.com
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20180813/7be42206/attachment.html>


More information about the osg-users mailing list