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     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 #include "COLLADAMaxStableHeaders.h"
17 #include "COLLADAMaxEffectTextureExporter.h"
18 #include "COLLADAMaxOptions.h"
19 
20 #include "Math/COLLADABUMathUtils.h"
21 #include "COLLADABUUtils.h"
22 
23 #include "COLLADASWStreamWriter.h"
24 #include "COLLADASWLibraryImages.h"
25 
26 namespace COLLADAMax
27 {
28 
29     const String EffectTextureExporter::FORMAT = "A8R8G8B8";
30 
31     //------------------------------------------------------
EffectTextureExporter(DocumentExporter * _documentExporter)32     EffectTextureExporter::EffectTextureExporter ( DocumentExporter* _documentExporter )
33     : mDocumentExporter ( _documentExporter )
34     , mTechniqueIsOpen ( false )
35     , mExtraSource ( NULL )
36     , mTechniqueSource ( NULL )
37     //, mAnimationTargetPath ( EMPTY_STRING )
38     {}
39 
40     //---------------------------------------------------------------
~EffectTextureExporter()41     EffectTextureExporter::~EffectTextureExporter()
42     {
43         if ( !mExportedImageMap.empty() )
44         {
45             ImageMap::iterator it = mExportedImageMap.begin();
46             for ( ; it!=mExportedImageMap.end(); ++it )
47             {
48                 COLLADASW::Image* image = it->second;
49                 delete image;
50             }
51 
52             mExportedImageMap.clear();
53         }
54     }
55 
56     //---------------------------------------------------------------
57     /*
58     void EffectTextureExporter::exportTexture (
59         COLLADASW::Texture* colladaTexture,
60         String channelSemantic,
61         const MObject& texture,
62         int blendMode,
63         const String& targetPath )
64     {
65         mAnimationTargetPath = targetPath;
66 
67         // Set the image name
68         String colladaImageId = exportImage ( texture );
69         colladaTexture->setImageId ( colladaImageId );
70         colladaTexture->setTexcoord ( channelSemantic );
71 
72         // Get the current stream writer
73         COLLADASW::StreamWriter* streamWriter = mDocumentExporter->getStreamWriter();
74 
75         // Create the sampler
76         String samplerSid = colladaImageId + COLLADASW::Sampler::SAMPLER_SID_SUFFIX;
77         String surfaceSid = colladaImageId + COLLADASW::Sampler::SURFACE_SID_SUFFIX;
78 
79         COLLADASW::Sampler sampler ( COLLADASW::Sampler::SAMPLER_TYPE_2D, samplerSid, surfaceSid );
80         sampler.setFormat ( FORMAT );
81         sampler.setImageId ( colladaImageId );
82 
83         colladaTexture->setSampler ( sampler );
84 
85         // Add 2D placement parameters
86         add2DPlacement ( colladaTexture, texture );
87 
88         // Check for 3D projection node
89         MObject colorReceiver = DagHelper::getSourceNodeConnectedTo ( texture, ATTR_OUT_COLOR );
90         if ( colorReceiver != MObject::kNullObj && colorReceiver.apiType() == MFn::kProjection )
91         {
92             add3DProjection ( colladaTexture, colorReceiver );
93         }
94 
95         // Add blend mode information
96         String blendModeString = getBlendMode ( blendMode );
97         colladaTexture->addExtraTechniqueParameter ( PROFILE_MAX, MAX_TEXTURE_BLENDMODE_PARAMETER, blendModeString );
98 
99         // Wrap elements
100         switch ( colladaTexture->getSampler().getSamplerType() )
101         {
102 
103         case COLLADASW::Sampler::SAMPLER_TYPE_1D:
104             sampler.setWrapS ( COLLADASW::Sampler::WRAP_MODE_WRAP );
105             break;
106 
107         case COLLADASW::Sampler::SAMPLER_TYPE_2D:
108         {
109             sampler.setWrapS ( COLLADASW::Sampler::WRAP_MODE_WRAP );
110             sampler.setWrapT ( COLLADASW::Sampler::WRAP_MODE_WRAP );
111         }
112         break;
113 
114         case COLLADASW::Sampler::SAMPLER_TYPE_3D:
115         case COLLADASW::Sampler::SAMPLER_TYPE_CUBE:
116         {
117             sampler.setWrapS ( COLLADASW::Sampler::WRAP_MODE_WRAP );
118             sampler.setWrapT ( COLLADASW::Sampler::WRAP_MODE_WRAP );
119             sampler.setWrapP ( COLLADASW::Sampler::WRAP_MODE_WRAP );
120         }
121         break;
122         }
123 
124         sampler.setMinFilter ( COLLADASW::Sampler::SAMPLER_FILTER_NONE );
125         sampler.setMagFilter ( COLLADASW::Sampler::SAMPLER_FILTER_NONE );
126         sampler.setMipFilter ( COLLADASW::Sampler::SAMPLER_FILTER_NONE );
127     }
128     */
129     //---------------------------------------------------------------
getBlendMode(int blendMode)130     String EffectTextureExporter::getBlendMode ( int blendMode )
131     {
132         /*
133         switch ( blendMode )
134         {
135         case NONE:
136             return MAYA_BLENDMODE_NONE;
137         case OVER:
138             return MAYA_BLENDMODE_OVER;
139         case In:
140             return MAYA_BLENDMODE_IN;
141         case OUt:
142             return MAYA_BLENDMODE_OUT;
143         case ADD:
144             return MAYA_BLENDMODE_ADD;
145         case SUBTRACT:
146             return MAYA_BLENDMODE_SUBTRACT;
147         case MULTIPLY:
148             return MAYA_BLENDMODE_MULTIPLY;
149         case DIFFERENCe:
150             return MAYA_BLENDMODE_DIFFERENCE;
151         case LIGHTEN:
152             return MAYA_BLENDMODE_LIGHTEN;
153         case DARKEN:
154             return MAYA_BLENDMODE_DARKEN;
155         case SATURATE:
156             return MAYA_BLENDMODE_SATURATE;
157         case DESATURATE:
158             return MAYA_BLENDMODE_DESATURATE;
159         case ILLUMINATE:
160             return MAYA_BLENDMODE_ILLUMINATE;
161         default:
162             return MAYA_BLENDMODE_NONE;
163         }
164         */
165 
166         return "";
167     }
168 
169     //---------------------------------------------------------------
170     /*
171     String EffectTextureExporter::exportImage ( const MObject &texture )
172     {
173         // Retrieve the texture filename
174         MFnDependencyNode textureNode ( texture );
175         MString mayaName = textureNode.name();
176         MPlug filenamePlug = textureNode.findPlug ( ATTR_FILE_TEXTURE_NAME );
177 
178         // Get the maya image id.
179         String mayaImageId = DocumentExporter::mayaNameToColladaName ( textureNode.name() );
180 
181         // Generate a COLLADA id for the new light object
182         String colladaImageId;
183 
184         // Check if there is an extra attribute "colladaId" and use this as export id.
185         MString attributeValue;
186         DagHelper::getPlugValue ( texture, COLLADA_ID_ATTRIBUTE_NAME, attributeValue );
187         if ( attributeValue != EMPTY_CSTRING )
188         {
189             // Generate a valid collada name, if necessary.
190             colladaImageId = mDocumentExporter->mayaNameToColladaName ( attributeValue, false );
191         }
192         else
193         {
194             // Generate a COLLADA id for the new light object
195             colladaImageId = DocumentExporter::mayaNameToColladaName ( textureNode.name() );
196         }
197         // Make the id unique and store it in a map for refernences.
198         colladaImageId = mImageIdList.addId ( colladaImageId );
199         mMayaIdColladaImageId [mayaImageId] = colladaImageId;
200 
201         // Get the maya filename with the path to the file.
202         MString mayaFileName;
203         filenamePlug.getValue ( mayaFileName );
204         if ( mayaFileName.length () == 0 ) return NULL;
205         String sourceFile = mayaFileName.asChar ();
206         COLLADASW::URI sourceFileUri ( COLLADASW::URI::nativePathToUri ( sourceFile ) );
207         if ( sourceFileUri.getScheme ().empty () )
208             sourceFileUri.setScheme ( COLLADASW::URI::SCHEME_FILE );
209 
210         COLLADASW::Image* colladaImage = exportImage ( mayaImageId, colladaImageId, sourceFileUri );
211         if ( colladaImage == NULL ) return NULL;
212 
213         // Export the node type, because PSD textures don't behave the same as File textures.
214         String nodeType = texture.hasFn ( MFn::kPsdFileTexture ) ? MAYA_TEXTURE_PSDTEXTURE : MAYA_TEXTURE_FILETEXTURE;
215         colladaImage->addExtraTechniqueParameter ( PROFILE_MAYA, MAYA_TEXTURE_NODETYPE, nodeType );
216 
217         // Export whether this image is in fact an image sequence
218         MPlug imgSeqPlug = textureNode.findPlug ( ATTR_IMAGE_SEQUENCE );
219         bool isImgSeq = false;
220         imgSeqPlug.getValue ( isImgSeq );
221         colladaImage->addExtraTechniqueParameter ( PROFILE_MAYA, MAYA_TEXTURE_IMAGE_SEQUENCE, isImgSeq );
222 
223         return colladaImage->getImageId();
224     }
225     */
226     // -------------------------------
exportImage(const String & mayaImageId,const String & colladaImageId,const COLLADASW::URI & sourceUri)227     COLLADASW::Image* EffectTextureExporter::exportImage (
228         const String& mayaImageId,
229         const String& colladaImageId,
230         const COLLADASW::URI& sourceUri )
231     {
232         // Get the file name and the URI
233         COLLADASW::URI fullFileNameURI;
234         bool sourceFileExist = getTextureFileInfos ( sourceUri, fullFileNameURI );
235         String fullFileName = fullFileNameURI.toNativePath ();
236 
237         // Have we seen this texture node before?
238         ImageMap::iterator exportedImagesIter = mExportedImageMap.find ( fullFileName );
239         if ( exportedImagesIter != mExportedImageMap.end() )
240         {
241             COLLADASW::Image* colladaImage = ( *exportedImagesIter ).second;
242             return colladaImage;
243         }
244 
245         // Check, if we should copy the texture to the destination folder.
246 
247         if ( mDocumentExporter->getOptions().getCopyImages() )
248         {
249             // Get the target file from source file.
250             COLLADASW::URI targetUri = createTargetURI ( sourceUri );
251 
252 			bool exists = COLLADABU::Utils::fileExistsAndIsReadable( sourceUri.toNativePath() );
253             if ( !exists )
254             {
255                 String message = "The source texture file doesn't exist! Filename = " + sourceUri.toNativePath();
256                 GetCOREInterface()->Log()->LogEntry( SYSLOG_ERROR, DISPLAY_DIALOG, _M( "Image export problem" ),_M( "%s\n" ), message.c_str() );
257             }
258             else
259             {
260                 // Copy the texture, if it isn't already there...
261 				exists = COLLADABU::Utils::fileExistsAndIsReadable( targetUri.toNativePath() );
262                 if ( !exists )
263                 {
264                     try
265                     {
266                         // Create the target directory, if necessary.
267                         // Note: some systems (window$) requires the string to be
268                         // enclosed in quotes when a space is present.
269                         COLLADASW::URI targetPathUri ( targetUri.getPathDir() );
270 						exists = COLLADABU::Utils::createDirectoryIfNeeded( targetPathUri.toNativePath() );
271 
272 						if( exists )
273 						{
274 							// Throws: basic_filesystem_error<Path> if
275 							// from_fp.empty() || to_fp.empty() ||!exists(from_fp) || !is_regular(from_fp) || exists(to_fp)
276 							exists = COLLADABU::Utils::copyFile ( sourceUri.toNativePath(), targetUri.toNativePath() );
277 						}
278                     }
279                     catch ( std::exception ex )
280                     {
281 						exists = false;
282                     }
283 
284 					if( !exists )
285 					{
286 						String message = "Could not successful create directory and copy file: " + sourceUri.toNativePath();
287 						GetCOREInterface()->Log()->LogEntry( SYSLOG_ERROR, DISPLAY_DIALOG, _M( "Image export problem" ),_M( "%s\nCould not copy file %s\n" ), message.c_str(), sourceUri.toNativePath().c_str() );
288 					}
289                 }
290             }
291         }
292 
293         // Create a new image structure
294         COLLADASW::Image* colladaImage = new COLLADASW::Image ( fullFileNameURI, colladaImageId, mayaImageId );
295 
296         // Export the original maya name.
297 //        colladaImage->addExtraTechniqueParameter ( PROFILE_MAYA, PARAMETER_MAYA_ID, mayaImageId );
298 
299         // Add this texture to our list of exported images
300         mExportedImageMap[ fullFileName ] = colladaImage;
301 
302         return colladaImage;
303     }
304 
305     // ------------------------------------------------------------
createTargetURI(const COLLADASW::URI & sourceUri)306     COLLADASW::URI EffectTextureExporter::createTargetURI ( const COLLADASW::URI& sourceUri )
307     {
308         // Target file
309         String targetFile = mDocumentExporter->getOutputFileUri().getPath();
310         COLLADASW::URI targetUri ( COLLADASW::URI::nativePathToUri ( targetFile ) );
311         const String& targetScheme = targetUri.getScheme ();
312 
313         // Get the pure file name of the source file and set
314         // the source file name to the target path
315         targetUri.setPathFile ( sourceUri.getPathFile () );
316         if ( !targetScheme.empty () )
317             targetUri.setScheme ( targetScheme );
318         else
319             targetUri.setScheme ( COLLADASW::URI::SCHEME_FILE );
320 
321         // Generate the target file name
322         return targetUri;
323     }
324 
325     // ------------------------------------------------------------
326     /*
327     void EffectTextureExporter::add2DPlacement ( COLLADASW::Texture* colladaTexture, MObject texture )
328     {
329         // Is there a texture placement applied to this texture?
330         MObject placementNode = DagHelper::getSourceNodeConnectedTo ( texture, ATTR_UV_COORD );
331         if ( placementNode.hasFn ( MFn::kPlace2dTexture ) )
332         {
333             MFnDependencyNode placement2d ( placementNode );
334 
335             addBoolParameter ( colladaTexture, MAYA_TEXTURE_WRAPU_PARAMETER, placement2d );
336             addBoolParameter ( colladaTexture, MAYA_TEXTURE_WRAPV_PARAMETER, placement2d );
337             addBoolParameter ( colladaTexture, MAYA_TEXTURE_MIRRORU_PARAMETER, placement2d );
338             addBoolParameter ( colladaTexture, MAYA_TEXTURE_MIRRORV_PARAMETER, placement2d );
339 
340             addFloatParameter ( colladaTexture, MAYA_TEXTURE_COVERAGEU_PARAMETER, placement2d );
341             addFloatParameter ( colladaTexture, MAYA_TEXTURE_COVERAGEV_PARAMETER, placement2d );
342             addFloatParameter ( colladaTexture, MAYA_TEXTURE_TRANSFRAMEU_PARAMETER, placement2d );
343             addFloatParameter ( colladaTexture, MAYA_TEXTURE_TRANSFRAMEV_PARAMETER, placement2d );
344             addAngleParameter ( colladaTexture, MAYA_TEXTURE_ROTFRAME_PARAMETER, placement2d );
345 
346             addBoolParameter ( colladaTexture, MAYA_TEXTURE_STAGGER_PARAMETER, placement2d );
347             addBoolParameter ( colladaTexture, MAYA_TEXTURE_FAST_PARAMETER, placement2d );
348             addFloatParameter ( colladaTexture, MAYA_TEXTURE_REPEATU_PARAMETER, placement2d );
349             addFloatParameter ( colladaTexture, MAYA_TEXTURE_REPEATV_PARAMETER, placement2d );
350             addFloatParameter ( colladaTexture, MAYA_TEXTURE_OFFSETU_PARAMETER, placement2d );
351             addFloatParameter ( colladaTexture, MAYA_TEXTURE_OFFSETV_PARAMETER, placement2d );
352             addAngleParameter ( colladaTexture, MAYA_TEXTURE_ROTATEUV_PARAMETER, placement2d );
353             addFloatParameter ( colladaTexture, MAYA_TEXTURE_NOISEU_PARAMETER, placement2d );
354             addFloatParameter ( colladaTexture, MAYA_TEXTURE_NOISEV_PARAMETER, placement2d );
355         }
356     }
357     */
358     // ------------------------------------------------------------
359     /*
360     void EffectTextureExporter::add3DProjection ( COLLADASW::Texture* colladaTexture, MObject projection )
361     {
362         int projectionType;
363         DagHelper::getPlugValue ( projection, ATTR_PROJECTION_TYPE, projectionType );
364         String strProjectionType = ShaderHelper::projectionTypeToString ( projectionType );
365         colladaTexture->addExtraTechniqueChildParameter (
366             PROFILE_MAYA,
367             MAYA_PROJECTION_ELEMENT,
368             MAYA_PROJECTION_TYPE_PARAMETER,
369             strProjectionType );
370 
371         MMatrix projectionMx;
372         DagHelper::getPlugValue ( projection, ATTR_PLACEMENT_MATRIX, projectionMx );
373         double sceneMatrix[4][4];
374         convertMayaMatrixToTransposedDouble4x4 ( sceneMatrix, projectionMx, getTolerance () );
375 
376         // Convert the  maya internal unit type of the transform part of the
377         // matrix from centimeters into the working units of the current scene!
378         for ( uint i=0; i<3; ++i)
379             sceneMatrix [i][3] = MDistance::internalToUI ( sceneMatrix [i][3] );
380 
381         colladaTexture->addExtraTechniqueChildParameter (
382             PROFILE_MAYA,
383             MAYA_PROJECTION_ELEMENT,
384             MAYA_PROJECTION_MATRIX_PARAMETER,
385             sceneMatrix );
386     }
387     */
388     // ------------------------------------------------------------
389     /*
390     void EffectTextureExporter::addBoolParameter (
391         COLLADASW::Texture* colladaTexture,
392         const char* plugName,
393         MFnDependencyNode &placement2d )
394     {
395         MStatus status;
396         MPlug plug = placement2d.findPlug ( plugName, &status );
397 
398         if ( status == MStatus::kSuccess )
399         {
400             bool value = false;
401             plug.getValue ( value );
402 
403             // Get the animation exporter
404             AnimationExporter* anim = mDocumentExporter->getAnimationExporter();
405             // The target id for the animation
406             String targetSid = mAnimationTargetPath + plugName;
407             // Create the animation
408             bool animated = anim->addPlugAnimation ( plug, targetSid, kBoolean );
409             // Add the parameter
410             String paramSid = EMPTY_STRING; if ( animated ) paramSid = plugName;
411             colladaTexture->addExtraTechniqueParameter ( PROFILE_MAYA, plugName, value, paramSid );
412         }
413     }
414     */
415     // ------------------------------------------------------------
416     /*
417     void EffectTextureExporter::addFloatParameter (
418         COLLADASW::Texture* colladaTexture,
419         const char* plugName,
420         MFnDependencyNode &placement2d )
421     {
422         MStatus status;
423         MPlug plug = placement2d.findPlug ( plugName, &status );
424 
425         if ( status == MStatus::kSuccess )
426         {
427             float value;
428             plug.getValue ( value );
429 
430             // Get the animation exporter
431             AnimationExporter* anim = mDocumentExporter->getAnimationExporter();
432             // The target id for the animation
433             String targetSid = mAnimationTargetPath + plugName;
434             // Create the animation
435             bool animated = anim->addPlugAnimation ( plug, targetSid, kBoolean );
436             // Add the parameter
437             String paramSid = EMPTY_STRING; if ( animated ) paramSid = plugName;
438             colladaTexture->addExtraTechniqueParameter ( PROFILE_MAYA, plugName, value, paramSid );
439         }
440     }
441     */
442     // ------------------------------------------------------------
443 /*
444     void EffectTextureExporter::addAngleParameter (
445         COLLADASW::Texture* colladaTexture,
446         const char* plugName,
447         MFnDependencyNode &placement2d )
448     {
449         MStatus status;
450         MPlug plug = placement2d.findPlug ( plugName, &status );
451         if ( status == MStatus::kSuccess )
452         {
453             float angleRad;
454             plug.getValue ( angleRad );
455             float angleDeg = COLLADABU::Math::Utils::radToDegF ( angleRad );
456 
457             // The target id for the animation
458             String targetSid = mAnimationTargetPath + plugName;
459 
460             // Create the animation
461             AnimationExporter* animationExporter = mDocumentExporter->getAnimationExporter();
462             bool animated = animationExporter->addPlugAnimation ( plug, targetSid, kBoolean );
463 
464             // Add the parameter
465             String paramSid = EMPTY_STRING;
466             if ( animated ) paramSid = plugName;
467             colladaTexture->addExtraTechniqueParameter ( PROFILE_MAYA, plugName, angleDeg, paramSid );
468         }
469     }
470     */
471     // ------------------------------------------------------------
472 /*
473     void EffectTextureExporter::openTechnique()
474     {
475         if ( !mTechniqueIsOpen )
476         {
477             COLLADASW::StreamWriter* streamWriter = &mDocumentExporter->getStreamWriter();
478 
479             mExtraSource = new COLLADASW::Extra ( streamWriter );
480             mExtraSource->openExtra();
481 
482             mTechniqueSource = new COLLADASW::Technique ( streamWriter );
483             mTechniqueSource->openTechnique ( PROFILE_MAYA );
484 
485             mTechniqueIsOpen = true;
486         }
487     }
488 
489     // ------------------------------------------------------------
490     void EffectTextureExporter::closeTechnique()
491     {
492         if ( mTechniqueIsOpen )
493         {
494             mTechniqueSource->closeTechnique();
495             mExtraSource->closeExtra();
496 
497             mTechniqueIsOpen = false;
498         }
499     }
500 */
501     // ------------------------------------------------------------
getTextureFileInfos(const COLLADASW::URI & sourceUri,COLLADASW::URI & fullFileNameURI)502     bool EffectTextureExporter::getTextureFileInfos (
503         const COLLADASW::URI &sourceUri,
504         COLLADASW::URI &fullFileNameURI )
505     {
506         bool returnValue = true;
507 
508         // Check if the file exist!
509         String sourceUriString = sourceUri.toNativePath();
510 
511         if ( mDocumentExporter->getOptions().getExportRelativePaths() )
512         {
513             // Different filename and URI, if we copy the textures to the destination directory!
514             if ( mDocumentExporter->getOptions().getCopyImages() )
515             {
516                 // Get the URI of the COLLADA file.
517                 String targetColladaFile = mDocumentExporter->getOutputFileUri().getPath();
518                 COLLADASW::URI targetColladaUri ( COLLADASW::URI::nativePathToUri ( targetColladaFile ) );
519                 if ( targetColladaUri.getScheme ().empty () )
520                     targetColladaUri.setScheme ( COLLADASW::URI::SCHEME_FILE );
521 
522                 // Get the URI of the copied texture file.
523                 COLLADASW::URI textureUri = createTargetURI ( sourceUri );
524 
525                 // Get the texture URI relative to the COLLADA file URI.
526                 bool success = false;
527                 COLLADASW::URI targetUri = textureUri.getRelativeTo ( targetColladaUri, success );
528                 if ( !success )
529                 {
530                     String message = "Not able to generate a relative path from "
531                         + textureUri.getURIString() + " to " + targetColladaUri.getURIString()
532                         + ". An absolute path will be written! ";
533                     GetCOREInterface()->Log()->LogEntry( SYSLOG_ERROR, DISPLAY_DIALOG, _M( "Error" ),_M( "%s\n" ), message.c_str() );
534                     targetUri = textureUri;
535                     returnValue = false;
536                 }
537 
538                 // Get the file URI
539                 fullFileNameURI = targetUri;
540             }
541             else
542             {
543                 // Get the URI of the COLLADA file.
544                 String targetColladaFile = mDocumentExporter->getOutputFileUri().getPath();
545                 COLLADASW::URI targetColladaUri ( COLLADASW::URI::nativePathToUri ( targetColladaFile ) );
546                 if ( targetColladaUri.getScheme ().empty () )
547                     targetColladaUri.setScheme ( COLLADASW::URI::SCHEME_FILE );
548 
549                 // Get the texture URI relative to the COLLADA file URI.
550                 bool success = false;
551                 COLLADASW::URI targetUri = sourceUri.getRelativeTo ( targetColladaUri, success );
552                 if ( !success )
553                 {
554                     String message = "Not able to generate a relative path from "
555                         + sourceUri.getURIString() + " to " + targetColladaUri.getURIString()
556                         + ". An absolute path will be written! ";
557                     GetCOREInterface()->Log()->LogEntry( SYSLOG_ERROR, DISPLAY_DIALOG, _M( "Error" ),_M( "%s\n" ), message.c_str() );
558                     targetUri = sourceUri;
559                     returnValue = false;
560                 }
561 
562                 // Get the file URI
563                 fullFileNameURI = targetUri;
564             }
565         }
566         else
567         {
568             // Different filename and URI, if we copy the textures to the destination directory!
569             if ( mDocumentExporter->getOptions().getCopyImages() )
570             {
571                 // Get the texture URI relative to the COLLADA file URI.
572                 COLLADASW::URI targetUri = createTargetURI ( sourceUri );
573 
574                 // Get the file URI
575                 fullFileNameURI = targetUri;
576             }
577             else
578             {
579                 // Get the file URI
580                 fullFileNameURI = sourceUri;
581             }
582         }
583 
584         return returnValue;
585     }
586 
587     // ------------------------------------
588 
findColladaImageId(const String & maxImageId)589     const String EffectTextureExporter::findColladaImageId ( const String& maxImageId )
590     {
591         const StringToStringMap::const_iterator it = mMaxIdColladaImageId.find ( maxImageId );
592         if ( it != mMaxIdColladaImageId.end () )
593         {
594             return it->second;
595         }
596         return "";
597     }
598 }
599 
600 
601