/* -*-c++-*- * Copyright (C) 2008 Cedric Pinson * * This library is open source and may be redistributed and/or modified under * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or * (at your option) any later version. The full license is in LICENSE file * included with this distribution, and on the openscenegraph.org website. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * OpenSceneGraph Public License for more details. */ #ifndef OSGANIMATION_KEYFRAME_H #define OSGANIMATION_KEYFRAME_H #include #include #include #include #include #include #include #include #include namespace osgAnimation { class Keyframe { public: double getTime() const { return _time; } void setTime(double time) { _time = time; } protected: double _time; }; template class TemplateKeyframe : public Keyframe { protected: T _value; public: TemplateKeyframe () {} ~TemplateKeyframe () {} TemplateKeyframe (double time, const T& value) { _time = time; _value = value; } void setValue(const T& value) { _value = value;} const T& getValue() const { return _value;} }; class KeyframeContainer : public osg::Referenced { public: KeyframeContainer() {} virtual unsigned int size() const = 0; protected: ~KeyframeContainer() {} std::string _name; }; template class TemplateKeyframeContainer : public std::vector >, public KeyframeContainer { public: // const char* getKeyframeType() { return #T ;} TemplateKeyframeContainer() {} typedef TemplateKeyframe KeyType; virtual unsigned int size() const { return (unsigned int)std::vector >::size(); } }; template <> class TemplateKeyframeContainer : public std::vector >, public KeyframeContainer { public: typedef TemplateKeyframe KeyType; TemplateKeyframeContainer() {} const char* getKeyframeType() { return "Vec3Packed" ;} void init(const osg::Vec3f& min, const osg::Vec3f& scale) { _min = min; _scale = scale; } osg::Vec3f _min; osg::Vec3f _scale; }; typedef TemplateKeyframe FloatKeyframe; typedef TemplateKeyframeContainer FloatKeyframeContainer; typedef TemplateKeyframe DoubleKeyframe; typedef TemplateKeyframeContainer DoubleKeyframeContainer; typedef TemplateKeyframe Vec2Keyframe; typedef TemplateKeyframeContainer Vec2KeyframeContainer; typedef TemplateKeyframe Vec3Keyframe; typedef TemplateKeyframeContainer Vec3KeyframeContainer; typedef TemplateKeyframe Vec4Keyframe; typedef TemplateKeyframeContainer Vec4KeyframeContainer; typedef TemplateKeyframe QuatKeyframe; typedef TemplateKeyframeContainer QuatKeyframeContainer; typedef TemplateKeyframe MatrixKeyframe; typedef TemplateKeyframeContainer MatrixKeyframeContainer; typedef TemplateKeyframe Vec3PackedKeyframe; typedef TemplateKeyframeContainer Vec3PackedKeyframeContainer; typedef TemplateKeyframe FloatCubicBezierKeyframe; typedef TemplateKeyframeContainer FloatCubicBezierKeyframeContainer; typedef TemplateKeyframe DoubleCubicBezierKeyframe; typedef TemplateKeyframeContainer DoubleCubicBezierKeyframeContainer; typedef TemplateKeyframe Vec2CubicBezierKeyframe; typedef TemplateKeyframeContainer Vec2CubicBezierKeyframeContainer; typedef TemplateKeyframe Vec3CubicBezierKeyframe; typedef TemplateKeyframeContainer Vec3CubicBezierKeyframeContainer; typedef TemplateKeyframe Vec4CubicBezierKeyframe; typedef TemplateKeyframeContainer Vec4CubicBezierKeyframeContainer; } #endif