OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Keyframe.h
Go to the documentation of this file.
1 /* -*-c++-*-
2  * Copyright (C) 2008 Cedric Pinson <mornifle@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_KEYFRAME_H
16 #define OSGANIMATION_KEYFRAME_H
17 
18 #include <string>
19 #include <osg/Referenced>
20 #include <osgAnimation/Vec3Packed>
21 #include <osgAnimation/CubicBezier>
22 #include <osg/Quat>
23 #include <osg/Vec4>
24 #include <osg/Vec3>
25 #include <osg/Vec2>
26 #include <osg/Matrixf>
27 
28 namespace osgAnimation
29 {
30 
31  class Keyframe
32  {
33  public:
34  double getTime() const { return _time; }
35  void setTime(double time) { _time = time; }
36 
37  protected:
38  double _time;
39 
40  };
41 
42  template <class T>
43  class TemplateKeyframe : public Keyframe
44  {
45  protected:
46  T _value;
47  public:
50 
51  TemplateKeyframe (double time, const T& value)
52  {
53  _time = time;
54  _value = value;
55  }
56 
57  void setValue(const T& value) { _value = value;}
58  const T& getValue() const { return _value;}
59  };
60 
61 
63  {
64  public:
66  virtual unsigned int size() const = 0;
67  protected:
69  std::string _name;
70  };
71 
72 
73  template <class T>
74  class TemplateKeyframeContainer : public std::vector<TemplateKeyframe<T> >, public KeyframeContainer
75  {
76  public:
77  // const char* getKeyframeType() { return #T ;}
80 
81  virtual unsigned int size() const { return (unsigned int)std::vector<TemplateKeyframe<T> >::size(); }
82 
83  };
84 
85  template <>
86  class TemplateKeyframeContainer<Vec3Packed> : public std::vector<TemplateKeyframe<Vec3Packed> >, public KeyframeContainer
87  {
88  public:
90 
92  const char* getKeyframeType() { return "Vec3Packed" ;}
93  void init(const osg::Vec3f& min, const osg::Vec3f& scale) { _min = min; _scale = scale; }
94 
97  };
98 
99 
102 
105 
108 
111 
114 
117 
120 
123 
126 
129 
132 
135 
138 
139 }
140 
141 #endif
virtual unsigned int size() const
Definition: Keyframe.h:81
TemplateKeyframeContainer< osg::Vec2 > Vec2KeyframeContainer
Definition: Keyframe.h:107
TemplateKeyframeContainer< float > FloatKeyframeContainer
Definition: Keyframe.h:101
TemplateKeyframeContainer< osg::Matrixf > MatrixKeyframeContainer
Definition: Keyframe.h:119
TemplateKeyframe< osg::Vec3 > Vec3Keyframe
Definition: Keyframe.h:109
void init(const osg::Vec3f &min, const osg::Vec3f &scale)
Definition: Keyframe.h:93
void setValue(const T &value)
Definition: Keyframe.h:57
TemplateKeyframeContainer< Vec4CubicBezier > Vec4CubicBezierKeyframeContainer
Definition: Keyframe.h:137
TemplateKeyframe< Vec3Packed > Vec3PackedKeyframe
Definition: Keyframe.h:121
TemplateKeyframeContainer< Vec3Packed > Vec3PackedKeyframeContainer
Definition: Keyframe.h:122
TemplateKeyframe< Vec3CubicBezier > Vec3CubicBezierKeyframe
Definition: Keyframe.h:133
TemplateKeyframeContainer< osg::Vec3 > Vec3KeyframeContainer
Definition: Keyframe.h:110
TemplateKeyframe< osg::Quat > QuatKeyframe
Definition: Keyframe.h:115
TemplateKeyframeContainer< osg::Quat > QuatKeyframeContainer
Definition: Keyframe.h:116
TemplateKeyframe< Vec3Packed > KeyType
Definition: Keyframe.h:89
TemplateKeyframeContainer< DoubleCubicBezier > DoubleCubicBezierKeyframeContainer
Definition: Keyframe.h:128
TemplateKeyframe(double time, const T &value)
Definition: Keyframe.h:51
TemplateKeyframe< float > FloatKeyframe
Definition: Keyframe.h:100
TemplateKeyframe< osg::Matrixf > MatrixKeyframe
Definition: Keyframe.h:118
TemplateKeyframeContainer< double > DoubleKeyframeContainer
Definition: Keyframe.h:104
TemplateKeyframeContainer< osg::Vec4 > Vec4KeyframeContainer
Definition: Keyframe.h:113
TemplateKeyframeContainer< FloatCubicBezier > FloatCubicBezierKeyframeContainer
Definition: Keyframe.h:125
TemplateKeyframe< DoubleCubicBezier > DoubleCubicBezierKeyframe
Definition: Keyframe.h:127
TemplateKeyframe< T > KeyType
Definition: Keyframe.h:79
TemplateKeyframeContainer< Vec2CubicBezier > Vec2CubicBezierKeyframeContainer
Definition: Keyframe.h:131
TemplateKeyframe< Vec2CubicBezier > Vec2CubicBezierKeyframe
Definition: Keyframe.h:130
TemplateKeyframe< double > DoubleKeyframe
Definition: Keyframe.h:103
const T & getValue() const
Definition: Keyframe.h:58
TemplateKeyframe< osg::Vec2 > Vec2Keyframe
Definition: Keyframe.h:106
TemplateKeyframe< osg::Vec4 > Vec4Keyframe
Definition: Keyframe.h:112
TemplateKeyframe< Vec4CubicBezier > Vec4CubicBezierKeyframe
Definition: Keyframe.h:136
TemplateKeyframe< FloatCubicBezier > FloatCubicBezierKeyframe
Definition: Keyframe.h:124
TemplateKeyframeContainer< Vec3CubicBezier > Vec3CubicBezierKeyframeContainer
Definition: Keyframe.h:134
double getTime() const
Definition: Keyframe.h:34
void setTime(double time)
Definition: Keyframe.h:35
virtual unsigned int size() const =0