1 /*
2 Copyright (c) 2008-2009 NetAllied Systems GmbH
3 
4 This file is part of COLLADAMax.
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 
10 Based on the 3dsMax COLLADASW Tools:
11 Copyright (c) 2005-2006 Autodesk Media Entertainment
12 
13 Licensed under the MIT Open Source License,
14 for details please see LICENSE file or the website
15 http://www.opensource.org/licenses/mit-license.php
16 */
17 
18 #ifndef __COLLADAMAX_ANIMATIONASSIGNER_H__
19 #define __COLLADAMAX_ANIMATIONASSIGNER_H__
20 
21 #include "COLLADAMaxPrerequisites.h"
22 #include "COLLADAMaxAnimationCreator.h"
23 
24 #include "COLLADAFWTransformation.h"
25 #include "COLLADAFWAnimationList.h"
26 
27 namespace COLLADAMax
28 {
29 	class MaterialCreator;
30 
31     /** Assigns all the controllers to the corresponding animatables. */
32 	class AnimationAssigner : public AnimationCreator
33 	{
34 	private:
35 
36 		enum Bucket
37 		{
38 			TRANSLATE_X = 0,
39 			TRANSLATE_Y,
40 			TRANSLATE_Z,
41 			TRANSLATE = TRANSLATE_Z,
42 			ROTATE_Z,
43 			ROTATE_Y,
44 			ROTATE_X,
45 			ROTATE_AXIS,
46 			SCALE_AXIS_ROTATE,
47 			SCALE_X,
48 			SCALE_Y,
49 			SCALE_Z,
50 			SCALE = SCALE_Z,
51 			SCALE_AXIS_ROTATE_R,
52 			BUCKET_COUNT
53 		};
54 
55 	private:
56 		const MaterialCreator& mMaterialCreator;
57 
58 	public:
59 
60         /** Constructor. */
61 		AnimationAssigner( DocumentImporter* documentImporter,
62 			               const MaterialCreator& materialCreator );
63 
64         /** Destructor. */
65 		virtual ~AnimationAssigner();
66 
67 		/** Performs the assignment.
68 		@return True on success, false otherwise.*/
69 		bool assign();
70 
71 
72 	private:
73 
74         /** Disable default copy ctor. */
75 		AnimationAssigner( const AnimationAssigner& pre );
76 
77         /** Disable default assignment operator. */
78 		const AnimationAssigner& operator= ( const AnimationAssigner& pre );
79 
80 		/** Assigns all transformation controllers.*/
81 		bool assignTransformationControllers();
82 
83 		/** Assigns the animations referenced by the transformations in @a node to the transformations in @a iNode.*/
84 		bool assignTransformationController( const COLLADAFW::Node* node, INode* iNode );
85 
86 		/** Assigns the matrix animations referenced by the transformations in @a node to the transformations in @a iNode.
87 		@a node hast to have exactly one transformation of type matrix.*/
88 		bool assignMatrixTransformationController( const COLLADAFW::Node* node, INode* iNode);
89 
90 		/** Assigns all controllers of animated effect parameters.*/
91 		bool assignEffectParameterControllers();
92 
93 		bool buckedTransforms( const COLLADAFW::TransformationPointerArray& transformations, Control** controllers );
94 
95 		template<COLLADAFW::AnimationList::AnimationClass class_XYZ,
96 				 COLLADAFW::AnimationList::AnimationClass class_X,
97 				 COLLADAFW::AnimationList::AnimationClass class_Y,
98 				 COLLADAFW::AnimationList::AnimationClass class_Z>
99 		bool assign3DController( int bucket_X,
100 							  	 int bucket_Y,
101 								 int bucket_Z,
102 							     const COLLADAFW::AnimationList::AnimationBindings& animationBindings,
103 								 Control** controllers);
104 
105 
106 		template<COLLADAFW::AnimationList::AnimationClass class_XYZW,
107 	  			 COLLADAFW::AnimationList::AnimationClass class_XYZ,
108 				 COLLADAFW::AnimationList::AnimationClass class_X,
109 				 COLLADAFW::AnimationList::AnimationClass class_Y,
110 				 COLLADAFW::AnimationList::AnimationClass class_Z,
111 				 COLLADAFW::AnimationList::AnimationClass class_W>
112 		bool assign4DController( int bucket_X,
113 			 					 int bucket_Y,
114 								 int bucket_Z,
115 								 int bucket_W,
116 								 const COLLADAFW::AnimationList::AnimationBindings& animationBindings,
117 								 Control** controllers);
118 
119 
120 		bool assignEffectParameterControllers( const COLLADAFW::UniqueId& effectUniqueId, Mtl* maxMaterial);
121 
122 		bool assignColorRGBAController(IParamBlock2* entity, int pid, const COLLADAFW::ColorOrTexture& colorOrTexture);
123 
124 		bool assignColorRGBAController( Animatable* entity, int pid, const COLLADAFW::AnimationList* animationList);
125 
126 		bool assignColorRGBController( Animatable* entity, int pid, const COLLADAFW::AnimationList* animationList);
127 
128 		bool assignLightParameterControllers();
129 
130 		bool assignLightParameterController( const COLLADAFW::Light& fwLight);
131 
132 	};
133 
134 } // namespace COLLADAMAX
135 
136 #endif // __COLLADAMAX_ANIMATIONASSIGNER_H__
137