1 | //////////////////////////////////////////////////////////////////////////////// |
---|
2 | // animation.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 ANIMATION_H |
---|
19 | #define ANIMATION_H |
---|
20 | |
---|
21 | #include "mayaExportLayer.h" |
---|
22 | |
---|
23 | namespace OgreMayaExporter |
---|
24 | { |
---|
25 | // Track type |
---|
26 | typedef enum { TT_SKELETON, TT_MORPH, TT_POSE } trackType; |
---|
27 | |
---|
28 | // Target |
---|
29 | typedef enum { T_MESH, T_SUBMESH } target; |
---|
30 | |
---|
31 | // Vertex position |
---|
32 | typedef struct vertexPositiontag |
---|
33 | { |
---|
34 | float x,y,z; |
---|
35 | } vertexPosition; |
---|
36 | |
---|
37 | // Vertex pose reference |
---|
38 | typedef struct vertexPoseReftag |
---|
39 | { |
---|
40 | int poseIndex; |
---|
41 | float poseWeight; |
---|
42 | } vertexPoseRef; |
---|
43 | |
---|
44 | // Vertex animation keyframe |
---|
45 | typedef struct vertexKeyframetag |
---|
46 | { |
---|
47 | float time; |
---|
48 | std::vector<vertexPosition> positions; |
---|
49 | std::vector<vertexPoseRef> poserefs; |
---|
50 | } vertexKeyframe; |
---|
51 | |
---|
52 | // Skeleton animation keyframe |
---|
53 | typedef struct skeletonKeyframeTag |
---|
54 | { |
---|
55 | float time; //time of keyframe |
---|
56 | double tx,ty,tz; //translation |
---|
57 | double angle,axis_x,axis_y,axis_z; //rotation |
---|
58 | float sx,sy,sz; //scale |
---|
59 | } skeletonKeyframe; |
---|
60 | |
---|
61 | // Blend shape data |
---|
62 | typedef struct vertexOffestTag |
---|
63 | { |
---|
64 | long index; |
---|
65 | float x,y,z; |
---|
66 | } vertexOffset; |
---|
67 | |
---|
68 | typedef struct poseTag |
---|
69 | { |
---|
70 | target poseTarget; |
---|
71 | long index; |
---|
72 | MString name; |
---|
73 | std::vector<vertexOffset> offsets; |
---|
74 | } pose; |
---|
75 | |
---|
76 | // A class for storing an animation track |
---|
77 | // each track can be either skeleton, morph or pose animation |
---|
78 | class Track |
---|
79 | { |
---|
80 | public: |
---|
81 | //constructor |
---|
82 | Track() { |
---|
83 | clear(); |
---|
84 | }; |
---|
85 | //destructor |
---|
86 | ~Track() { |
---|
87 | clear(); |
---|
88 | } |
---|
89 | //clear track data |
---|
90 | void clear() { |
---|
91 | m_type = TT_SKELETON; |
---|
92 | m_target = T_MESH; |
---|
93 | m_index = 0; |
---|
94 | m_bone = ""; |
---|
95 | m_vertexKeyframes.clear(); |
---|
96 | m_skeletonKeyframes.clear(); |
---|
97 | } |
---|
98 | //add vertex animation keyframe |
---|
99 | void addVertexKeyframe(vertexKeyframe& k) { |
---|
100 | m_vertexKeyframes.push_back(k); |
---|
101 | } |
---|
102 | //add skeleton animation keyframe |
---|
103 | void addSkeletonKeyframe(skeletonKeyframe& k) { |
---|
104 | m_skeletonKeyframes.push_back(k); |
---|
105 | } |
---|
106 | |
---|
107 | //public members |
---|
108 | trackType m_type; |
---|
109 | target m_target; |
---|
110 | int m_index; |
---|
111 | MString m_bone; |
---|
112 | std::vector<vertexKeyframe> m_vertexKeyframes; |
---|
113 | std::vector<skeletonKeyframe> m_skeletonKeyframes; |
---|
114 | }; |
---|
115 | |
---|
116 | |
---|
117 | // A class for storing animation information |
---|
118 | // an animation is a collection of different tracks |
---|
119 | class Animation |
---|
120 | { |
---|
121 | public: |
---|
122 | //constructor |
---|
123 | Animation() { |
---|
124 | clear(); |
---|
125 | } |
---|
126 | //destructor |
---|
127 | ~Animation() { |
---|
128 | clear(); |
---|
129 | }; |
---|
130 | //clear animation data |
---|
131 | void clear() { |
---|
132 | m_name = ""; |
---|
133 | m_length = 0; |
---|
134 | m_tracks.clear(); |
---|
135 | }; |
---|
136 | //add track |
---|
137 | void addTrack(Track& t) { |
---|
138 | m_tracks.push_back(t); |
---|
139 | } |
---|
140 | |
---|
141 | //public memebers |
---|
142 | MString m_name; |
---|
143 | float m_length; |
---|
144 | std::vector<Track> m_tracks; |
---|
145 | }; |
---|
146 | |
---|
147 | } // end namespace |
---|
148 | |
---|
149 | |
---|
150 | #endif // ANIMATION_H |
---|