1 | //////////////////////////////////////////////////////////////////////////////// |
---|
2 | // skeleton.h |
---|
3 | // Author : Francesco Giordana |
---|
4 | // Start Date : January 13, 2005 |
---|
5 | // Copyright : (C) 2006 by Francesco Giordana |
---|
6 | // Email : fra.giordana@tiscali.it |
---|
7 | //////////////////////////////////////////////////////////////////////////////// |
---|
8 | |
---|
9 | /********************************************************************************* |
---|
10 | * * |
---|
11 | * This program is free software; you can redistribute it and/or modify * |
---|
12 | * it under the terms of the GNU Lesser General Public License as published by * |
---|
13 | * the Free Software Foundation; either version 2 of the License, or * |
---|
14 | * (at your option) any later version. * |
---|
15 | * * |
---|
16 | **********************************************************************************/ |
---|
17 | |
---|
18 | #ifndef _SKELETON_H |
---|
19 | #define _SKELETON_H |
---|
20 | |
---|
21 | #include "mayaExportLayer.h" |
---|
22 | #include "paramList.h" |
---|
23 | #include "animation.h" |
---|
24 | |
---|
25 | namespace OgreMayaExporter |
---|
26 | { |
---|
27 | /***** structure to hold joint info *****/ |
---|
28 | typedef struct jointTag |
---|
29 | { |
---|
30 | MString name; |
---|
31 | int id; |
---|
32 | MMatrix localMatrix; |
---|
33 | MMatrix bindMatrix; |
---|
34 | int parentIndex; |
---|
35 | double posx,posy,posz; |
---|
36 | double angle; |
---|
37 | double axisx,axisy,axisz; |
---|
38 | float scalex,scaley,scalez; |
---|
39 | MDagPath jointDag; |
---|
40 | } joint; |
---|
41 | |
---|
42 | |
---|
43 | /*********** Class Skeleton **********************/ |
---|
44 | class Skeleton |
---|
45 | { |
---|
46 | public: |
---|
47 | //constructor |
---|
48 | Skeleton(); |
---|
49 | //destructor |
---|
50 | ~Skeleton(); |
---|
51 | //clear skeleton data |
---|
52 | void clear(); |
---|
53 | //load skeleton data |
---|
54 | MStatus load(MFnSkinCluster* pSkinCluster,ParamList& params); |
---|
55 | //load skeletal animations |
---|
56 | MStatus loadAnims(ParamList& params); |
---|
57 | //get joints |
---|
58 | std::vector<joint>& getJoints(); |
---|
59 | //get animations |
---|
60 | std::vector<Animation>& getAnimations(); |
---|
61 | //restore skeleton pose |
---|
62 | void restorePose(); |
---|
63 | //write to an OGRE binary skeleton |
---|
64 | MStatus writeOgreBinary(ParamList ¶ms); |
---|
65 | |
---|
66 | protected: |
---|
67 | //load a joint |
---|
68 | MStatus loadJoint(MDagPath& jointDag, joint* parent, ParamList& params,MFnSkinCluster* pSkinCluster); |
---|
69 | //load a clip |
---|
70 | MStatus loadClip(MString clipName,float start,float stop,float rate,ParamList& params); |
---|
71 | //load a keyframe for a particular joint at current time |
---|
72 | skeletonKeyframe loadKeyframe(joint& j,float time,ParamList& params); |
---|
73 | //write joints to an Ogre skeleton |
---|
74 | MStatus createOgreBones(Ogre::SkeletonPtr pSkeleton,ParamList& params); |
---|
75 | // write skeleton animations to an Ogre skeleton |
---|
76 | MStatus createOgreSkeletonAnimations(Ogre::SkeletonPtr pSkeleton,ParamList& params); |
---|
77 | |
---|
78 | std::vector<joint> m_joints; |
---|
79 | std::vector<Animation> m_animations; |
---|
80 | std::vector<int> m_roots; |
---|
81 | MString m_restorePose; |
---|
82 | }; |
---|
83 | |
---|
84 | } //end namespace |
---|
85 | |
---|
86 | #endif |
---|