2
Copyright (c) 2008-2009 NetAllied Systems GmbH
4
This file is part of COLLADAMaya.
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.
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
16
#ifndef __COLLADA_MAYA_VISUAL_SCENE_EXPORTER_H__
17
#define __COLLADA_MAYA_VISUAL_SCENE_EXPORTER_H__
19
#include "COLLADAMayaStableHeaders.h"
20
#include "COLLADASWLibraryVisualScenes.h"
21
#include "COLLADASWStreamWriter.h"
22
#include "COLLADASWNode.h"
23
#include "COLLADASWInstanceMaterial.h"
25
#include "COLLADAMayaDocumentExporter.h"
26
#include "COLLADAMayaSceneElement.h"
28
#include "COLLADABUIDList.h"
30
#include <maya/MDagPath.h>
31
#include <maya/MFnTransform.h>
32
#include <maya/MFnMesh.h>
35
class DocumentExporter;
41
* Exports the transform data of the visual scene.
43
* All transform components with units will be in maya's internal units
44
* (radians for rotations and centimeters for translations).
45
* We have to translate them into the working units of the current scene!
47
class VisualSceneExporter : public COLLADASW::LibraryVisualScenes
53
* The list of the unique collada ids.
55
COLLADABU::IDList mNodeIdList;
58
* A collada id for every maya id.
60
StringToStringMap mMayaIdColladaNodeId;
62
/** Flag, if the current node is a joint. */
65
/** Flag, if we handle the first rotation.
66
Make sure to export the rotation order correctly by always enforcing
67
the elements of the first rotation. */
68
bool mIsFirstRotation;
70
/** The id of the current scene. */
73
/** Pointer to the document exporter. */
74
DocumentExporter* mDocumentExporter;
76
/** Flag if the visual scene library is already added. */
77
bool mVisualSceneAdded;
79
/** A pointer to the actual visual scene node. */
80
COLLADASW::Node* mVisualSceneNode;
82
/** Pointer to the current scene element. */
83
SceneElement* mSceneElement;
85
/** The path of the current node. */
88
/** The current transform object. */
89
MObject mTransformObject;
91
/** The current transform matrix. */
92
MTransformationMatrix mTransformMatrix;
98
* @param streamWriter Pointer to the collada stream writer.
99
* @param documentExporter Pointer to the main document exporter.
100
* @param sceneId Name of the current scene to export. Has an empty string as default value.
102
VisualSceneExporter ( COLLADASW::StreamWriter* streamWriter,
103
DocumentExporter* documentExporter,
104
const String& sceneId = EMPTY_STRING );
108
virtual ~VisualSceneExporter() {};
111
* Exports the visual scene with the transforms of all included elements
113
bool exportVisualScenes();
116
* A collada id for every maya id.
118
const String findColladaNodeId ( const String& mayaNodeId );
121
* Creates the uri for the scene element. Checks for instances
122
* and creates the right element.
124
COLLADASW::URI getSceneElementURI ( const SceneElement* sceneElement, const String& elementId = EMPTY_STRING );
127
* Returns the collada id of the current node, if it is a transform node
129
String getColladaNodeId ( const MDagPath& dagPath );
133
/** Returns the tolerance value for double value comparison. */
134
const double getTolerance () const
136
return mDocumentExporter->getTolerance ();
140
* Exports all the nodes in a node and all its child nodes recursive.
141
* @param sceneElement The node to export.
143
bool exportVisualSceneNodes ( SceneElement* sceneElement );
146
* Creates and opens a visual scene node of type node and writes the transforms
147
* and the references to the geometries and materials of the current scene element.
148
* @param sceneNode The collada node to write.
149
* @param sceneElement The node to export.
151
bool exportNodeVisualSceneNode ( COLLADASW::Node* sceneNode, SceneElement* sceneElement );
154
* Creates and opens a visual scene node of type joint and writes the transforms
155
* and the references to the geometries and materials of the current scene element.
156
* @param sceneNode The collada node.
157
* @param dagPath The node to export.
159
bool exportJointVisualSceneNode ( COLLADASW::Node* sceneNode, SceneElement* sceneElement );
162
* Creates and opens a visual scene node and writes the transforms
163
* and the references to the geometries and materials of the current scene element.
164
* @param sceneNode The collada node to write.
165
* @param sceneElement The node to export.
167
bool exportVisualSceneNode ( COLLADASW::Node* sceneNode, SceneElement* sceneElement );
170
* Exports a node instance of the current scene element.
171
* @param sceneElement The scene element to instantiate.
173
void exportInstanceNode ( SceneElement* sceneElement );
175
void exportInstanceChildNodes ( const SceneElement* sceneElement );
178
* Exports the geometry instances of the given transform scene element.
179
* @param childElement The transform scene element.
181
void exportInstanceGeometry ( SceneElement* sceneElement );
184
* Exports the skin controller instances of the given transform scene element.
185
* @param childElement The transform scene element.
187
void exportInstanceController(
188
SceneElement* childElement,
189
const bool hasSkinController,
190
const bool hasMorphController );
193
* Exports the light instances of the given transform scene element.
194
* @param childElement The transform scene element.
196
void exportInstanceLight ( const SceneElement* childElement );
199
* Exports the camera instances of the given transform scene element.
200
* @param childElement The transform scene element.
202
void exportInstanceCamera ( const SceneElement* childElement );
205
* Exports the material instances.
206
* @param instanceMaterialList The instance list to fill.
207
* @param childDagPath The path of the current node to export the material instances.
208
* @param instanceNumber The current instance number of the shape.
210
void exportInstanceMaterial (
211
COLLADASW::InstanceMaterialList &instanceMaterialList,
212
const MDagPath &dagPath );
215
* Check if the current mesh has some polygons for the connected shader.
216
* If not, we don't need to write the current material instance.
218
const bool meshContainsShaderPolygons (
219
const MFnMesh& fnMesh,
220
const MObjectArray& shaders,
221
const MIntArray& shaderIndices,
222
const uint shaderPosition );
225
* Initializes the transform objects.
226
* @param dagPath The path to the transform object.
227
* @return bool True, if the initialisation was successfull.
229
bool initializeTransform ( SceneElement* sceneElement );
232
* Prepares a new the visual scene node.
233
* @param sceneElement The scene element of the node.
235
void openVisualSceneNode ( const SceneElement *sceneElement );
238
* Compute local space parameters and export them. These parameters are:
241
* - Up-axis direction
243
void exportLookatTransform ();
245
/** Exports all transforms */
246
void exportDecomposedTransform ();
248
/** Exports the translation */
249
void exportTranslation ( const String name, const MPoint& translation, bool animation );
250
void exportTranslation ( const String name, const MVector& translation, bool animation );
252
/** Exports the translation in matrix style */
253
void exportMatrixTransform ();
255
/** Exports the Rotation */
256
void exportRotation ( const String name, const MEulerRotation& rotation );
258
/** Exports the scale */
261
/** Exports the skew */
262
void exportSkew ( double* shear );
265
* Exports the visibility technique tag and the visibility animation.
266
* A hidden visual scene node will not be rendered but will
267
* still affect the world. This parameter is a floating-point value
268
* because it is animated. It should be intepreted as a Boolean value.
269
* @param sceneNode The collada scene node to export the values.
271
void exportVisibility ( COLLADASW::Node* sceneNode );
274
* @todo documentation
275
* @param sceneElement
279
bool enterDagNode( const SceneElement* sceneElement, bool instantiate );
285
#endif //__COLLADA_MAYA_VISUAL_SCENE_EXPORTER_H__