root/OpenSceneGraph/trunk/include/osgAnimation/Keyframe @ 11009

Revision 11009, 4.5 kB (checked in by robert, 5 years ago)

From Cedric Pinson, "Here a list of changes:
Bone now inherit from MatrixTransform?. It simplify a lot the update of
Bone matrix. It helps to have the bone system more generic. eg it's now
possible to have animation data with precomputed bind matrix. The other
benefit, is now the collada plugin will be able to use osgAnimation to
display skinned mesh. Michael Plating did a great work to improve this
aspect, he is working on the collada plugin and should be able to submit
a new version soon.
The RigGeometry? has been refactored so now it works when you save and
reload RigGeometry? because the source is not touched anymore. The
benefit with this update is that it should be now possible to use a
MorphGeometry? as source for a RigGeometry?.

The bad news is that the format has changed, so i have rebuild osg-data
related to osgAnimation data, updated the blender exporter to export to
the new format.
The fbx plugin could be touched about this commit, i dont compile it so
i can't give more information about it.
The bvh plugin has been updated by Wang rui so this one is fixed with
the new code of osgAnimation.
The examples has been updated to work with the new code too...

The example osg-data/example.osg should be remove, it's an old example
that does not work.

For people using blender the blender exporter up to date is here:
http://hg.plopbyte.net/osgexport2/
it will be merge to http://hg.plopbyte.net/osgexport/ as soon as the
modification will be push in the trunk.
"

RevLine 
[9093]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>
[11009]26#include <osg/Matrixf>
[9093]27
28namespace osgAnimation
29{
30
31    class Keyframe
32    {
33    public:
34        float getTime() const { return _time; }
35        void setTime(float time) { _time = time; }
36             
37    protected:
38        float _time;
39
40    };
41
42    template <class T>
43    class TemplateKeyframe : public Keyframe
44    {
45    protected:
46        T _value;
47    public:
48        TemplateKeyframe () {}
49        ~TemplateKeyframe () {}
50
51        TemplateKeyframe (float 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
62    class KeyframeContainer : public osg::Referenced
63    {
64    public:
65        KeyframeContainer() {}
66        virtual unsigned int size() const = 0;
67    protected:
68        ~KeyframeContainer() {}
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 ;}
78        TemplateKeyframeContainer() {}
79        typedef TemplateKeyframe<T> KeyType;
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:
89        typedef TemplateKeyframe<Vec3Packed> KeyType;
90
91        TemplateKeyframeContainer() {}
92        const char* getKeyframeType() { return "Vec3Packed" ;}
93        void init(const osg::Vec3f& min, const osg::Vec3f& scale) { _min = min; _scale = scale; }
94
95        osg::Vec3f _min;
96        osg::Vec3f _scale;
97    };
98
99
100    typedef TemplateKeyframe<float> FloatKeyframe;
101    typedef TemplateKeyframeContainer<float> FloatKeyframeContainer;
[9877]102   
103    typedef TemplateKeyframe<double> DoubleKeyframe;
104    typedef TemplateKeyframeContainer<double> DoubleKeyframeContainer;   
[9093]105
106    typedef TemplateKeyframe<osg::Vec2> Vec2Keyframe;
107    typedef TemplateKeyframeContainer<osg::Vec2> Vec2KeyframeContainer;
108
109    typedef TemplateKeyframe<osg::Vec3> Vec3Keyframe;
110    typedef TemplateKeyframeContainer<osg::Vec3> Vec3KeyframeContainer;
111
112    typedef TemplateKeyframe<osg::Vec4> Vec4Keyframe;
113    typedef TemplateKeyframeContainer<osg::Vec4> Vec4KeyframeContainer;
114
115    typedef TemplateKeyframe<osg::Quat> QuatKeyframe;
116    typedef TemplateKeyframeContainer<osg::Quat> QuatKeyframeContainer;
117
[11009]118    typedef TemplateKeyframe<osg::Matrixf> MatrixKeyframe;
119    typedef TemplateKeyframeContainer<osg::Matrixf> MatrixKeyframeContainer;
120
[9093]121    typedef TemplateKeyframe<Vec3Packed> Vec3PackedKeyframe;
122    typedef TemplateKeyframeContainer<Vec3Packed> Vec3PackedKeyframeContainer;
123
124    typedef TemplateKeyframe<FloatCubicBezier> FloatCubicBezierKeyframe;
125    typedef TemplateKeyframeContainer<FloatCubicBezier> FloatCubicBezierKeyframeContainer;
[9877]126   
[9093]127    typedef TemplateKeyframe<DoubleCubicBezier> DoubleCubicBezierKeyframe;
128    typedef TemplateKeyframeContainer<DoubleCubicBezier> DoubleCubicBezierKeyframeContainer;
[9877]129   
[9093]130    typedef TemplateKeyframe<Vec2CubicBezier> Vec2CubicBezierKeyframe;
131    typedef TemplateKeyframeContainer<Vec2CubicBezier> Vec2CubicBezierKeyframeContainer;
[9877]132   
[9093]133    typedef TemplateKeyframe<Vec3CubicBezier> Vec3CubicBezierKeyframe;
134    typedef TemplateKeyframeContainer<Vec3CubicBezier> Vec3CubicBezierKeyframeContainer;
[9877]135   
[9093]136    typedef TemplateKeyframe<Vec4CubicBezier> Vec4CubicBezierKeyframe;
137    typedef TemplateKeyframeContainer<Vec4CubicBezier> Vec4CubicBezierKeyframeContainer;
138
139}
140
141#endif
Note: See TracBrowser for help on using the browser.