Hi,

First, sorry to post a lot on mailing list, but I have some difficulties,I
do not find any way to solve them, and I didn't find a way to stop time ...

This problem concern mathematical things, based on Quat, PAT, matrices, ...

I implement a new manipulator, with a way to set a node as reference.
The expected effect is that the camera will stay motionless relative to the
node (translation and rotation)

My manipulator is based on a quaternion : _rotation and a vector : _eye.
This quat and this vector are used in the getInverseMatrix().

To move the camera following a node, I use that :

osg::Matrixd mat = _node->asGroup()->getWorldMatrices()[0];//get world
> coordinate
> _eye -= mat.getTrans() - _oldmat.getTrans();
> [...]
> _oldmat = mat;
>

This looks good.

Now, when node rotate, it becomes more difficult : is camera is far/near
from the node, it have to stay motionless.
It imply to compute two things : the rotation, and the translation to apply.

The rotation is computed like that :

qq = pat->getAttitude();
> osg::Quat _q_ = qq * _QuatActual.inverse(); // = rotation from QuatActual
> to qq
>
> if(!_q_.zeroRotation()) {//apply only if necessary
>     _rotation *= _q_;
> }
>
> _QuatActual = qq;
>

Last, the translation to put the camera at the same relative place of the
node.

osg::Vec3d vt(mat.getTrans() - getEyePoint()); //getEyePoint return the
> current camera position
> osg::Vec3d vt2 = _q_ * vt ;
>
> _eye -= vt-vt2;
>

This is all.
The result ? so complicated too : the camera seems to be not exactly
motionless relative to the node. Can be a lack of precision.... but* if the
node is moved with two successive rotation, the camera is not at all
motionless and move without any sense...
*
I have tried a lot of things, but the result still stay the same...
I have this problem for months... and no new idea... so, if you have any
suggestion, idea, .... it would be very great for me!

Thanks for help.

Regards,
   Vincent.
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to