Hello Vincent,

Last, If I try InfinitePlane (referenced node), this is just a drawable, so it getNormal() method always return me the same value... whatever be the Dragger state. And I need a plane normal() in world coordinate...

That's just because the normal is in local coordinates. Transform it with the accumulated local-to-world matrix. To transform a vector, you need to multiply it by the inverse transpose of upper 3x3 part of the transformation matrix, which in OSG can be done by pre-multiplying instead of post-multiplying and using osg::Matrix::transform3x3, with the inverse local-to-world, or the world-to-local.

inline osg::Vec3f transform_position(const osg::Vec3f& position,
                                     const osg::Matrixd& localToWorld)
{
    // v' = v * Mlw
    osg::Vec3f transformed_position = position * localToWorld;
    return transformed_position;
}

inline osg::Vec3f transform_normal(const osg::Vec3f& normal,
                                   const osg::Matrixd& invLocalToWorld)
{
    // Normal must be multiplied by the inverse of the transpose of the
    // local-to-world matrix : (Mlw ^ -1) ^ t
    // V' = M * V is the same as V' = V * M^t where M^t is the
    // transpose of M.
    // n' = n * (Mlw^-1)^t
    osg::Vec3f transformed_normal =
        osg::Matrix::transform3x3(invLocalToWorld, normal);
    transformed_normal.normalize();
    return transformed_normal;
}


J-S
--
______________________________________________________
Jean-Sebastien Guay    jean-sebastien.g...@cm-labs.com
                               http://www.cm-labs.com/
                        http://whitestar02.webhop.org/
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to