[osg-users] double vs. float precision in camera position + osg::MatrixTransform question

Roni Rosenzweig roniros at gmail.com
Mon Mar 3 22:19:49 PST 2008


Hi Robert
I found the problem and fixed it:
Turns out is wasn't the MatrixTransform but how I set the camera position.
I used:
getCamera()->setViewMatrixAsLookat(eye, center, up)     which receives
osg::Vec3f instead of osg::Vec3d.
when I switched to:
getCamera()->setViewMatrix(osg::Matrixd::lookat(eye, center, up)) (which
receives osg::Vec3d)
the problem was completely solved.

Is there a reason why setViewMatrixAsLookat doesn't receive osg::Vec3d??

Roni


On 3/3/08, Robert Osfield <robert.osfield at gmail.com> wrote:
>
> Hi Roni,
>
> The OSG defaults to using Matrxd for the Matrix definition.  The
> MatrixManipulators generally use doubles internally as well.  All for
> the reason of avoid problems with precision.   The intersection code
> can be a problem area though as its currently done in floats, other
> than this possible area, I'm not sure what code you might be having
> issue with.
>
> What camera manipulator are you using?
>
> Robert.
>
> On Mon, Mar 3, 2008 at 7:49 AM, Roni Rosenzweig <roniros at gmail.com> wrote:
> > Hello
> >
> > I made a small demo using osg 2.2, of an object moving on a terrain with
> a
> > camera looking at it from above, and lowering towards it.
> > When the location of the object+camera is near the (0,0,0) the demo
> works
> > smoothly.
> > However when their location is far (for example at location (30000,
> 5000,
> > 100)), there are "vibrations" in the move of both the camera and the
> object.
> >
> > I narrowed it down to a precision problem between float and double, and
> made
> > it much better using Vec3d/Matrixd instead of Vec3f/Matrixf for the
> camera
> > position.
> > However for the object I'm using a osg::MatrixTransform, which uses a
> Matrix
> > and not a Matrixd. I think this is causing the precision problems in the
> > object movement.
> >
> > Did anyone else bump into this problem?
> > Is there a version of osg::MatrixTransform using a Matrixd for double
> > precision?
> > _______________________________________________
> >  osg-users mailing list
> >  osg-users at lists.openscenegraph.org
> >
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> >
> >
> _______________________________________________
> 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/20080304/f92decf6/attachment.html 


More information about the osg-users mailing list