1 /*
2     Copyright (c) 2008-2009 NetAllied Systems GmbH
3 
4 	This file is part of COLLADAMaya.
5 
6     Portions of the code are:
7     Copyright (c) 2005-2007 Feeling Software Inc.
8     Copyright (c) 2005-2007 Sony Computer Entertainment America
9     Copyright (c) 2004-2005 Alias Systems Corp.
10 
11     Licensed under the MIT Open Source License,
12     for details please see LICENSE file or the website
13     http://www.opensource.org/licenses/mit-license.php
14 */
15 
16 #ifndef __COLLADA_MAYA_ANIMATION_TOOLS_H__
17 #define __COLLADA_MAYA_ANIMATION_TOOLS_H__
18 
19 #include "COLLADAMayaPrerequisites.h"
20 #include "COLLADASWLibraryAnimationClips.h"
21 
22 namespace COLLADAMaya
23 {
24 
25     // ----------------------------------------------------------
26     // Use this enum when export/importing an animation to tell the expected type
27     enum SampleType
28     {
29         // Just one float
30         kSingle = 0x01,
31         // Vector value: X, Y, Z
32         kVector = 0x02,
33         // Color value: R, G, B, A
34         kColour = 0x03,
35         // Matrix
36         kMatrix = 0x04,
37         // Boolean
38         kBoolean = 0x05,
39         // Vector2 value: U, V
40         kVector2 = 0x06,
41         // Angle type, there will be rad <-> degree conversions
42         kAngle = 0x10,
43         kQualifiedAngle = 0x30,
44         // Length factor will be applied
45         kLength = 0x40,
46 
47         kFlagMask = 0xF0,
48         kValueMask = 0x07
49     };
50 
51 
52 
53     // ----------------------------------------------------------
54     /** The different types of animations */
55     enum AnimationResult
56     {
57         kISANIM_None = 0,
58         kISANIM_Curve,
59         kISANIM_Sample,
60         kISANIM_Character,
61     };
62 
63     // ----------------------------------------------------------
64     /**
65      * Organizes the data of an animation clip.
66      */
67 
68 	struct Markers
69 	{
70 		float time;
71 		MString ID;
72 	};
73 	typedef std::vector<Markers> MarkersList;
74 
75     class AnimationClip
76     {
77 
78     public:
79 
AnimationClip()80         AnimationClip() {};
81 
~AnimationClip()82         virtual ~AnimationClip()
83         {
84             delete colladaClip;
85         }
86 
87         MObject characterNode;
88 
89         COLLADASW::ColladaAnimationClip* colladaClip;
90 
91 
92 		MarkersList markers;
93 
94 
95         MObjectArray animCurves;
96         MPlugArray plugs;
97 		MObject clipFn;
98 
99         /** Returns the plug */
100         int findPlug ( const MPlug& p );
101 
102         /** Gets the id of the current clip. */
getClipId()103         const String& getClipId() const
104         {
105             return colladaClip->getAnimationClipId();
106         }
107 
getClipSourceId()108 		const String& getClipSourceId() const
109 		{
110 			return colladaClip->getAnimationClipSourceId();
111 		}
112 
113     };
114 
115     typedef std::vector<AnimationClip*> AnimationClipList;
116 
117     // ----------------------------------------------------------
118     /**
119     * Organizes the data of an animation character.
120     */
121 
122     class AnimationCharacter
123     {
124 
125     public:
126         // Import-only
127         AnimationClipList clips;
128         MObject characterNode;
129         MPlugArray plugs;
130         MTime startTime;
131     };
132 
133     typedef std::vector<AnimationCharacter> AnimationCharacterList;
134 
135 }
136 
137 #endif // __COLLADA_MAYA_ANIMATION_TOOLS_H__
138 
139