Frapper  1.0a
AnimatableMeshNode.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-2012 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 
34 
35 #ifndef ANIMATABLEMESHNODE_H
36 #define ANIMATABLEMESHNODE_H
37 
38 #include "GeometryNode.h"
39 #include "OgreContainer.h"
40 #include "Ogre.h"
41 #include "OgreTools.h"
42 #include <QtGui/qvector3d.h>
43 
44 namespace AnimatableMeshNode {
45 using namespace Frapper;
46 
51 {
52 
53  Q_OBJECT
55 
56 public: // nested type definitions
57 
61  struct BoneTransform {
62  Ogre::Vector3 translate;
63  Ogre::Vector3 rotate;
64  Ogre::Vector3 size;
65  };
66 
67 public: // constructors and destructors
68 
75  AnimatableMeshNode ( const QString &name, ParameterGroup *parameterRoot );
76 
81 
82 public slots: //
83 
87  void updateAnimation ();
88 
92  void updateBones ();
93 
97  void updatePoses ();
98 
102  void updateAll ();
103 
107  void updateObjectId ();
108 
109 private: // functions
110 
111 
117  bool initAnimationStates ();
118 
124  QStringList getAnimationNames ();
125 
131  QStringList getBoneNames ();
132 
138  void initializeBones ( QStringList boneNames );
139 
145  bool loadMesh ();
146 
151  void updateStatistics ();
152 
157  void destroyEntity ();
158 
166  void progressAnimation ( const QString &animationName, float timeToAdd, float weight = 1.0 );
167 
179  void transformBone ( const QString &name, float &tx, float &ty, float &tz, float &rx, float &ry, float &rz );
180 
184  void parseMaterialParameters ();
185 
193  Ogre::HardwareVertexBufferSharedPtr writeDataToVertices(Ogre::SubMesh* mesh);
194 
202  bool compareVectors(QVector3D* v1, QVector3D* v2);
203 
208  bool isAnimated () const;
209 
210 
211 private slots: //
212 
216  void geometryFileChanged ();
217 
221  void setInterpolationMode ();
222 
226  void setMaterialParameter ();
227 
231  void reloadTexture ();
232 
238  bool setupMaterial ();
239 
245  bool loadLightDescriptionFile ();
246 
250  void setSwitches();
251 
252 private: // data
253 
258 
262  Ogre::Entity *m_entity;
263 
268 
273 
277  QMap<QString, Ogre::AnimationState *> m_animStates;
278 
282  QMap<QString, double> m_animProgresses;
283 
287  QStringList m_animationNames;
288 
292  QStringList m_weightNames;
293 
297  QStringList m_poseNames;
298 
302  QStringList m_boneNames;
303 
307  QMap<QString, Ogre::AnimationState *> m_animStatesVertex;
308 
314 
320 
325 
330 
335 
339  Ogre::TexturePtr m_lightDirsTexture;
340 
344  Ogre::TexturePtr m_lightPowsTexture;
345 
349  bool m_manual;
350 
354  bool m_bones;
355 
360 
365 
366 };
367 
368 } // namespace AnimatableMeshNode
369 #endif