- Timestamp:
- 03/21/12 18:36:20 (14 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/include/osgPresentation/AnimationMaterial
r12139 r13041 1 /* -*-c++-*- Present3D - Copyright (C) 1999-2006 Robert Osfield 1 /* -*-c++-*- Present3D - Copyright (C) 1999-2006 Robert Osfield 2 2 * 3 * This software is open source and may be redistributed and/or modified under 3 * This software is open source and may be redistributed and/or modified under 4 4 * the terms of the GNU General Public License (GPL) version 2.0. 5 5 * The full license is in LICENSE.txt file included with this distribution,. 6 * 6 * 7 7 * This software is distributed in the hope that it will be useful, 8 8 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 10 * include LICENSE.txt for more details. 11 11 */ … … 32 32 { 33 33 public: 34 34 35 35 AnimationMaterial():_loopMode(LOOP) {} 36 36 … … 43 43 44 44 45 /** get the transformation matrix for a point in time.*/ 45 /** get the transformation matrix for a point in time.*/ 46 46 bool getMaterial(double time,osg::Material& material) const; 47 47 48 48 void insert(double time,osg::Material* material); 49 49 50 50 double getFirstTime() const { if (!_timeControlPointMap.empty()) return _timeControlPointMap.begin()->first; else return 0.0;} 51 51 double getLastTime() const { if (!_timeControlPointMap.empty()) return _timeControlPointMap.rbegin()->first; else return 0.0;} 52 52 double getPeriod() const { return getLastTime()-getFirstTime();} 53 53 54 54 enum LoopMode 55 55 { … … 58 58 NO_LOOPING 59 59 }; 60 60 61 61 void setLoopMode(LoopMode lm) { _loopMode = lm; } 62 62 63 63 LoopMode getLoopMode() const { return _loopMode; } 64 64 65 65 66 66 typedef std::map<double, osg::ref_ptr<osg::Material> > TimeControlPointMap; 67 67 68 68 TimeControlPointMap& getTimeControlPointMap() { return _timeControlPointMap; } 69 69 70 70 const TimeControlPointMap& getTimeControlPointMap() const { return _timeControlPointMap; } 71 71 72 72 /** read the anumation path from a flat ascii file stream.*/ 73 73 void read(std::istream& in); … … 75 75 /** write the anumation path to a flat ascii file stream.*/ 76 76 void write(std::ostream& out) const; 77 77 78 78 bool requiresBlending() const; 79 79 80 80 protected: 81 81 82 82 virtual ~AnimationMaterial() {} 83 83 84 84 void interpolate(osg::Material& material, float r, const osg::Material& lhs,const osg::Material& rhs) const; 85 85 … … 101 101 _pause(false), 102 102 _pauseTime(0.0) {} 103 103 104 104 105 105 AnimationMaterialCallback(const AnimationMaterialCallback& apc,const osg::CopyOp& copyop): … … 114 114 _pauseTime(apc._pauseTime) {} 115 115 116 116 117 117 META_Object(osg,AnimationMaterialCallback); 118 118 … … 126 126 _pause(false), 127 127 _pauseTime(0.0) {} 128 128 129 129 void setAnimationMaterial(AnimationMaterial* path) { _animationMaterial = path; } 130 130 … … 132 132 133 133 const AnimationMaterial* getAnimationMaterial() const { return _animationMaterial.get(); } 134 134 135 135 void setTimeOffset(double offset) { _timeOffset = offset; } 136 136 double getTimeOffset() const { return _timeOffset; } 137 137 138 138 void setTimeMultiplier(double multiplier) { _timeMultiplier = multiplier; } 139 139 double getTimeMultiplier() const { return _timeMultiplier; } … … 149 149 /** implements the callback*/ 150 150 virtual void operator()(osg::Node* node, osg::NodeVisitor* nv); 151 151 152 152 void update(osg::Node& node); 153 153 … … 164 164 165 165 protected: 166 166 167 167 ~AnimationMaterialCallback(){} 168 168
