[osg-users] EXTERNAL: Re: LookAt() function parameter meanings..
Rowley, Marlin R
marlin.r.rowley at lmco.com
Mon Aug 13 07:58:25 PDT 2018
Ravi,
During the projection matrix phase, OpenGL switches to left-handed system (i.e. Z-axis points positive going into the screen). But I missed the rotation, so it stays left-handed with +x (right), -y (look), and +z(up).
Thanks for the interpretation of the parameter names. I interpreted “center” to mean a position point – not a vector. And “eye” to mean the direction the eye is pointed to.
----------------------------------------
Marlin Rowley
Software Engineer, Staff
[cid:image002.jpg at 01D39374.DEC5A2E0]
Missiles and Fire Control
972-603-1931 (office)
214-926-0622 (mobile)
marlin.r.rowley at lmco.com<mailto:marlin.r.rowley at lmco.com>
From: osg-users <osg-users-bounces at lists.openscenegraph.org> On Behalf Of Ravi Mathur
Sent: Monday, August 13, 2018 9:32 AM
To: OpenSceneGraph Users <osg-users at lists.openscenegraph.org>
Subject: EXTERNAL: Re: [osg-users] LookAt() function parameter meanings..
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<mailto: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
Missiles and Fire Control
972-603-1931 (office)
214-926-0622 (mobile)
marlin.r.rowley at lmco.com<mailto:marlin.r.rowley at lmco.com>
_______________________________________________
osg-users mailing list
osg-users at lists.openscenegraph.org<mailto: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/faddc41d/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.jpg
Type: image/jpeg
Size: 3114 bytes
Desc: image001.jpg
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20180813/faddc41d/attachment.jpg>
More information about the osg-users
mailing list