Hi Hakan,

If you want to simply drag (or do other transformation to) an object you can 
use the Dragger from the osgManipulator pluggin:


Code:

osgManipulator::TranslateAxisDragger




Otherwise you need to project the mouse to the world space.
If I recall correctly:



Code:

    osgViewer::View *view = dynamic_cast<osgViewer::View *>(&actionAdapter);
    const osg::Camera *camera = view->getCamera();

    const osg::Matrixd viewMatrix = camera->getViewMatrix();
    const osg::Matrix projectionMatrix = camera->getProjectionMatrix();
    osg::Matrix inverseCameraMatrix;
    inverseCameraMatrix.invert(viewMatrix * projectionMatrix);
    osg::Vec3 worldPosition = osg::Vec3(ea.getXnormalized(), 
ea.getYnormalized(), 0.0f) *
                    inverseCameraMatrix;




The z value of the Vec3 is the Near Plane, set it to 1.0 to have the Far Plane 
projection.

Best,
Florian

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=72440#72440





_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to