Hi,
I noticed that TrackballManipulator::computePosition( eye, center, up )
computes TrackballManipulator::_rotation with all elements
= -1.#IND000000000000 what eventually causes broken view and inverseView
matrices.
It happens when TrackballManipulator::computePosition( eye, center, up ) is
called with following arguments
osg::Vec3 eye( 0.0, 3.5, 0.0 );
osg::Vec3 center( 0.0, 0.0, 0.0 );
osg::Vec3 up( 0.0, 0.0, 1.0 );
Above eye, center, up arguments are produced when Viewer::SceneData has
empty bounding sphere (empty group for example). In our project we initially
set up empty scene and dynamically add objects during frame loop.
I traced the problem and it seems related to the recent change in
Matrix_implementation::getRotate() where osg::sign call was replaced by
osg::signOrZero call. TrackballManipulator::computePosition uses
Matrix::getRotate() to compute _rotation Quaternion.
Sorry, I do not provide fix because I am not sure what should be changed.
Assuming recent modifications to getRotate were correct- fix should be
probably made in TrackballManipulator and other manipulators if they use
similar code.
Below code example which can be used to reproduce the bug (code is based on
TrackballManipulator::computePosition body). This example produces incorrect
rotation quaternion with current SVN sources. It works with OSG 1.2.
osg::Vec3 eye( 0.0, 3.5, 0.0 );
osg::Vec3 center( 0.0, 0.0, 0.0 );
osg::Vec3 up( 0.0, 0.0, 1.0 );
osg::Vec3 lv(center-eye);
osg::Vec3 f(lv);
f.normalize();
osg::Vec3 s(f^up);
s.normalize();
osg::Vec3 u(s^f);
u.normalize();
osg::Matrix rotation_matrix(s[0], u[0], -f[0], 0.0f,
s[1], u[1], -f[1], 0.0f,
s[2], u[2], -f[2], 0.0f,
0.0f, 0.0f, 0.0f, 1.0f);
osg::Quat rotation = rotation_matrix.getRotate( ).inverse();
Cheers,
Wojtek Lewandowski
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/