2 * Copyright (C) 2008 Cedric Pinson <cedric.pinson@plopbyte.net>
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.
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.
15#ifndef OSGANIMATION_ANIMATION_MANAGER_BASE
16#define OSGANIMATION_ANIMATION_MANAGER_BASE 1
18#include <osgAnimation/LinkVisitor>
19#include <osgAnimation/Animation>
20#include <osgAnimation/Export>
21#include <osg/FrameStamp>
28 class OSGANIMATION_EXPORT AnimationManagerBase : public osg::NodeCallback
31 typedef std::set<osg::ref_ptr<Target> > TargetSet;
33 AnimationManagerBase();
34 AnimationManagerBase(const AnimationManagerBase& b, const osg::CopyOp& copyop= osg::CopyOp::SHALLOW_COPY);
35 virtual ~AnimationManagerBase();
36 virtual void buildTargetReference();
37 virtual void registerAnimation (Animation*);
38 virtual void unregisterAnimation (Animation*);
39 virtual void link(osg::Node* subgraph);
40 virtual void update(double t) = 0;
41 virtual bool needToLink() const;
42 const AnimationList& getAnimationList() const { return _animations;}
43 AnimationList& getAnimationList() { return _animations;}
45 //uniformisation of the API
46 inline Animation * getRegisteredAnimation(unsigned int i) { return _animations[i].get();}
47 inline unsigned int getNumRegisteredAnimations() const { return _animations.size();}
48 inline void addRegisteredAnimation(Animation* animation)
51 _animations.push_back(animation);
52 buildTargetReference();
54 void removeRegisteredAnimation(Animation* animation);
56 /** Callback method called by the NodeVisitor when visiting a node.*/
57 virtual void operator()(osg::Node* node, osg::NodeVisitor* nv);
59 /** Reset the value of targets
60 this Operation must be done each frame */
63 LinkVisitor* getOrCreateLinkVisitor();
64 void setLinkVisitor(LinkVisitor*);
66 /// set a flag to define the behaviour
67 void setAutomaticLink(bool);
68 bool getAutomaticLink() const;
69 bool isAutomaticLink() const { return getAutomaticLink(); }
74 osg::ref_ptr<LinkVisitor> _linker;
75 AnimationList _animations;