Hi,

I added the pickHandler to my application, and then I applied some changes in 
it to rotate a rod (that is part of an imported osg model) when scrolling the 
mouse on its handle (a geode). 
It picks correctly, but doesn't perform the visual rotation... here is the 
relevant code fragment:

Code:
void BabyFootManipulator::_pickRotate(osgViewer::View* view, const 
osgGA::GUIEventAdapter& ea, double rotation) {
    osgUtil::LineSegmentIntersector::Intersections intersections;

    float x = ea.getX();
    float y = ea.getY();

    if (view->computeIntersections(x, y, intersections)) {
        for (osgUtil::LineSegmentIntersector::Intersections::iterator hitr = 
intersections.begin();
                hitr != intersections.end();
                ++hitr) {
            if (!hitr->nodePath.empty() && 
!(hitr->nodePath.back()->getName().empty())) {
                // the geodes are identified by name.
                osg::Node* node = hitr->nodePath.back();
                if (node->getName() == "handle") {
                    osg::notify(osg::ALWAYS) << "\n\tFound handle.. " ;
                    osg::Group* parent = node->getParent(0);
                    osg::Group* grandpa = parent->getParent(0);
                    osg::Transform* t = grandpa->asTransform();
                    osg::MatrixTransform* mtRod = t->asMatrixTransform();
                    mtRod->setDataVariance(DYNAMIC);
                    osg::notify(osg::ALWAYS) << grandpa->getName() << ": " << 
grandpa->className() << std::endl;
                    osg::Matrix m = mtRod->getMatrix() *
                            osg::Matrix::rotate(rotation, osg::Vec3(0,1,0));
                    mtRod->setMatrix( m );

                    printVector("\t m.rotation =  ", m.getRotate());

                    osg::notify(osg::ALWAYS) << "\tRotation done" << std::endl;
                    return;
                }
            }
        }
    }
}





The output related to that code, when i scroll upon the handle is this:
        Found handle.. mtRod: MatrixTransform
         m.rotation =  (0, -1.00629e-231, 0)
        Rotation done

        Found handle.. mtRod: MatrixTransform
         m.rotation =  (0, -2.01257e-231, 0)
        Rotation done

        Found handle.. mtRod: MatrixTransform
         m.rotation =  (0, -3.01886e-231, 0)
        Rotation done

        Found handle.. mtRod: MatrixTransform
         m.rotation =  (0, -4.02514e-231, 0)
        Rotation done

        Found handle.. mtRod: MatrixTransform
         m.rotation =  (0, -5.03143e-231, 0)
        Rotation done

        Found handle.. mtRod: MatrixTransform
         m.rotation =  (0, -6.03771e-231, 0)
        Rotation done

        Found handle.. mtRod: MatrixTransform
         m.rotation =  (0, -7.044e-231, 0)
        Rotation done

... 

So, how you can see, the matrix is updated, but i can't see any visual 
rotation. What's wrong on my code? What do i forget?
I alwo tried to change the axis of rotation or to apply a translation instead 
of a rotation, but the result is the same...
Can someone help me?

Thank you!

Cheers,
Axel

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





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

Reply via email to