Hi Tim, many thanx for the answer! Dividing the vector by w was the hint I needed. Now it works.
Best regards, Oli Am Samstag, 2. Oktober 2010, 13:13:35 schrieb Tim Moore: > On Sat, Oct 2, 2010 at 4:47 AM, Oliver Burtchen <o.burtc...@gmx.de> wrote: > > Hello at all, > > > > I'm currently working on frustum-culling for a > > roam-algorithm-implemetation. > > Maybe someone can give me a hint what I'm missing to nail my problem > > down. > > > > I want to calculate the x,y-coordinates for a vertex on the screen. My > > approach (only for testing, to nail down the problem): > > > > <code> > > > > osg::Matrixd mv = osg::Matrixd::identity(); > > osg::Matrixd mp = osg::Matrixd::identity(); > > osg::Matrixd mw = osg::Matrixd::identity(); > > > > while( !viewer.done() ) > > { > > > > viewer.frame(); > > > > if (viewer.getCameraWithFocus()) > > { > > > > mv = viewer.getCameraWithFocus()->getViewMatrix(); > > mp = viewer.getCameraWithFocus()->getProjectionMatrix(); > > mw = > > viewer.getCameraWithFocus()->getViewport()->computeWindowMatrix(); > > > > } > > > > } > > > > osg::Vec4d v = osg::Vec4d(0, 0, 0, 1.0); > > v = v * mv; > > v.normalize(); > > No! don't normalize there. > > > v = v * mp * mw; > > > > This is fine, now you need to divide v by v.w(). > > Tim > > > </code> > > > > > > Schould this give me the last-coordinates of v on the screen, when > > pressing "ESC" so the viewer terminates? I know this code only works, if > > the window has > > the focus at termination-time, this is not the problem why I'm asking. > > > > Best regards, > > Oli > > > > -- > > Oliver Burtchen, Berlin > > _______________________________________________ > > osg-users mailing list > > osg-users@lists.openscenegraph.org > > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org -- Oliver Burtchen, Berlin _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org