Ok,
if you want to go for post-multiplication (like currently done with
osg::Matrix) than the following operations should be equal.
int main(int argc, char** argv) {
osg::Matrix m;
osg::Matrix m2;
osg::Quat q( osg::PI_2, osg::Vec3( 0, 0, 1 ) );
osg::Quat q2( osg::PI_2, osg::Vec3( 0, 1, 0 ) );
osg::Vec3d t( 2, 0, 0 );
osg::Vec3d x( 3, 0, 0 );
m.setRotate( q );
m.setTrans( t );
m2.setRotate( q2 );
osg::Vec3d out = x * m * m2;
osg::Vec3d out2 = (x * q + t ) * q2;
osg::Vec3d out3 = x * q * q2 + t * q2;
return 0;
}
However post-multipliction is implemented only for Quat * Quat, so you
have to implement it for Vec * Quat as well (just refactor Quat * Vec to
Vec * Quat).
If you choose pre-multiplication for your matrix and quat classes the
following operations should give you the same result.
int main(int argc, char** argv) {
osg::Matrix m;
osg::Matrix m2;
osg::Quat q( osg::PI_2, osg::Vec3( 0, 0, 1 ) );
osg::Quat q2( osg::PI_2, osg::Vec3( 0, 1, 0 ) );
osg::Vec3d t( 2, 0, 0 );
osg::Vec3d x( 3, 0, 0 );
m.setRotate( q );
m.setTrans( t );
m2.setRotate( q2 );
osg::Vec3d out = m2 * m * x;
osg::Vec3d out2 = q2 * ( q * x + t );
osg::Vec3d out3 = q2 * q * x + q2 * t;
return 0;
}
This would require a huge a amount of change, however it's compilant to
glsl than... (is it?!)
Greetings,
Richard
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org