---------------------------------------------------------------
| 239 | |
| 240 | //--------------------------------------------------------------- |
| 241 | String EffectTextureExporter::exportImage ( const MObject &texture ) |
| 242 | { |
| 243 | // Retrieve the texture filename |
| 244 | MFnDependencyNode textureNode ( texture ); |
| 245 | MString mayaName = textureNode.name(); |
| 246 | MPlug filenamePlug = textureNode.findPlug ( ATTR_FILE_TEXTURE_NAME ); |
| 247 | |
| 248 | // Get the maya image id. |
| 249 | String mayaImageId = DocumentExporter::mayaNameToColladaName ( textureNode.name() ); |
| 250 | |
| 251 | // Generate a COLLADA id for the new light object |
| 252 | String colladaImageId; |
| 253 | |
| 254 | // Check if there is an extra attribute "colladaId" and use this as export id. |
| 255 | MString attributeValue; |
| 256 | DagHelper::getPlugValue ( texture, COLLADA_ID_ATTRIBUTE_NAME, attributeValue ); |
| 257 | if ( attributeValue != EMPTY_CSTRING ) |
| 258 | { |
| 259 | // Generate a valid collada name, if necessary. |
| 260 | colladaImageId = mDocumentExporter->mayaNameToColladaName ( attributeValue, false ); |
| 261 | } |
| 262 | else |
| 263 | { |
| 264 | // Generate a COLLADA id for the new light object |
| 265 | colladaImageId = DocumentExporter::mayaNameToColladaName ( textureNode.name() ); |
| 266 | } |
| 267 | // Make the id unique and store it in a map for refernences. |
| 268 | colladaImageId = mImageIdList.addId ( colladaImageId ); |
| 269 | mMayaIdColladaImageId [mayaImageId] = colladaImageId; |
| 270 | |
| 271 | // Get the maya filename with the path to the file. |
| 272 | MString mayaFileName; |
| 273 | filenamePlug.getValue ( mayaFileName ); |
| 274 | if ( mayaFileName.length () == 0 ) return NULL; |
| 275 | String sourceFile = mayaFileName.asChar (); |
| 276 | COLLADASW::URI sourceFileUri ( COLLADASW::URI::nativePathToUri ( sourceFile ) ); |
| 277 | if ( sourceFileUri.getScheme ().empty () ) |
| 278 | sourceFileUri.setScheme ( COLLADASW::URI::SCHEME_FILE ); |
| 279 | |
| 280 | COLLADASW::Image* colladaImage = exportImage ( mayaImageId, colladaImageId, sourceFileUri ); |
| 281 | if ( colladaImage == NULL ) return NULL; |
| 282 | |
| 283 | // Export the node type, because PSD textures don't behave the same as File textures. |
| 284 | String nodeType = texture.hasFn ( MFn::kPsdFileTexture ) ? MAYA_TEXTURE_PSDTEXTURE : MAYA_TEXTURE_FILETEXTURE; |
| 285 | colladaImage->addExtraTechniqueParameter ( PROFILE_MAYA, MAYA_TEXTURE_NODETYPE, nodeType ); |
| 286 | |
| 287 | // Export whether this image is in fact an image sequence |
| 288 | MPlug imgSeqPlug = textureNode.findPlug ( ATTR_IMAGE_SEQUENCE ); |
| 289 | bool isImgSeq = false; |
| 290 | imgSeqPlug.getValue ( isImgSeq ); |
| 291 | colladaImage->addExtraTechniqueParameter ( PROFILE_MAYA, MAYA_TEXTURE_IMAGE_SEQUENCE, isImgSeq ); |
| 292 | |
| 293 | return colladaImage->getImageId(); |
| 294 | } |
| 295 | |
| 296 | // ------------------------------- |
| 297 | COLLADASW::Image* EffectTextureExporter::exportImage ( |
no test coverage detected