1 | #ifndef _SKELETON_H
|
---|
2 | #define _SKELETON_H
|
---|
3 |
|
---|
4 | #include "mayaExportLayer.h"
|
---|
5 | #include "paramList.h"
|
---|
6 |
|
---|
7 | namespace OgreMayaExporter
|
---|
8 | {
|
---|
9 | /***** structure to hold joint info *****/
|
---|
10 | typedef struct jointTag
|
---|
11 | {
|
---|
12 | MString name;
|
---|
13 | int id;
|
---|
14 | MMatrix localMatrix;
|
---|
15 | MMatrix worldMatrix;
|
---|
16 | int parentIndex;
|
---|
17 | double posx,posy,posz;
|
---|
18 | double angle;
|
---|
19 | double axisx,axisy,axisz;
|
---|
20 | MDagPath jointDag;
|
---|
21 | } joint;
|
---|
22 |
|
---|
23 | /***** structure to hold keyframes *****/
|
---|
24 | typedef struct keyframeTag
|
---|
25 | {
|
---|
26 | double time; //time of keyframe
|
---|
27 | double tx,ty,tz; //translation
|
---|
28 | double angle,axis_x,axis_y,axis_z; //rotation
|
---|
29 | double sx,sy,sz; //scale
|
---|
30 | } keyframe;
|
---|
31 |
|
---|
32 | /***** structure to hold an animation track *****/
|
---|
33 | typedef struct trackTag
|
---|
34 | {
|
---|
35 | MString bone;
|
---|
36 | std::vector<keyframe> keyframes;
|
---|
37 | } track;
|
---|
38 |
|
---|
39 | /***** structure to hold an animation *****/
|
---|
40 | typedef struct animationTag
|
---|
41 | {
|
---|
42 | MString name;
|
---|
43 | double length;
|
---|
44 | std::vector<track> tracks;
|
---|
45 | } animation;
|
---|
46 |
|
---|
47 | /*********** Class Skeleton **********************/
|
---|
48 | class Skeleton
|
---|
49 | {
|
---|
50 | public:
|
---|
51 | //constructor
|
---|
52 | Skeleton();
|
---|
53 | //destructor
|
---|
54 | ~Skeleton();
|
---|
55 | //clear skeleton data
|
---|
56 | void clear();
|
---|
57 | //load skeleton data
|
---|
58 | MStatus load(MFnSkinCluster* pSkinCluster,ParamList& params);
|
---|
59 | //load skeletal animations
|
---|
60 | MStatus loadAnims(MDagPath& jointDag,int jointId,ParamList& params);
|
---|
61 | MStatus loadAnims(ParamList& params);
|
---|
62 | //load a clip
|
---|
63 | MStatus loadClip(MString clipName,double start,double stop,double rate,ParamList& params);
|
---|
64 | MStatus loadClip(MDagPath& jointDag,int jointId,MString clipName,double start,
|
---|
65 | double stop,double rate,ParamList& params);
|
---|
66 | //load a keyframe for a particular joint at current time
|
---|
67 | keyframe loadKeyframe(joint& j,double time,ParamList& params);
|
---|
68 | //get joints
|
---|
69 | std::vector<joint>& getJoints();
|
---|
70 | //get animations
|
---|
71 | std::vector<animation>& getAnimations();
|
---|
72 | //write skeleton data to Ogre XML
|
---|
73 | MStatus writeXML(ParamList ¶ms);
|
---|
74 |
|
---|
75 | protected:
|
---|
76 | MStatus loadJoint(MDagPath& jointDag, joint* parent, ParamList& params);
|
---|
77 |
|
---|
78 | std::vector<joint> m_joints;
|
---|
79 | std::vector<animation> m_animations;
|
---|
80 | };
|
---|
81 |
|
---|
82 | } //end namespace
|
---|
83 |
|
---|
84 | #endif
|
---|