| 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_ANIMATION_MANAGER_BASE |
|---|
| 16 | #define OSGANIMATION_ANIMATION_MANAGER_BASE 1 |
|---|
| 17 | |
|---|
| 18 | #include <osgAnimation/LinkVisitor> |
|---|
| 19 | #include <osgAnimation/Animation> |
|---|
| 20 | #include <osgAnimation/Export> |
|---|
| 21 | #include <osg/FrameStamp> |
|---|
| 22 | #include <osg/Group> |
|---|
| 23 | |
|---|
| 24 | |
|---|
| 25 | |
|---|
| 26 | namespace osgAnimation |
|---|
| 27 | { |
|---|
| 28 | class OSGANIMATION_EXPORT AnimationManagerBase : public osg::NodeCallback |
|---|
| 29 | { |
|---|
| 30 | public: |
|---|
| 31 | typedef std::set<osg::ref_ptr<Target> > TargetSet; |
|---|
| 32 | |
|---|
| 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 | |
|---|
| 44 | /** Callback method called by the NodeVisitor when visiting a node.*/ |
|---|
| 45 | virtual void operator()(osg::Node* node, osg::NodeVisitor* nv); |
|---|
| 46 | |
|---|
| 47 | /** Reset the value of targets |
|---|
| 48 | this Operation must be done each frame */ |
|---|
| 49 | void clearTargets(); |
|---|
| 50 | |
|---|
| 51 | |
|---|
| 52 | LinkVisitor* getOrCreateLinkVisitor(); |
|---|
| 53 | void setLinkVisitor(LinkVisitor*); |
|---|
| 54 | |
|---|
| 55 | /// set a flag to define the behaviour |
|---|
| 56 | void setAutomaticLink(bool); |
|---|
| 57 | bool getAutomaticLink() const; |
|---|
| 58 | bool isAutomaticLink() const { return getAutomaticLink(); } |
|---|
| 59 | void dirty(); |
|---|
| 60 | |
|---|
| 61 | protected: |
|---|
| 62 | |
|---|
| 63 | osg::ref_ptr<LinkVisitor> _linker; |
|---|
| 64 | AnimationList _animations; |
|---|
| 65 | TargetSet _targets; |
|---|
| 66 | bool _needToLink; |
|---|
| 67 | bool _automaticLink; |
|---|
| 68 | }; |
|---|
| 69 | } |
|---|
| 70 | #endif |
|---|