Frapper  1.0a
MocapMeshNode.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 MOCAPMESHNODE_H
36 #define MOCAPMESHNODE_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 
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  MocapMeshNode ( const QString &name, ParameterGroup *parameterRoot );
76 
80  ~MocapMeshNode ();
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  void transformBone( const QString &name, const Ogre::Quaternion &q, const Ogre::Vector3& position );
181 
182 
183 
188  void setupBones();
189 
193  void parseMaterialParameters ();
194 
202  Ogre::HardwareVertexBufferSharedPtr writeDataToVertices(Ogre::SubMesh* mesh);
203 
211  bool compareVectors(QVector3D* v1, QVector3D* v2);
212 
217  bool isAnimated () const;
218 
219 private slots: //
220 
224  void geometryFileChanged ();
225 
229  void setInterpolationMode ();
230 
234  void setMaterialParameter ();
235 
239  void reloadTexture ();
240 
246  bool setupMaterial ();
247 
253  bool loadLightDescriptionFile ();
254 
258  void setSwitches();
259 
263  //void initPosition();
264 
265 private: // data
266 
271 
275  Ogre::Entity *m_entity;
276 
281 
286 
290  QMap<QString, Ogre::AnimationState *> m_animStates;
291 
295  QMap<QString, double> m_animProgresses;
296 
300  QStringList m_animationNames;
301 
305  QStringList m_weightNames;
306 
310  QStringList m_poseNames;
311 
315  QStringList m_boneNames;
316 
320  QMap<QString, Ogre::AnimationState *> m_animStatesVertex;
321 
327 
333 
338 
343 
348 
352  Ogre::TexturePtr m_lightDirsTexture;
353 
357  Ogre::TexturePtr m_lightPowsTexture;
358 
362  bool m_manual;
363 
367  bool m_bones;
368 
373 
378 
380 
381  Ogre::Quaternion quat;
382 
383 
384  QList<Ogre::Vector3> m_jointInitPos;
385 
386 };
387 
388 
389 #endif