LinkVisitor 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* -*-c++-*-
  2. * Copyright (C) 2008 Cedric Pinson <cedric.pinson@plopbyte.net>
  3. *
  4. * This library is open source and may be redistributed and/or modified under
  5. * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
  6. * (at your option) any later version. The full license is in LICENSE file
  7. * included with this distribution, and on the openscenegraph.org website.
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * OpenSceneGraph Public License for more details.
  13. */
  14. #ifndef OSGANIMATION_NODE_VISITOR_H
  15. #define OSGANIMATION_NODE_VISITOR_H
  16. #include <osg/NodeVisitor>
  17. #include <osg/StateSet>
  18. #include <osgAnimation/Animation>
  19. namespace osgAnimation
  20. {
  21. class AnimationUpdateCallbackBase;
  22. /** This class is instancied by the AnimationManagerBase, it will link animation target to updatecallback that have the same name
  23. */
  24. class OSGANIMATION_EXPORT LinkVisitor : public osg::NodeVisitor
  25. {
  26. public:
  27. LinkVisitor();
  28. META_NodeVisitor(osgAnimation, LinkVisitor);
  29. void apply(osg::Node& node);
  30. void apply(osg::Geode& node);
  31. AnimationList& getAnimationList();
  32. void reset();
  33. unsigned int getNbLinkedTarget() const { return _nbLinkedTarget; }
  34. protected:
  35. void handle_stateset(osg::StateSet* stateset);
  36. void link(osgAnimation::AnimationUpdateCallbackBase* cb);
  37. // animation list to link
  38. AnimationList _animations;
  39. // number of success link done
  40. unsigned int _nbLinkedTarget;
  41. };
  42. }
  43. #endif