nodeCallBack problem

classic Classic list List threaded Threaded
2 messages Options
cxh860315 cxh860315
Reply | Threaded
Open this post in threaded view
|

nodeCallBack problem

Hey.  
    osg 3.6.5 ,osgEarth 2.10.2, Win10, VS2013 64bit

    I try to add a nodecallback on the subnode of AnimationPathCallback node , let subnode  rotate when

they move. But I debug to find the nodecallback can come into operator() function.

   When i attach the nodecallback to other model node without animationpathcallback, operator()function

can is called,the model can rotate.

 code segment:

        m_cstMT = new osg::MatrixTransform;
    ...........
        m_mairplaneMT = new osg::MatrixTransform;
        m_mairplaneMT->addChild(m_cstMT.get());
        .............
        airplaneAnipathCallback = new osg::AnimationPathCallback(airplaneAnimPath, 0.0, 1.0);
        m_mairplaneMT->setUpdateCallback(airplaneAnipathCallback);

        m_autoRotateCallback = new TM::AutoRotateCallBack;
        m_cstMT ->setUpdateCallback(m_autoRotateCallback);


class AutoRotateCallBack : public osg::NodeCallback
        {
        public:
                AutoRotateCallBack() :_rotateZ(0.0) {}

                virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
                {
                        osg::ref_ptr<osg::MatrixTransform> mt = dynamic_cast<osg::MatrixTransform*>(node);
                        osg::Matrix mx;
                        mx.makeRotate(_rotateZ, osg::Vec3(0.0, 0.0, 1.0));
                        mt->setMatrix(mt->getMatrix()*mx);
                        _rotateZ += 0.1;

                        traverse(node, nv);
                }

        private:
                double _rotateZ;
        };


  I do not know how to solve this problem. hoping for everyone help. Thanks!
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: nodeCallBack problem

Hello,

I recommend you ask this question on the OpenSceneGraph support group. They may be able to help:

https://groups.google.com/g/osg-users

Glenn Waldron / Pelican Mapping