Frapper  1.0a
AnimationClipNode.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of FRAPPER
4 research.animationsinstitut.de
5 sourceforge.net/projects/frapper
6 
7 Copyright (c) 2008-2009 Filmakademie Baden-Wuerttemberg, Institute of Animation
8 
9 This program is free software; you can redistribute it and/or modify it under
10 the terms of the GNU Lesser General Public License as published by the Free Software
11 Foundation; version 2.1 of the License.
12 
13 This program is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16 
17 You should have received a copy of the GNU Lesser General Public License along with
18 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
20 http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
21 -----------------------------------------------------------------------------
22 */
23 
33 
34 #ifndef ANIMATIONCLIPNODE_H
35 #define ANIMATIONCLIPNODE_H
36 
37 #include "Node.h"
38 #include <QtGui/QColor>
39 #include <QtCore/QVariant>
40 #include <QtGui/QStandardItem>
41 #include <QtCore/QTimer>
42 #include <QtCore/QTime>
43 
44 // OGRE
45 #include "Ogre.h"
46 #if (OGRE_PLATFORM == OGRE_PLATFORM_WIN32)
47 #include <windows.h>
48 #endif
49 
50 namespace AnimationClipNode {
51 using namespace Frapper;
52 
56 struct AnimCurve
57 {
58 
59 public: // constructors and destructors
60 
62  {
63  }
64 
66  {
67  keys.clear();
68  }
69 
70 public: // data
71 
72  QString name;
73  double length;
74  QMap<double, double> keys;
75 
76 };
77 
78 
83 class AnimationClipNode : public Node
84 {
85 
86  Q_OBJECT
88 
89 public: // constructors and destructors
90 
97  AnimationClipNode ( QString name, ParameterGroup *parameterRoot );
98 
102  ~AnimationClipNode ();
103 
104 public: // functions
105 
111  //bool process ( const QString& connectorName );
112 
118  virtual void setUpTimeDependencies ( Parameter *timeParameter );
119 
120 public slots: //
121 
127  void animationClipFileChanged ();
128 
132  void processAnimationParameter();
133 
137  void toggleInterpolationMode();
138 
142  void toggleOffsetAnimation();
143 
147  void updateTimer ();
148 
152  void triggerReload ();
153 
154 
155 protected: // functions
156 
162  void parseAnimationFile ( const QString &filename );
163 
170  void createAnimationCurves ( QString clipName, double clipLength );
171 
175  bool loadAnimationClip ();
176 
180  bool removeParameters ();
181 
185  bool generateParameters();
186 
187 private slots: //
188 
192  void increaseFrameCount ();
193 
197  void resetFrameCount ();
198 
199 private: // data
200 
204  QStringList m_groupSuffixes;
205  QStringList m_boneSuffixes;
206  QStringList m_translateSuffixes;
207  QStringList m_rotateSuffixes;
208  QStringList m_scaleSuffixes;
209  QMap<QString, QMap<QString, double> > m_parameterMap;
210  QMap<QString, unsigned short> m_forwCurveMap;
211  QMap<unsigned short, QString> m_backwCurveMap;
212  QMap<QString, AnimCurve*> m_animCurves;
213  Ogre::Animation* m_animation;
214  QTimer *m_timer;
218  bool m_stop;
220  double m_progress;
222 
223 };
224 } // namespace AnimationClipNode
225 
226 #endif