void apply(osg::Node& node)
    {
        if (node.getStateSet()) process(node.getStateSet());

        if (node.getUpdateCallback())
        {
            _operatorList.insert(new CallbackOperator(&node, node.getUpdateCallback()));
        }

        LayerAttributes* la = dynamic_cast<LayerAttributes*>(node.getUserData());
        if (la)
        {
            if ((_objectsHandled[la]++)==0)
            {
                OSG_NOTICE<<"LayerAttributeOperator for "<<la<<" required, assigning one."<<std::endl;
                _operatorList.insert(new LayerAttributesOperator(&node, la));
            }
            else
            {
                OSG_NOTICE<<"LayerAttributeOperator for "<<la<<" not required, as one already assigned."<<std::endl;
            }
        }

        traverse(node);
    }
示例#2
0
    void apply(osg::Node& node)
    {
        if (node.getStateSet()) process(node.getStateSet());

        if (node.getUpdateCallback())
        {
            _operatorList.insert(new CallbackOperator(&node, node.getUpdateCallback()));
        }

        LayerAttributes* la = dynamic_cast<LayerAttributes*>(node.getUserData());
        if (la)
        {
            _operatorList.insert(new LayerAttributesOperator(&node, la));
        }

        traverse(node);
    }
void AnimationCleanerVisitor::collectUpdateCallback(osg::Node& node) {
    osg::Callback *callBack = node.getUpdateCallback();
    while(callBack) {
        BaseAnimationUpdateCallback* update = getCallbackType<BaseAnimationUpdateCallback>(callBack);
        if(update)  {
            _updates[update] = osg::ref_ptr<osg::Node>(&node);
        }
        callBack = callBack->getNestedCallback();
    }
}
示例#4
0
void LinkVisitor::apply(osg::Node& node)
{
    osg::StateSet* st = node.getStateSet();
    if (st)
        handle_stateset(st);

    osg::NodeCallback* cb = node.getUpdateCallback();
    while (cb)
    {
        osgAnimation::AnimationUpdateCallbackBase* cba = dynamic_cast<osgAnimation::AnimationUpdateCallbackBase*>(cb);
        if (cba)
            link(cba);
        cb = cb->getNestedCallback();
    }
    traverse(node);
}
 void apply(osg::Node& node) {
     if (_am.valid()){
         osgAnimation::Animation * anim=_am->getRegisteredAnimation(0);
         OSG_WARN<<"aim0"<<anim->getName()<<std::endl;
         return;
         }
     if (node.getUpdateCallback()) {
         osgAnimation::AnimationManagerBase* b = dynamic_cast<osgAnimation::AnimationManagerBase*>(node.getUpdateCallback());
         if (b) {
          osgAnimation::Animation * anim=b->getRegisteredAnimation(0);
         OSG_WARN<<"aim0"<<anim->getName()<<std::endl;
             _am = new osgAnimation::BasicAnimationManager(*b);
             return;
         }
     }
     traverse(node);
 }
示例#6
0
文件: daenim.cpp 项目: salini/daenim
 void apply(osg::Node& node)
 {
     if (_animManager.valid())
     {
         return;
     }
     if (node.getUpdateCallback())
     {
         osgAnimation::AnimationManagerBase* b = dynamic_cast<osgAnimation::AnimationManagerBase*>(node.getUpdateCallback());
         if (b)
         {
             _animManager = new osgAnimation::BasicAnimationManager(*b);
             return;
         }
     }
     traverse(node);
 }
示例#7
0
    void apply(osg::Node& node) {
        if (_am.valid())
            return;
        if (node.getUpdateCallback()) {
            osgAnimation::AnimationManagerBase* b = dynamic_cast<osgAnimation::AnimationManagerBase*>(node.getUpdateCallback());
			if (b) {
				_am = new osgAnimation::BasicAnimationManager(*b);
				const osgAnimation::AnimationList & pAL = b->getAnimationList();
				for(osgAnimation::AnimationList::const_iterator citAL = pAL.begin();
					citAL != pAL.end();
					citAL++) {

						osgAnimation::ChannelList & channelList = (*citAL)->getChannels();
						for(osgAnimation::ChannelList::iterator itCL = channelList.begin();
							itCL != channelList.end();
							itCL++) {
								osgAnimation::Sampler * pSampler = (*itCL)->getSampler();
								osgAnimation::KeyframeContainer * pKFC = pSampler->getKeyframeContainer();

								{
									osgAnimation::TemplateKeyframeContainer<osg::Vec3f> *pTKFC_Vec3f =
										dynamic_cast<osgAnimation::TemplateKeyframeContainer<osg::Vec3f> *>(pKFC);
									if((pTKFC_Vec3f != 0) && (pTKFC_Vec3f->size() > 199)) {
										pTKFC_Vec3f->erase(pTKFC_Vec3f->begin()+110, pTKFC_Vec3f->end());
									}
								}
								{

									osgAnimation::TemplateKeyframeContainer<osg::Quat> *pTKFC_Quat =
										dynamic_cast<osgAnimation::TemplateKeyframeContainer<osg::Quat> *>(pKFC);
									if((pTKFC_Quat != 0) && (pTKFC_Quat->size() > 199)) {
										pTKFC_Quat->erase(pTKFC_Quat->begin()+110, pTKFC_Quat->end());
									}
								}
						}		
				}

//				osgDB::writeNodeFile(node,"C:/Matej/test.osg");
                return;
            }
        }
        traverse(node);
    }
示例#8
0
    void ControllerVisitor::apply(osg::Node &node)
    {
        osg::Callback* callback = node.getUpdateCallback();
        while (callback)
        {
            if (Controller* ctrl = dynamic_cast<Controller*>(callback))
                visit(node, *ctrl);
            if (CompositeStateSetUpdater* composite = dynamic_cast<CompositeStateSetUpdater*>(callback))
            {
                for (unsigned int i=0; i<composite->getNumControllers(); ++i)
                {
                    StateSetUpdater* statesetcontroller = composite->getController(i);
                    if (Controller* ctrl = dynamic_cast<Controller*>(statesetcontroller))
                        visit(node, *ctrl);
                }
            }

            callback = callback->getNestedCallback();
        }

        traverse(node);
    }
void AnimationCleanerVisitor::apply(osg::Node& node) {
    osgAnimation::BasicAnimationManager* manager = getCallbackType<osgAnimation::BasicAnimationManager>(node.getUpdateCallback());
    if(manager) {
        _managers[manager] = osg::ref_ptr<osg::Node>(&node);
        collectAnimationChannels(*manager);
    }

    collectUpdateCallback(node);

    traverse(node);
}