~ubuntu-branches/ubuntu/wily/opencollada/wily

« back to all changes in this revision

Viewing changes to COLLADAMaya/include/COLLADAMayaEffectTextureExporter.h

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2015-05-14 17:23:27 UTC
  • Revision ID: package-import@ubuntu.com-20150514172327-f862u8envms01fra
Tags: upstream-0.1.0~20140703.ddf8f47+dfsg1
ImportĀ upstreamĀ versionĀ 0.1.0~20140703.ddf8f47+dfsg1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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_TEXTURE_EXPORTER_H__
 
17
#define __COLLADA_MAYA_TEXTURE_EXPORTER_H__
 
18
 
 
19
#include "COLLADAMayaStableHeaders.h"
 
20
#include "COLLADAMayaDocumentExporter.h"
 
21
#include "COLLADAMayaDagHelper.h"
 
22
 
 
23
#include <map>
 
24
 
 
25
#include "COLLADASWStreamWriter.h"
 
26
#include "COLLADASWLibraryEffects.h"
 
27
#include "COLLADASWExtraTechnique.h"
 
28
#include "COLLADASWExtra.h"
 
29
#include "COLLADASWEffectProfile.h"
 
30
#include "COLLADASWLibraryImages.h"
 
31
 
 
32
#include "COLLADABUIDList.h"
 
33
 
 
34
#include <maya/MFnDependencyNode.h>
 
35
 
 
36
namespace COLLADAMaya
 
37
{
 
38
 
 
39
    typedef std::map<String, COLLADASW::Image*> ImageMap;
 
40
 
 
41
 
 
42
    /**
 
43
    * Class which manages the textures.
 
44
    */
 
45
    class EffectTextureExporter
 
46
    {
 
47
 
 
48
    public:
 
49
 
 
50
        /** The standard format for materials. */
 
51
        static const String FORMAT;
 
52
 
 
53
    private:
 
54
 
 
55
        /** A multi-texture blend mode. */
 
56
        enum Mode
 
57
        {
 
58
            NONE, /**< No blending. This is the default blend mode. */
 
59
            OVER, /**< Replaces the previous texture with the current one. */
 
60
            In, /**< ?. */
 
61
            OUt, /**< ?. */
 
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. */
 
66
            LIGHTEN, /**< ?. */
 
67
            DARKEN, /**< ?. */
 
68
            SATURATE, /**< ?. */
 
69
            DESATURATE, /**< ?. */
 
70
            ILLUMINATE, /**< ?. */
 
71
 
 
72
            UNKNOWN, /**< An unknown blend mode. */
 
73
            DEFAULT = NONE,
 
74
        };
 
75
 
 
76
    private:
 
77
 
 
78
        /**
 
79
        * The list of the unique collada ids.
 
80
        */
 
81
        COLLADABU::IDList mImageIdList;
 
82
 
 
83
        /** 
 
84
         * Pointer to the document exporter 
 
85
         */
 
86
        DocumentExporter* mDocumentExporter;
 
87
 
 
88
        /** 
 
89
         * Maps already exported image file names to the corresponding image id 
 
90
         */
 
91
        ImageMap mExportedImageMap;
 
92
 
 
93
        /**
 
94
         * The map holds the collada id for the maya id.
 
95
         */
 
96
        StringToStringMap mMayaIdColladaImageId;
 
97
 
 
98
        /** true, if the <extra> and a <technique> tags are already open */
 
99
        bool mTechniqueIsOpen;
 
100
 
 
101
        /** The <extra> tag */
 
102
        COLLADASW::Extra* mExtraSource;
 
103
 
 
104
        /** The <technique> tag */
 
105
        COLLADASW::Technique* mTechniqueSource;
 
106
 
 
107
        /** The target path for animated elements. */
 
108
        String mAnimationTargetPath;
 
109
 
 
110
    public:
 
111
 
 
112
        /** Constructor. */
 
113
        EffectTextureExporter ( DocumentExporter* _documentExporter );
 
114
        virtual ~EffectTextureExporter();
 
115
 
 
116
        /**
 
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.
 
121
        */
 
122
        void exportTexture ( COLLADASW::Texture* colladaTexture,
 
123
                             String channelSemantic,
 
124
                             const MObject &texture,
 
125
                             int blendMode,
 
126
                             const String &targetPath );
 
127
 
 
128
        /**
 
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
 
133
        */
 
134
        const ImageMap* getExportedImageMap() const { return &mExportedImageMap; }
 
135
 
 
136
        /** Exports the texture image */
 
137
        String exportImage ( const MObject &texture );
 
138
 
 
139
        /** Exports the texture image */
 
140
        COLLADASW::Image* exportImage ( 
 
141
            const String& mayaImageId, 
 
142
            const String& colladaImageId, 
 
143
            const COLLADASW::URI& sourceFile );
 
144
 
 
145
        /**
 
146
        * The list of the unique collada ids.
 
147
        */
 
148
        COLLADABU::IDList& getImageIdList () { return mImageIdList; }
 
149
 
 
150
        /**
 
151
        * The map holds the collada id for the maya id.
 
152
        */
 
153
        COLLADAMaya::StringToStringMap& getMayaIdColladaImageId () { return mMayaIdColladaImageId; }
 
154
 
 
155
    private:
 
156
 
 
157
        /** Returns the tolerance value for double value comparison. */
 
158
        const double getTolerance () const 
 
159
        {
 
160
            return mDocumentExporter->getTolerance ();
 
161
        }
 
162
 
 
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 );
 
169
 
 
170
        /**
 
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.
 
174
         */
 
175
        COLLADASW::URI createTargetURI ( const COLLADASW::URI &sourceUri );
 
176
 
 
177
        /** Dump a place2dTexture node */
 
178
        void add2DPlacement ( COLLADASW::Texture* colladaTexture, MObject texture );
 
179
 
 
180
        /** Dump a place2dTexture 3DProjection */
 
181
        void add3DProjection ( COLLADASW::Texture* colladaTexture, MObject projection );
 
182
 
 
183
        /** Opens an <extra> and a <technique> tag in the collada document */
 
184
        void openTechnique();
 
185
 
 
186
        /** Closes the <extra> and a <technique> tag in the collada document, if open */
 
187
        void closeTechnique();
 
188
 
 
189
        /** Adds an bool parameter into the <technique> tag */
 
190
        void addBoolParameter ( COLLADASW::Texture* colladaTexture,
 
191
                                const char* plugName,
 
192
                                MFnDependencyNode &placement2d );
 
193
 
 
194
        /** Adds an float parameter into the <technique> tag */
 
195
        void addFloatParameter ( COLLADASW::Texture* colladaTexture,
 
196
                                 const char* plugName,
 
197
                                 MFnDependencyNode &placement2d );
 
198
 
 
199
        /** Adds an angle parameter into the <technique> tag */
 
200
        void addAngleParameter ( COLLADASW::Texture* colladaTexture,
 
201
                                 const char* plugName,
 
202
                                 MFnDependencyNode &placement2d );
 
203
 
 
204
        /**
 
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.
 
215
         * 
 
216
         * The non-technical definitions are as follows:
 
217
         * 
 
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 
 
253
         *          desaturated reds.
 
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.
 
259
         */
 
260
        String getBlendMode ( int blendMode );
 
261
 
 
262
    };
 
263
 
 
264
}
 
265
 
 
266
#endif // __COLLADA_MAYA_TEXTURE_EXPORTER_H__
 
 
b'\\ No newline at end of file'