[osg-users] How to Convert Lookat to Projection and View Matrices
Erik Hensens
ehensens at hunter.com
Tue Sep 22 09:03:34 PDT 2015
Thank you Sebastian!
The issue here is that the camera is not yet at the lookat in question. Basically, I have an eye, a center, and an up vector, and I need to be able to convert between 3D world coordinates and 2D screen pixel coordinates before the camera actually gets to the final lookat.
Is that possible?
I hope that all makes sense...
SMesserschmidt wrote:
> Am 22.09.2015 um 16:08 schrieb Erik Hensens:
>
> > Thank you for the reply Glenn!
> >
> > You say that the projection matrix doesn't depend on the lookat parameters; what does it depend on?
> >
> The projection matrix depends on the size of your viewing frustum.
> Usually near/far plane and the dimensions (angles) of the field of view.
> You can use the camera->get/setProjectionMatrix functions here.
> For instance:
>
> viewer->getCamera()->setProjectionMatrixAsFrustum(
> aspect_x * near_plane * left_angle,
> aspect_x * near_plane *right_angle,
> aspect_y * near_plane * bottom_angle,
> aspect_y * near_plane * top_angle,
> near_plane,
> far_plane
> );
>
> Cheers
> Sebastian
>
> >
> > Thanks in advance!
> >
> >
> > gwaldron wrote:
> >
> > > You can make the view matrix:
> > >
> > > osg::Matrix::lookAt(eye, center, up)
> > >
> > >
> > > This has nothing to do with the projection matrix though; that doesn't depend on your look vector.
> > >
> > > Glenn Waldron
> > >
> > >
> > >
> > >
> > > On Tue, Sep 22, 2015 at 9:24 AM, Erik Hensens < ()> wrote:
> > >
> > >
> > > > Hi everyone!
> > > >
> > > > How can I compute the view matrix and the projection matrix from a set of lookat parameters (eye, center, and up)?
> > > >
> > > > I'm asking because I need to compute the MVPW for a given lookat before the camera is actually at that lookat.
> > > >
> > > > I'm totally stumped and any help would be greatly appreciated!
> > > >
> > > > Thank you!
> > > >
> > > > Cheers,
> > > > Erik[/list]
> > > >
> > > > ------------------
> > > > Read this topic online here:
> > > > http://forum.openscenegraph.org/viewtopic.php?p=65173#65173 (http://forum.openscenegraph.org/viewtopic.php?p=65173#65173)
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > _______________________________________________
> > > > osg-users mailing list
> > > > ()
> > > > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org (http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org)
> > > >
> > > >
> > >
> > > ------------------
> > > Post generated by Mail2Forum
> > >
> >
> > ------------------
> > Read this topic online here:
> > http://forum.openscenegraph.org/viewtopic.php?p=65175#65175
> >
> >
> >
> >
> >
> > _______________________________________________
> > osg-users mailing list
> >
> > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> >
>
> _______________________________________________
> osg-users mailing list
>
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
> ------------------
> Post generated by Mail2Forum
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=65177#65177
More information about the osg-users
mailing list