1 | /*
|
---|
2 | ============================================================================
|
---|
3 | This source file is part of the Ogre-Maya Tools.
|
---|
4 | Distributed as part of Ogre (Object-oriented Graphics Rendering Engine).
|
---|
5 | Copyright (C) 2003 Fifty1 Software Inc., Bytelords
|
---|
6 |
|
---|
7 | This program is free software; you can redistribute it and/or
|
---|
8 | modify it under the terms of the GNU General Public License
|
---|
9 | as published by the Free Software Foundation; either version 2
|
---|
10 | of the License, or (at your option) any later version.
|
---|
11 |
|
---|
12 | This program is distributed in the hope that it will be useful,
|
---|
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
15 | GNU General Public License for more details.
|
---|
16 |
|
---|
17 | You should have received a copy of the GNU General Public License
|
---|
18 | along with this program; if not, write to the Free Software
|
---|
19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
---|
20 | or go to http://www.gnu.org/licenses/gpl.txt
|
---|
21 | ============================================================================
|
---|
22 | */
|
---|
23 | #ifndef _OGREMAYA_SKELETON_H_
|
---|
24 | #define _OGREMAYA_SKELETON_H_
|
---|
25 |
|
---|
26 | #include "OgreMayaCommon.h"
|
---|
27 |
|
---|
28 | #include <maya/MGlobal.h>
|
---|
29 | #include <maya/MDagPath.h>
|
---|
30 | #include <maya/MFloatArray.h>
|
---|
31 | #include <maya/MPointArray.h>
|
---|
32 | #include <maya/MFloatVectorArray.h>
|
---|
33 | #include <maya/MColorArray.h>
|
---|
34 | #include <maya/MObjectArray.h>
|
---|
35 | #include <maya/MFnMesh.h>
|
---|
36 | #include <maya/MStatus.h>
|
---|
37 | #include <maya/MItMeshPolygon.h>
|
---|
38 | #include <maya/MMatrix.h>
|
---|
39 | #include <maya/MQuaternion.h>
|
---|
40 | #include <maya/MVector.h>
|
---|
41 |
|
---|
42 | #include <fstream>
|
---|
43 |
|
---|
44 | #include <string>
|
---|
45 | #include <list>
|
---|
46 | #include <map>
|
---|
47 |
|
---|
48 | namespace OgreMaya {
|
---|
49 |
|
---|
50 | // using namespace std;
|
---|
51 | using std::list;
|
---|
52 | using std::map;
|
---|
53 | using std::string;
|
---|
54 |
|
---|
55 |
|
---|
56 |
|
---|
57 | struct Keyframe {
|
---|
58 | Keyframe(Real time, MVector pos, MQuaternion rot):
|
---|
59 | time(time), pos(pos), rot(rot) {}
|
---|
60 |
|
---|
61 | Real time; // in s
|
---|
62 | MVector pos;
|
---|
63 | MQuaternion rot;
|
---|
64 | };
|
---|
65 |
|
---|
66 | typedef list<Keyframe> KeyframeList;
|
---|
67 | typedef map<string, KeyframeList> KeyframesMap;
|
---|
68 |
|
---|
69 | struct Animation {
|
---|
70 | Animation(): time(0) {}
|
---|
71 | float time;
|
---|
72 |
|
---|
73 | KeyframesMap keyframes; // bonename -> keyframelist
|
---|
74 | };
|
---|
75 |
|
---|
76 | typedef map<string, Animation> AnimationMap;
|
---|
77 |
|
---|
78 |
|
---|
79 | // ===========================================================================
|
---|
80 | /** \struct SkeletonJoint
|
---|
81 | stores joint data
|
---|
82 | */
|
---|
83 | // ===========================================================================
|
---|
84 | struct SkeletonJoint {
|
---|
85 | MDagPath dagPath;
|
---|
86 |
|
---|
87 | int index;
|
---|
88 |
|
---|
89 | std::string name;
|
---|
90 | std::string parentName;
|
---|
91 | bool hasParent;
|
---|
92 |
|
---|
93 | MMatrix worldMatrix;
|
---|
94 | MMatrix invWorldMatrix;
|
---|
95 | MMatrix localMatrix;
|
---|
96 | MMatrix invLocalMatrix;
|
---|
97 |
|
---|
98 | SkeletonJoint* parent;
|
---|
99 |
|
---|
100 | MVector relPos;
|
---|
101 | MQuaternion relRot;
|
---|
102 | };
|
---|
103 |
|
---|
104 | typedef list<SkeletonJoint*> SkeletonJointList;
|
---|
105 |
|
---|
106 |
|
---|
107 | // ===========================================================================
|
---|
108 | /** \class SkeletonGenerator
|
---|
109 | \author Ivica "macross" Aracic, Bytelords
|
---|
110 | \version 1.0
|
---|
111 | \date August 2003
|
---|
112 |
|
---|
113 | Generates an Ogre skeleton from a Maya scene.
|
---|
114 | */
|
---|
115 | // ===========================================================================
|
---|
116 | class SkeletonGenerator {
|
---|
117 | public:
|
---|
118 |
|
---|
119 | /// Standard constructor.
|
---|
120 | SkeletonGenerator();
|
---|
121 |
|
---|
122 | /// Destructor.
|
---|
123 | virtual ~SkeletonGenerator();
|
---|
124 |
|
---|
125 | /// Export the complete Maya scene (called by OgreMaya.mll or OgreMaya.exe).
|
---|
126 | bool exportAll();
|
---|
127 |
|
---|
128 | /// Export selected parts of the Maya scene (called by OgreMaya.mll).
|
---|
129 | bool exportSelection();
|
---|
130 |
|
---|
131 | int getJointCount() {
|
---|
132 | return jointList.size();
|
---|
133 | }
|
---|
134 |
|
---|
135 | protected:
|
---|
136 | bool _querySkeleton();
|
---|
137 | bool _querySkeletonAnim();
|
---|
138 |
|
---|
139 | protected:
|
---|
140 | SkeletonJointList jointList;
|
---|
141 | SkeletonJoint* root;
|
---|
142 | AnimationMap animations;
|
---|
143 | };
|
---|
144 |
|
---|
145 | } // namespace OgreMaya
|
---|
146 |
|
---|
147 | #endif
|
---|