| 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 | |
|---|
| 15 | #ifndef OSGANIMATION_NODE_VISITOR_H |
|---|
| 16 | #define OSGANIMATION_NODE_VISITOR_H |
|---|
| 17 | |
|---|
| 18 | #include <osg/NodeVisitor> |
|---|
| 19 | #include <osg/StateSet> |
|---|
| 20 | #include <osgAnimation/Animation> |
|---|
| 21 | |
|---|
| 22 | namespace osgAnimation |
|---|
| 23 | { |
|---|
| 24 | class AnimationUpdateCallbackBase; |
|---|
| 25 | |
|---|
| 26 | /** This class is instancied by the AnimationManagerBase, it will link animation target to updatecallback that have the same name |
|---|
| 27 | */ |
|---|
| 28 | class OSGANIMATION_EXPORT LinkVisitor : public osg::NodeVisitor |
|---|
| 29 | { |
|---|
| 30 | public: |
|---|
| 31 | LinkVisitor(); |
|---|
| 32 | |
|---|
| 33 | META_NodeVisitor("osgAnimation","LinkVisitor"); |
|---|
| 34 | |
|---|
| 35 | void apply(osg::Node& node); |
|---|
| 36 | void apply(osg::Geode& node); |
|---|
| 37 | |
|---|
| 38 | AnimationList& getAnimationList(); |
|---|
| 39 | void reset(); |
|---|
| 40 | unsigned int getNbLinkedTarget() const { return _nbLinkedTarget; } |
|---|
| 41 | |
|---|
| 42 | protected: |
|---|
| 43 | |
|---|
| 44 | void handle_stateset(osg::StateSet* stateset); |
|---|
| 45 | void link(osgAnimation::AnimationUpdateCallbackBase* cb); |
|---|
| 46 | |
|---|
| 47 | // animation list to link |
|---|
| 48 | AnimationList _animations; |
|---|
| 49 | |
|---|
| 50 | // number of success link done |
|---|
| 51 | unsigned int _nbLinkedTarget; |
|---|
| 52 | }; |
|---|
| 53 | |
|---|
| 54 | } |
|---|
| 55 | |
|---|
| 56 | #endif |
|---|