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_TEXTURE_EXPORTER_H__
17
#define __COLLADA_MAYA_TEXTURE_EXPORTER_H__
19
#include "COLLADAMayaStableHeaders.h"
20
#include "COLLADAMayaDocumentExporter.h"
21
#include "COLLADAMayaDagHelper.h"
25
#include "COLLADASWStreamWriter.h"
26
#include "COLLADASWLibraryEffects.h"
27
#include "COLLADASWExtraTechnique.h"
28
#include "COLLADASWExtra.h"
29
#include "COLLADASWEffectProfile.h"
30
#include "COLLADASWLibraryImages.h"
32
#include "COLLADABUIDList.h"
34
#include <maya/MFnDependencyNode.h>
39
typedef std::map<String, COLLADASW::Image*> ImageMap;
43
* Class which manages the textures.
45
class EffectTextureExporter
50
/** The standard format for materials. */
51
static const String FORMAT;
55
/** A multi-texture blend mode. */
58
NONE, /**< No blending. This is the default blend mode. */
59
OVER, /**< Replaces the previous texture with the current one. */
62
ADD, /**< Adds the color values from the previous texture to the current one. */
63
SUBTRACT, /**< Substracts the color values from the current texture to the previous one. */
64
MULTIPLY, /**< Modulates the previous texture with the current one. */
65
DIFFERENCe, /**< Substracts the color values from the previous texture to the current one. */
69
DESATURATE, /**< ?. */
70
ILLUMINATE, /**< ?. */
72
UNKNOWN, /**< An unknown blend mode. */
79
* The list of the unique collada ids.
81
COLLADABU::IDList mImageIdList;
84
* Pointer to the document exporter
86
DocumentExporter* mDocumentExporter;
89
* Maps already exported image file names to the corresponding image id
91
ImageMap mExportedImageMap;
94
* The map holds the collada id for the maya id.
96
StringToStringMap mMayaIdColladaImageId;
98
/** true, if the <extra> and a <technique> tags are already open */
99
bool mTechniqueIsOpen;
101
/** The <extra> tag */
102
COLLADASW::Extra* mExtraSource;
104
/** The <technique> tag */
105
COLLADASW::Technique* mTechniqueSource;
107
/** The target path for animated elements. */
108
String mAnimationTargetPath;
113
EffectTextureExporter ( DocumentExporter* _documentExporter );
114
virtual ~EffectTextureExporter();
117
* Exports the current texture.
118
* The parameters @shader and @attribute have to be set in the special case for bump maps:
119
* export the bump height in the "amount" texture parameter.
120
* Exists currently within the ColladaMax profile.
122
void exportTexture ( COLLADASW::Texture* colladaTexture,
123
String channelSemantic,
124
const MObject &texture,
126
const String &targetPath );
129
* Returns the std::map with the exported images.
130
* @return const ImageMap*
131
* Returns a const pointer to the image map, managed and released
132
* in the class @EffectTextureExporter
134
const ImageMap* getExportedImageMap() const { return &mExportedImageMap; }
136
/** Exports the texture image */
137
String exportImage ( const MObject &texture );
139
/** Exports the texture image */
140
COLLADASW::Image* exportImage (
141
const String& mayaImageId,
142
const String& colladaImageId,
143
const COLLADASW::URI& sourceFile );
146
* The list of the unique collada ids.
148
COLLADABU::IDList& getImageIdList () { return mImageIdList; }
151
* The map holds the collada id for the maya id.
153
COLLADAMaya::StringToStringMap& getMayaIdColladaImageId () { return mMayaIdColladaImageId; }
157
/** Returns the tolerance value for double value comparison. */
158
const double getTolerance () const
160
return mDocumentExporter->getTolerance ();
163
/** Checks if the source file exist and is valid. If not, the method
164
returns false. Fills the full file URI of the texture in dependency
165
of the current export options. */
166
bool getTextureFileInfos (
167
const COLLADASW::URI &sourceUri,
168
COLLADASW::URI &fullFileNameURI );
171
* Returns the target file name of the given source file name.
172
* @param sourceFileName The source file name.
173
* @return String The target file name.
175
COLLADASW::URI createTargetURI ( const COLLADASW::URI &sourceUri );
177
/** Dump a place2dTexture node */
178
void add2DPlacement ( COLLADASW::Texture* colladaTexture, MObject texture );
180
/** Dump a place2dTexture 3DProjection */
181
void add3DProjection ( COLLADASW::Texture* colladaTexture, MObject projection );
183
/** Opens an <extra> and a <technique> tag in the collada document */
184
void openTechnique();
186
/** Closes the <extra> and a <technique> tag in the collada document, if open */
187
void closeTechnique();
189
/** Adds an bool parameter into the <technique> tag */
190
void addBoolParameter ( COLLADASW::Texture* colladaTexture,
191
const char* plugName,
192
MFnDependencyNode &placement2d );
194
/** Adds an float parameter into the <technique> tag */
195
void addFloatParameter ( COLLADASW::Texture* colladaTexture,
196
const char* plugName,
197
MFnDependencyNode &placement2d );
199
/** Adds an angle parameter into the <technique> tag */
200
void addAngleParameter ( COLLADASW::Texture* colladaTexture,
201
const char* plugName,
202
MFnDependencyNode &placement2d );
205
* Use the Blend Mode to control how successive layers of textures are combined together.
206
* There are a number of blend modes which can specify exactly how to blend a texture with
207
* the textures beneath it.
208
* Here we present two descriptions of the different blend modes. The first description is
209
* a non-technical definition of each blend mode for the benefit of someone who wants to
210
* know what each one does. The second is a technical definition of each blend mode for the
211
* benefit of someone who is attempting to imitate their function in hardware. In both cases
212
* we will refer to the texture whose blend mode is being specified as the "foreground"
213
* texture, and the result of all of the underlying textures blended together (according to
214
* their particular blend modes) as the "background" texture.
216
* The non-technical definitions are as follows:
218
* * None: The foreground texture covers up the background texture entirely.
219
* * Over: The foreground texture is applied like a decal to the background. The shape of
220
* the decal is determined by the foreground alpha.
221
* * In: The result is the background texture cut in the shape of the foreground alpha.
222
* * Out: The result is the opposite of In. It is as if the shape of the foreground alpha
223
* has been cut out of the background.
224
* * Add: The result color is the foreground color added to the background color as if being
225
* projected on the background through a slide projector. The result color is then
226
* applied over the background color using the foreground alpha to define the
227
* opacity of the result.
228
* * Subtract: The result color is the foreground color subtracted from the background
229
* color. The result color is then applied over the background color using the
230
* foreground alpha to define the opacity of the result.
231
* * Multiply: The result color is the foreground color multiplied by the background color.
232
* The result color is then applied over the background color using the foreground
233
* alpha to define the opacity of the result.
234
* * Difference: The result color is the difference between the foreground color and the
235
* background color. The result color is then applied over the background color
236
* using the foreground alpha to define the opacity of the result. Difference is
237
* not supported by hardware texturing.
238
* * Lighten: The result color of each pixel is the background color or foreground color,
239
* whichever is lighter. The result color is then applied over the background
240
* color using the foreground alpha to define the opacity of the result. Lighten
241
* is not supported by hardware texturing.
242
* * Darken: The result color of each pixel is the background color or foreground color,
243
* whichever is darker. The result color is then applied over the background color
244
* using the foreground alpha to define the opacity of the result. Darken is not
245
* supported by hardware texturing.
246
* * Saturate: The result color is the background color with saturation increased in
247
* proportion to the foreground color scaled by foreground alpha. If the
248
* foreground color is red, for example, the result color will be the background
249
* color with more saturated reds.
250
* * Desaturate: The result color is the background color with saturation decreased in
251
* proportion to the foreground color scaled by foreground alpha. If the foreground
252
* color is red, for example, the result color will be the background color with
254
* * Illuminate: The result color is the background color mixed with the foreground color,
255
* brighter where the foreground is bright and darker where the foreground is dark.
256
* It is as if the foreground texture represents the light falling on the
257
* background. The result color is then applied over the background color using the
258
* foreground alpha to define the opacity of the result.
260
String getBlendMode ( int blendMode );
266
#endif // __COLLADA_MAYA_TEXTURE_EXPORTER_H__
b'\\ No newline at end of file'