1 /* 2 Copyright (c) 2008-2009 NetAllied Systems GmbH 3 4 This file is part of DAE2MA. 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 "DAE2MAStableHeaders.h" 17 #include "DAE2MADocumentImporter.h" 18 #include "DAE2MAImportOptions.h" 19 #include "DAE2MAMaterialImporter.h" 20 #include "DAE2MAEffectImporter.h" 21 #include "DAE2MAGeometryImporter.h" 22 #include "DAE2MACameraImporter.h" 23 #include "DAE2MALightImporter.h" 24 #include "DAE2MAImageImporter.h" 25 #include "DAE2MAAnimationImporter.h" 26 #include "DAE2MAControllerImporter.h" 27 #include "DAE2MAVisualSceneImporter.h" 28 #include "DAE2MANodeImporter.h" 29 30 #include "COLLADAFWRoot.h" 31 #include "COLLADAFWAnimationList.h" 32 #include "COLLADAFWScene.h" 33 34 #include <fstream> 35 #include <time.h> 36 37 #include "MayaDMScript.h" 38 39 #include "COLLADASaxFWLLoader.h" 40 41 42 namespace DAE2MA 43 { 44 45 /** This names are reserved. Maya nodes can't have this names! */ 46 const size_t DocumentImporter::NUM_RESERVED_NAMES = 43; 47 const String DocumentImporter::RESERVED_NAMES[] = 48 { 49 "default", 50 "defaultShaderList1", 51 "renderPartition", 52 "initialShadingGroup", 53 "initialMaterialInfo", 54 "lightList1", 55 "defaultLightSet", 56 "lightLinker1", 57 "defaultTextureList1", 58 "lambert1", 59 "particleCloud1", 60 "shaderGlow1", 61 "initialParticleSE", 62 "layerManager", 63 "defaultLayer", 64 "defaultObjectSet", 65 "dof1", 66 "dynController1", 67 "globalCacheControl", 68 "hardwareRenderGlobals", 69 "defaultHardwareRenderGlobals", 70 "ikSystem", 71 "ikSCsolver", 72 "ikRPsolver", 73 "ikSplineSolver", 74 "hikSolver", 75 "characterPartition", 76 "renderPartition", 77 "defaultRenderLayer", 78 "renderLayerManager", 79 "strokeGlobals", 80 "time1", 81 "persp", 82 "top", 83 "side", 84 "front", 85 "perspShape", 86 "topShape", 87 "sideShape", 88 "frontShape", 89 "int", 90 "float", 91 "string" 92 }; 93 94 /** The Buffersize for the document to write. */ 95 const int DocumentImporter::BUFFERSIZE = 2097152; 96 97 98 //--------------------------------- DocumentImporter(const String & fileName,const String & mayaAsciiFileName,const char * mayaVersion)99 DocumentImporter::DocumentImporter ( 100 const String& fileName, 101 const String& mayaAsciiFileName, 102 const char* mayaVersion /*= MAYA_VERSION_2009*/ ) 103 : mColladaFileName ( fileName ) 104 , mMayaAsciiFileURI ( mayaAsciiFileName ) 105 , mMayaVersion ( mayaVersion ) 106 // , mSaxLoader ( &mSaxParserErrorHandler ) 107 , mParseStep ( NO_PARSING ) 108 , mVisualScenesList (0) 109 , mLibraryNodesList (0) 110 , mMaterialsList (0) 111 , mEffectsList (0) 112 , mAnimationListsList (0) 113 , mFile ( 0 ) 114 , mNodeImporter (0) 115 , mVisualSceneImporter (0) 116 , mGeometryImporter (0) 117 , mMaterialImporter (0) 118 , mEffectImporter (0) 119 , mCameraImporter (0) 120 , mLightImporter (0) 121 , mImageImporter (0) 122 , mAnimationImporter (0) 123 , mControllerImporter (0) 124 , mNumDocumentParses (0) 125 , mUpAxisType ( COLLADAFW::FileInfo::Y_UP ) 126 , mLinearUnitConvertFactor ( 1.0 ) 127 , mLinearUnitMayaBindShapeBugConvertFactor ( 1.0 ) 128 , mDigitTolerance (FLOAT_TOLERANCE) 129 , mBuffer (0) 130 , mInstanceVisualScene (0) 131 { 132 // Maya already use some names for the default maya objects. 133 for ( size_t i=0; i<NUM_RESERVED_NAMES; ++i ) 134 { 135 mGlobalNodeIdList.addId ( RESERVED_NAMES[i] ); 136 mDependNodeIdList.addId ( RESERVED_NAMES[i] ); 137 } 138 } 139 140 //--------------------------------- ~DocumentImporter()141 DocumentImporter::~DocumentImporter() 142 { 143 // Close the maya ascii file 144 closeMayaAsciiFile (); 145 146 // Don't delete the objects earlier, other parts use the elements! 147 delete mInstanceVisualScene; 148 149 // A copy of the framework's library visual scenes elements. 150 for ( size_t i=0; i< mVisualScenesList.size (); ++i ) 151 { 152 COLLADAFW::VisualScene* visualScene = mVisualScenesList [i]; 153 delete visualScene; 154 } 155 mVisualScenesList.clear (); 156 157 // A copy of the framework's library nodes elements. 158 for ( size_t i=0; i< mLibraryNodesList.size (); ++i ) 159 { 160 COLLADAFW::LibraryNodes* libraryNodes = mLibraryNodesList [i]; 161 delete libraryNodes; 162 } 163 mLibraryNodesList.clear (); 164 165 // A copy of the framework's library materials elements. 166 for ( size_t i=0; i< mMaterialsList.size (); ++i ) 167 { 168 COLLADAFW::Material* material = mMaterialsList [i]; 169 delete material; 170 } 171 mMaterialsList.clear (); 172 173 // A copy of the framework's library effect elements. 174 for ( size_t i=0; i< mEffectsList.size (); ++i ) 175 { 176 COLLADAFW::Effect* effect = mEffectsList [i]; 177 delete effect; 178 } 179 mEffectsList.clear (); 180 181 // A copy of the framework's library animationList elements. 182 for ( size_t i=0; i< mAnimationListsList.size (); ++i ) 183 { 184 COLLADAFW::AnimationList* animationList = mAnimationListsList [i]; 185 delete animationList; 186 } 187 mAnimationListsList.clear (); 188 189 // Delete the library elements. 190 releaseLibraries(); 191 192 // Release the buffer memory 193 delete[] mBuffer; 194 mBuffer = 0; 195 } 196 197 //--------------------------------- createLibraries()198 void DocumentImporter::createLibraries() 199 { 200 // First release the existing libraries. 201 releaseLibraries(); 202 203 // Create the libraries. 204 mNodeImporter = new NodeImporter ( this ); 205 mVisualSceneImporter = new VisualSceneImporter ( this ); 206 mGeometryImporter = new GeometryImporter ( this ); 207 mMaterialImporter = new MaterialImporter ( this ); 208 mEffectImporter = new EffectImporter ( this ); 209 mCameraImporter = new CameraImporter ( this ); 210 mLightImporter = new LightImporter ( this ); 211 mImageImporter = new ImageImporter (this); 212 mAnimationImporter = new AnimationImporter (this); 213 mControllerImporter = new ControllerImporter (this); 214 215 // // TODO Initialize the reference manager 216 // ReferenceManager::getInstance()->initialize (); 217 } 218 219 //--------------------------------- releaseLibraries()220 void DocumentImporter::releaseLibraries() 221 { 222 delete mNodeImporter; 223 delete mVisualSceneImporter; 224 delete mGeometryImporter; 225 delete mMaterialImporter; 226 delete mEffectImporter; 227 delete mCameraImporter; 228 delete mLightImporter; 229 delete mImageImporter; 230 delete mAnimationImporter; 231 delete mControllerImporter; 232 } 233 234 //----------------------------- importCurrentScene()235 void DocumentImporter::importCurrentScene() 236 { 237 // Create the import/export library helpers. 238 createLibraries (); 239 240 // Load the collada document into the collada framework. 241 mParseStep = FIRST_PARSING; 242 243 // TODO 244 int objectFlags = 245 COLLADASaxFWL::Loader::SCENE_FLAG | 246 COLLADASaxFWL::Loader::ASSET_FLAG | 247 COLLADASaxFWL::Loader::VISUAL_SCENES_FLAG | 248 COLLADASaxFWL::Loader::LIBRARY_NODES_FLAG | 249 COLLADASaxFWL::Loader::MATERIAL_FLAG | 250 COLLADASaxFWL::Loader::CONTROLLER_FLAG; 251 //mSaxLoader.setObjectFlags ( objectFlags ); 252 253 readColladaDocument(); 254 255 // Close the maya file. 256 closeMayaAsciiFile (); 257 } 258 259 //----------------------------- createMayaAsciiFile()260 bool DocumentImporter::createMayaAsciiFile () 261 { 262 String mayaAsciiFileName = mMayaAsciiFileURI.getURIString (); 263 264 // Check if the file already exist. 265 if ( std::ifstream ( mayaAsciiFileName.c_str () ) ) 266 { 267 // TODO Open a dialog and ask the user to save the file under an other name. 268 //MGlobal::displayError ( "File already exists!\n" ); 269 //MGlobal::doErrorLogEntry ( "File already exists!\n" ); 270 std::cerr << "Overwrite existing file!" << std::endl; 271 } 272 273 // Get the current locale value 274 mLocale = setlocale ( LC_NUMERIC, 0 ); 275 setlocale ( LC_NUMERIC, "C" ); 276 277 mFile = fopen ( mayaAsciiFileName.c_str (), "w" ); 278 if ( mFile == 0 ) 279 { 280 std::cerr << "Can't open output file!\n" << std::endl; 281 return false; 282 } 283 284 // Set the buffer 285 mBuffer = new char[BUFFERSIZE]; 286 bool failed = ( setvbuf ( mFile , mBuffer, _IOFBF, BUFFERSIZE ) != 0 ); 287 if ( failed ) 288 { 289 delete[] mBuffer; 290 mBuffer = 0; 291 std::cerr << "Could not set buffer for writing." << std::endl; 292 return false; 293 } 294 295 return true; 296 } 297 298 //----------------------------- closeMayaAsciiFile()299 void DocumentImporter::closeMayaAsciiFile () 300 { 301 if ( mFile ) 302 { 303 fclose ( mFile ); 304 mFile = 0; 305 306 setlocale ( LC_NUMERIC, mLocale.c_str() ); 307 } 308 } 309 310 //--------------------------------- getColladaFilename() const311 const String& DocumentImporter::getColladaFilename() const 312 { 313 return mColladaFileName; 314 } 315 316 //----------------------------- initialize()317 void DocumentImporter::initialize () 318 { 319 // Create the maya file. 320 bool retValue = createMayaAsciiFile (); 321 if ( !retValue ) 322 std::cerr << "Error: could not create output file! " << std::endl; 323 324 // Initialise the maya default objects. 325 if ( retValue ) 326 { 327 mLightImporter->initialiseDefaultLightObjects (); 328 } 329 } 330 331 //----------------------------- cancel(const String & errorMessage)332 void DocumentImporter::cancel ( const String& errorMessage ) 333 { 334 std::cerr << "Error: " << errorMessage << std::endl; 335 } 336 337 //----------------------------- finish()338 void DocumentImporter::finish () 339 { 340 // First parse is done. 341 if ( mParseStep <= COPY_ELEMENTS ) 342 { 343 // The order of the steps here is very important! 344 mParseStep = ELEMENTS_COPIED; 345 346 // Create the scene graph and map the unique node ids to the framwork node objects. 347 importNodes (); 348 349 // Import referenced visual scene 350 importVisualScene (); 351 352 // After the import of the visual scene, we can determine the scale animations. 353 detectScaleAnimations (); 354 355 // Import morph controllers 356 importMorphControllers (); 357 358 // First import materials, then effects and after this images. 359 // The order of the import is relevant, about we have to know which effects are used 360 // by this material. After the import of the effects, we know which images we need. 361 // We have to import this before we write the animations in the second parsing, about 362 // to know the animated effects. 363 importMaterials (); 364 importEffects (); 365 importImages (); 366 367 // Get the minimum and the maximum time values of the animations to get the start 368 // time and the end time of the animation. This times we have to set as the 369 // "playbackOptions" in the "sceneConfigurationScriptNode". 370 importPlaybackOptions (); 371 372 // Start the next parsing. 373 mParseStep = SECOND_PARSING; 374 375 // TODO Not active in the current implementation! 376 int objectFlags = 377 COLLADASaxFWL::Loader::GEOMETRY_FLAG | 378 COLLADASaxFWL::Loader::EFFECT_FLAG | 379 COLLADASaxFWL::Loader::CAMERA_FLAG | 380 COLLADASaxFWL::Loader::IMAGE_FLAG | 381 COLLADASaxFWL::Loader::LIGHT_FLAG | 382 COLLADASaxFWL::Loader::ANIMATION_FLAG | 383 COLLADASaxFWL::Loader::ANIMATION_LIST_FLAG | 384 COLLADASaxFWL::Loader::SKIN_CONTROLLER_DATA_FLAG; 385 //mSaxLoader.setObjectFlags ( objectFlags ); 386 387 readColladaDocument (); 388 } 389 390 // If the last read is ready, we can write the connections and close the file. 391 --mNumDocumentParses; 392 if ( mNumDocumentParses == 0 ) 393 { 394 mParseStep = GEOMETRY_IMPORTED; 395 396 // After we have imported the geometries, we can create the necessary uv-choosers. 397 // We can't create them earlier, about we need to know, if the geometry has more than 398 // one uv-set (texture coordinates). 399 createUvChoosers (); 400 401 // After the complete read of the collada document, 402 // the connections can be written into the maya file. 403 mParseStep = MAKE_CONNECTIONS; 404 writeConnections (); 405 406 // Close the file 407 closeMayaAsciiFile (); 408 409 if( mGeometryImporter && mGeometryImporter->getCount2013Workarounds() > 0 ) 410 std::cerr << "Warning: Maya 2013 workaround applied! (duplication of single face geometry!)" << std::endl; 411 412 } 413 } 414 415 //----------------------------- createUvChoosers()416 void DocumentImporter::createUvChoosers () 417 { 418 // After we have imported the geometries, we can create the necessary uv-choosers. 419 if ( mParseStep < GEOMETRY_IMPORTED ) 420 { 421 std::cerr << "Geometries not imported! Can't create the uv-choosers!" << std::endl; 422 return; 423 } 424 425 // The file must already exist. 426 if ( mFile == 0 ) 427 { 428 std::cerr << "DocumentImporter::createUvChoosers(): Cant't import, no maya file exist!" << std::endl; 429 return; 430 } 431 432 // Create the uv-choosers. 433 mMaterialImporter->createUVChoosers (); 434 } 435 436 //----------------------------- writeConnections()437 void DocumentImporter::writeConnections () 438 { 439 if ( mParseStep == MAKE_CONNECTIONS ) 440 { 441 // The file must already exist. 442 if ( mFile == 0 ) 443 { 444 std::cerr << "DocumentImporter::writeConnections(): Cant't import, no maya file exist!" << std::endl; 445 return; 446 } 447 448 // If we have one or more controllers, the material groupIds have to 449 // connect to the geometry object groups on a later index position. 450 mControllerImporter->writeConnections (); 451 mMaterialImporter->writeConnections (); 452 mLightImporter->writeConnections (); 453 mEffectImporter->writeConnections (); 454 mGeometryImporter->writeConnections (); 455 456 // We have to connect the stored animations. 457 importAnimationLists (); 458 } 459 } 460 461 //----------------------------- readColladaDocument()462 void DocumentImporter::readColladaDocument () 463 { 464 // See revision 511 (generate new loader object without setting object flags). 465 COLLADASaxFWL::Loader saxLoader ( &mSaxParserErrorHandler ); 466 467 if ( mParseStep == FIRST_PARSING ) 468 saxLoader.registerExtraDataCallbackHandler ( &mMayaIdCallbackHandler ); 469 470 // TODO 471 COLLADAFW::Root root ( &saxLoader, this ); 472 // COLLADAFW::Root root ( &mSaxLoader, this ); 473 String filename = getColladaFilename (); 474 String fileUriString = URI::nativePathToUri ( filename ); 475 476 ++mNumDocumentParses; 477 root.loadDocument ( fileUriString ); 478 } 479 480 //----------------------------- frameworkNameToMayaName(const String & name)481 String DocumentImporter::frameworkNameToMayaName ( const String& name ) 482 { 483 // Replace offending characters by some that are supported within maya: 484 // ':', '|', '-', '!' are replaced by '_'. 485 486 const char* c = name.c_str (); 487 size_t length = name.length(); 488 char* tmp = new char[length + 1]; 489 490 for ( size_t i = 0; i <= length; i++ ) 491 { 492 char d = c[i]; 493 if ( d == '.' || d == '-' || d == '|' || d == ':' || d == '/' || d == '\\' || d == '(' || d == ')' || d == '[' || d == ']' ) 494 { 495 d = '_'; 496 } 497 tmp[i] = d; 498 } 499 500 String newName = COLLADABU::Utils::checkNCName ( tmp ); 501 delete[] tmp; 502 return newName; 503 } 504 505 //----------------------------- writeGlobalAsset(const COLLADAFW::FileInfo * asset)506 bool DocumentImporter::writeGlobalAsset ( const COLLADAFW::FileInfo* asset ) 507 { 508 if ( mParseStep >= IMPORT_ASSET ) 509 { 510 return true; 511 } 512 mParseStep = IMPORT_ASSET; 513 514 // Create the file, if not already done. 515 if ( mFile == 0 ) 516 { 517 initialize(); 518 } 519 520 if ( mFile == 0 ) 521 { 522 return false; 523 } 524 525 // The maya version 526 //String mayaVersion ( MGlobal::mayaVersion ().asChar () ); 527 fprintf ( mFile, "//Maya ASCII %s scene\n", mMayaVersion ); 528 fprintf ( mFile, "requires maya \"%s\";\n", mMayaVersion ); 529 530 // Get the unit informations. 531 const COLLADAFW::FileInfo::Unit& unit = asset->getUnit (); 532 mLinearUnitConvertFactor = 1.0; 533 mLinearUnitMayaBindShapeBugConvertFactor = 1.0; 534 535 // Set the default value to centimeters. 536 String linearUnitName = COLLADAFW::FileInfo::Unit::LINEAR_UNIT_CENTIMETER_NAME; 537 if ( ImportOptions::importUnits () ) 538 { 539 linearUnitName = unit.getLinearUnitName (); 540 double linearUnitMeter = unit.getLinearUnitMeter (); 541 542 // Set the valid maya values in depend on the current precision. 543 linearUnitMeter = toMayaUnitValue ( linearUnitMeter ); 544 545 // Set the linear unit in meters. 546 // Maya knows: millimeter, centimeter, meter, foot, inch and yard. 547 switch ( unit.getLinearUnitUnit () ) 548 { 549 case COLLADAFW::FileInfo::Unit::KILOMETER: 550 { 551 // Convert to meters 552 linearUnitName = COLLADAFW::FileInfo::Unit::LINEAR_UNIT_METER_NAME; 553 mLinearUnitConvertFactor = COLLADAFW::FileInfo::Unit::LINEAR_UNIT_KILOMETER / COLLADAFW::FileInfo::Unit::LINEAR_UNIT_METER; // 1km = 1000m ==> cf = 1000 554 mLinearUnitMayaBindShapeBugConvertFactor = COLLADAFW::FileInfo::Unit::LINEAR_UNIT_KILOMETER / COLLADAFW::FileInfo::Unit::LINEAR_UNIT_CENTIMETER; // 1km = 100.000m ==> cf = 100.000 555 break; 556 } 557 case COLLADAFW::FileInfo::Unit::METER: 558 { 559 // Don't convert 560 linearUnitName = COLLADAFW::FileInfo::Unit::LINEAR_UNIT_METER_NAME; 561 mLinearUnitConvertFactor = 1.0; 562 mLinearUnitMayaBindShapeBugConvertFactor = COLLADAFW::FileInfo::Unit::LINEAR_UNIT_METER / COLLADAFW::FileInfo::Unit::LINEAR_UNIT_CENTIMETER; // 1m = 100cm ==> cf = 100 563 break; 564 } 565 case COLLADAFW::FileInfo::Unit::DECIMETER: 566 { 567 // Convert to centimeters 568 linearUnitName = COLLADAFW::FileInfo::Unit::LINEAR_UNIT_CENTIMETER_NAME; 569 mLinearUnitConvertFactor = COLLADAFW::FileInfo::Unit::LINEAR_UNIT_DECIMETER / COLLADAFW::FileInfo::Unit::LINEAR_UNIT_CENTIMETER; // 1dm = 10cm ==> cf = 10 570 mLinearUnitMayaBindShapeBugConvertFactor = COLLADAFW::FileInfo::Unit::LINEAR_UNIT_DECIMETER / COLLADAFW::FileInfo::Unit::LINEAR_UNIT_CENTIMETER; // 1dm = 10cm ==> cf = 10 571 break; 572 } 573 case COLLADAFW::FileInfo::Unit::CENTIMETER: 574 { 575 // Don't convert 576 linearUnitName = COLLADAFW::FileInfo::Unit::LINEAR_UNIT_CENTIMETER_NAME; 577 mLinearUnitConvertFactor = 1.0; 578 mLinearUnitMayaBindShapeBugConvertFactor = 1.0; 579 break; 580 } 581 case COLLADAFW::FileInfo::Unit::MILLIMETER: 582 { 583 // Convert to centimeters 584 linearUnitName = COLLADAFW::FileInfo::Unit::LINEAR_UNIT_CENTIMETER_NAME; 585 mLinearUnitConvertFactor = COLLADAFW::FileInfo::Unit::LINEAR_UNIT_MILLIMETER / COLLADAFW::FileInfo::Unit::LINEAR_UNIT_CENTIMETER; // 1mm = 0.01m ==> cf = 0.1 586 mLinearUnitMayaBindShapeBugConvertFactor = COLLADAFW::FileInfo::Unit::LINEAR_UNIT_MILLIMETER / COLLADAFW::FileInfo::Unit::LINEAR_UNIT_CENTIMETER; // 1mm = 0.01m ==> cf = 0.1 587 break; 588 } 589 case COLLADAFW::FileInfo::Unit::FOOT: 590 { 591 // Don't convert 592 linearUnitName = COLLADAFW::FileInfo::Unit::LINEAR_UNIT_FOOT_NAME; 593 mLinearUnitConvertFactor = 1.0; 594 mLinearUnitMayaBindShapeBugConvertFactor = COLLADAFW::FileInfo::Unit::LINEAR_UNIT_FOOT / COLLADAFW::FileInfo::Unit::LINEAR_UNIT_CENTIMETER; 595 break; 596 } 597 case COLLADAFW::FileInfo::Unit::INCH: 598 { 599 // Don't convert 600 linearUnitName = COLLADAFW::FileInfo::Unit::LINEAR_UNIT_INCH_NAME; 601 mLinearUnitConvertFactor = 1.0; 602 mLinearUnitMayaBindShapeBugConvertFactor = COLLADAFW::FileInfo::Unit::LINEAR_UNIT_INCH / COLLADAFW::FileInfo::Unit::LINEAR_UNIT_CENTIMETER; 603 break; 604 } 605 case COLLADAFW::FileInfo::Unit::YARD: 606 { 607 // Don't convert 608 linearUnitName = COLLADAFW::FileInfo::Unit::LINEAR_UNIT_YARD_NAME; 609 mLinearUnitConvertFactor = 1.0; 610 mLinearUnitMayaBindShapeBugConvertFactor = COLLADAFW::FileInfo::Unit::LINEAR_UNIT_YARD / COLLADAFW::FileInfo::Unit::LINEAR_UNIT_CENTIMETER; 611 break; 612 } 613 default: 614 { 615 if ( linearUnitMeter >= COLLADAFW::FileInfo::Unit::LINEAR_UNIT_METER ) 616 { 617 // Set to meter 618 linearUnitName = COLLADAFW::FileInfo::Unit::LINEAR_UNIT_METER_NAME; 619 mLinearUnitConvertFactor = linearUnitMeter / COLLADAFW::FileInfo::Unit::LINEAR_UNIT_METER; // 1 ? = 1 m 620 mLinearUnitMayaBindShapeBugConvertFactor = linearUnitMeter / COLLADAFW::FileInfo::Unit::LINEAR_UNIT_CENTIMETER; 621 } 622 else 623 { 624 // Set to centimeters 625 linearUnitName = COLLADAFW::FileInfo::Unit::LINEAR_UNIT_CENTIMETER_NAME; 626 mLinearUnitConvertFactor = linearUnitMeter / COLLADAFW::FileInfo::Unit::LINEAR_UNIT_CENTIMETER; // 1 ? = 0.01 m 627 mLinearUnitMayaBindShapeBugConvertFactor = linearUnitMeter / COLLADAFW::FileInfo::Unit::LINEAR_UNIT_CENTIMETER; // 1 ? = 0.01 m 628 } 629 break; 630 } 631 } 632 } 633 634 fprintf ( mFile, "currentUnit -l %s -a %s -t %s;\n", 635 linearUnitName.c_str (), unit.getAngularUnitName ().c_str (), unit.getTimeUnitName ().c_str () ); 636 637 if ( ImportOptions::importUpAxis () ) 638 { 639 mUpAxisType = asset->getUpAxisType (); 640 String upAxis = "y"; 641 switch ( mUpAxisType ) 642 { 643 case COLLADAFW::FileInfo::Y_UP: 644 upAxis = "y"; break; 645 case COLLADAFW::FileInfo::Z_UP: 646 upAxis = "z"; break; 647 default: 648 upAxis = "y"; break; 649 } 650 // createNode script -name "upAxisScriptNode"; 651 // setAttr ".before" -type "string" "string $currentAxis = `upAxis -q -ax`; if ($currentAxis != \"z\") { upAxis -ax \"z\"; viewSet -home persp; }"; 652 // setAttr ".scriptType" 2; 653 MayaDM::Script scriptNode ( mFile, SCRIPT_NODE_UP_AXIS ); 654 String scriptValue = "string $currentAxis = `upAxis -q -ax`; if ($currentAxis != \\\"" + upAxis + "\\\") { upAxis -ax \\\"" + upAxis + "\\\"; viewSet -home persp; }"; // -rv 655 656 scriptNode.setBefore ( scriptValue ); 657 scriptNode.setScriptType ( 2 ); 658 } 659 660 // String application ( MGlobal::executeCommandStringResult ( "about -application" ).asChar () ); 661 // fprintf ( mFile, "fileInfo \"application\" \"%s\";\n", application.c_str () ); 662 // String product ( MGlobal::executeCommandStringResult ( "about -product" ).asChar () ); 663 // fprintf ( mFile, "fileInfo \"product\" \"%s\";\n", product.c_str () ); 664 // fprintf ( mFile, "fileInfo \"version\" \"%s\";\n", mayaVersion.c_str () ); 665 // String cutIdentifier ( MGlobal::executeCommandStringResult ( "product -cutIdentifier" ).asChar () ); 666 // fprintf ( mFile, "fileInfo \"cutIdentifier\" \"%s\";\n", cutIdentifier.c_str () ); 667 // String operatingSystemVersion ( MGlobal::executeCommandStringResult ( "product -operatingSystemVersion" ).asChar () ); 668 // fprintf ( mFile, "fileInfo \"osv\" \"%s\";\n", operatingSystemVersion.c_str () ); 669 670 return true; 671 } 672 673 //----------------------------- toMayaUnitValue(double unitValue)674 double DocumentImporter::toMayaUnitValue ( double unitValue ) 675 { 676 if ( COLLADABU::Math::Utils::equalsZero ( unitValue, getTolerance () ) ) 677 unitValue = 0.0; 678 else if ( COLLADABU::Math::Utils::equals ( unitValue, COLLADAFW::FileInfo::Unit::LINEAR_UNIT_KILOMETER, getTolerance () ) ) 679 unitValue = COLLADAFW::FileInfo::Unit::LINEAR_UNIT_KILOMETER; 680 else if ( COLLADABU::Math::Utils::equals ( unitValue, COLLADAFW::FileInfo::Unit::LINEAR_UNIT_METER, getTolerance () ) ) 681 unitValue = COLLADAFW::FileInfo::Unit::LINEAR_UNIT_METER; 682 else if ( COLLADABU::Math::Utils::equals ( unitValue, COLLADAFW::FileInfo::Unit::LINEAR_UNIT_DECIMETER, getTolerance () ) ) 683 unitValue = COLLADAFW::FileInfo::Unit::LINEAR_UNIT_DECIMETER; 684 else if ( COLLADABU::Math::Utils::equals ( unitValue, COLLADAFW::FileInfo::Unit::LINEAR_UNIT_CENTIMETER, getTolerance () ) ) 685 unitValue = COLLADAFW::FileInfo::Unit::LINEAR_UNIT_CENTIMETER; 686 else if ( COLLADABU::Math::Utils::equals ( unitValue, COLLADAFW::FileInfo::Unit::LINEAR_UNIT_FOOT, getTolerance () ) ) 687 unitValue = COLLADAFW::FileInfo::Unit::LINEAR_UNIT_FOOT; 688 else if ( COLLADABU::Math::Utils::equals ( unitValue, COLLADAFW::FileInfo::Unit::LINEAR_UNIT_INCH, getTolerance () ) ) 689 unitValue = COLLADAFW::FileInfo::Unit::LINEAR_UNIT_INCH; 690 else if ( COLLADABU::Math::Utils::equals ( unitValue, COLLADAFW::FileInfo::Unit::LINEAR_UNIT_YARD, getTolerance () ) ) 691 unitValue = COLLADAFW::FileInfo::Unit::LINEAR_UNIT_YARD; 692 return unitValue; 693 } 694 695 //----------------------------- writeScene(const COLLADAFW::Scene * scene)696 bool DocumentImporter::writeScene ( const COLLADAFW::Scene* scene ) 697 { 698 // The file must already exist. 699 if ( mFile == 0 ) 700 { 701 std::cerr << "DocumentImporter::writeScene(..): Cant't import, no maya file exist!" << std::endl; 702 return false; 703 } 704 705 if ( mParseStep <= COPY_ELEMENTS ) 706 { 707 // Make a copy of the instantiated visual scene element. 708 mParseStep = COPY_ELEMENTS; 709 mInstanceVisualScene = scene->getInstanceVisualScene ()->clone (); 710 } 711 712 return true; 713 } 714 715 //----------------------------- importNodes()716 void DocumentImporter::importNodes () 717 { 718 if ( mParseStep >= ELEMENTS_COPIED ) 719 { 720 // Get the visual scene element to import. 721 for ( size_t i=0; i<mVisualScenesList.size (); ++i ) 722 { 723 const COLLADAFW::VisualScene* visualScene = mVisualScenesList [i]; 724 if ( mInstanceVisualScene->getInstanciatedObjectId () == visualScene->getUniqueId () ) 725 { 726 const COLLADAFW::NodePointerArray& nodePointerArray = visualScene->getRootNodes (); 727 728 // Store the unique node ids in a map to the framework nodes. 729 mNodeImporter->importNodes ( nodePointerArray ); 730 } 731 } 732 733 // Import the library notes data. 734 for ( size_t i=0; i<mLibraryNodesList.size (); ++i ) 735 { 736 const COLLADAFW::LibraryNodes* libraryNodes = mLibraryNodesList [i]; 737 const COLLADAFW::NodePointerArray& nodePointerArray = libraryNodes->getNodes (); 738 739 // Store the unique node ids in a map to the framework nodes. 740 mNodeImporter->importNodes ( nodePointerArray ); 741 } 742 } 743 } 744 745 //----------------------------- writeVisualScene(const COLLADAFW::VisualScene * visualScene)746 bool DocumentImporter::writeVisualScene ( const COLLADAFW::VisualScene* visualScene ) 747 { 748 // The file must already exist. 749 if ( mFile == 0 ) 750 { 751 std::cerr << "DocumentImporter::writeScene(..): Cant't import, no maya file exist!" << std::endl; 752 return false; 753 } 754 755 if ( mParseStep <= COPY_ELEMENTS ) 756 { 757 // Make a copy of the visual scene element and push it into the list of visual scenes. 758 mParseStep = COPY_ELEMENTS; 759 mVisualScenesList.push_back ( new COLLADAFW::VisualScene ( *visualScene ) ); 760 } 761 762 return true; 763 } 764 765 //----------------------------- importVisualScene()766 void DocumentImporter::importVisualScene () 767 { 768 if ( mParseStep >= ELEMENTS_COPIED ) 769 { 770 // The file must already exist. 771 if ( mFile == 0 ) 772 { 773 std::cerr << "DocumentImporter::importVisualScene(..): Cant't import, no maya file exist!" << std::endl; 774 return; 775 } 776 777 // Get the referenced visual scene element to import. 778 for ( size_t i=0; i<mVisualScenesList.size (); ++i ) 779 { 780 const COLLADAFW::VisualScene* visualScene = mVisualScenesList [i]; 781 if ( mInstanceVisualScene->getInstanciatedObjectId () == visualScene->getUniqueId () ) 782 { 783 // Import the data. 784 mVisualSceneImporter->importVisualScene ( visualScene ); 785 } 786 } 787 mParseStep = VISUAL_SCENE_IMPORTED; 788 } 789 } 790 791 //----------------------------- writeLibraryNodes(const COLLADAFW::LibraryNodes * libraryNodes)792 bool DocumentImporter::writeLibraryNodes ( const COLLADAFW::LibraryNodes* libraryNodes ) 793 { 794 // The file must already exist. 795 if ( mFile == 0 ) 796 { 797 std::cerr << "DocumentImporter::writeLibraryNodes(..): Cant't import, no maya file exist!" << std::endl; 798 return false; 799 } 800 801 if ( mParseStep <= COPY_ELEMENTS ) 802 { 803 // Make a copy of the library nodes element and push it into the list of library nodes. 804 mParseStep = COPY_ELEMENTS; 805 mLibraryNodesList.push_back ( new COLLADAFW::LibraryNodes ( *libraryNodes ) ); 806 } 807 808 return true; 809 } 810 811 // //----------------------------- 812 // void DocumentImporter::importLibraryNodes () 813 // { 814 // // The file must already exist. 815 // if ( mFile == 0 ) 816 // { 817 // std::cerr << "DocumentImporter::importLibraryNodes(..): Cant't import, no maya file exist!" << std::endl; 818 // return; 819 // } 820 // 821 // // Import the library notes data. 822 // for ( size_t i=0; i<mLibraryNodesList.size (); ++i ) 823 // { 824 // const COLLADAFW::LibraryNodes* libraryNodes = mLibraryNodesList [i]; 825 // mVisualSceneImporter->importLibraryNodes ( libraryNodes ); 826 // } 827 // } 828 829 //----------------------------- writeMaterial(const COLLADAFW::Material * material)830 bool DocumentImporter::writeMaterial ( const COLLADAFW::Material* material ) 831 { 832 // The file must already exist. 833 if ( mFile == 0 ) 834 { 835 std::cerr << "DocumentImporter::writeMaterial(..): Cant't import, no maya file exist!" << std::endl; 836 return false; 837 } 838 839 if ( mParseStep <= COPY_ELEMENTS ) 840 { 841 // Make a copy of the material element and push it into the list. 842 mParseStep = COPY_ELEMENTS; 843 mMaterialsList.push_back ( new COLLADAFW::Material ( *material ) ); 844 } 845 846 return true; 847 } 848 849 //----------------------------- importMaterials()850 void DocumentImporter::importMaterials () 851 { 852 // The file must already exist. 853 if ( mFile == 0 ) 854 { 855 std::cerr << "DocumentImporter::importMaterials(..): Cant't import, no maya file exist!" << std::endl; 856 return; 857 } 858 859 // Import the materials data. 860 if ( mParseStep >= ELEMENTS_COPIED ) 861 { 862 for ( size_t i=0; i<mMaterialsList.size (); ++i ) 863 { 864 const COLLADAFW::Material* material = mMaterialsList [i]; 865 mMaterialImporter->importMaterial ( material ); 866 } 867 } 868 } 869 870 //----------------------------- writeEffect(const COLLADAFW::Effect * effect)871 bool DocumentImporter::writeEffect ( const COLLADAFW::Effect* effect ) 872 { 873 // The file must already exist. 874 if ( mFile == 0 ) 875 { 876 std::cerr << "DocumentImporter::writeEffect(..): Cant't import, no maya file exist!" << std::endl; 877 return false; 878 } 879 880 if ( mParseStep <= COPY_ELEMENTS ) 881 { 882 // Make a copy of the effect element and push it into the list. 883 mParseStep = COPY_ELEMENTS; 884 mEffectsList.push_back ( new COLLADAFW::Effect ( *effect ) ); 885 } 886 887 return true; 888 } 889 890 //----------------------------- importEffects()891 void DocumentImporter::importEffects () 892 { 893 // The file must already exist. 894 if ( mFile == 0 ) 895 { 896 std::cerr << "DocumentImporter::importEffects(): Cant't import, no maya file exist!" << std::endl; 897 return; 898 } 899 900 // Import the effects data. 901 if ( mParseStep >= ELEMENTS_COPIED ) 902 { 903 for ( size_t i=0; i<mEffectsList.size (); ++i ) 904 { 905 const COLLADAFW::Effect* effect = mEffectsList [i]; 906 mEffectImporter->importEffect ( effect ); 907 } 908 } 909 } 910 911 //----------------------------- writeImage(const COLLADAFW::Image * image)912 bool DocumentImporter::writeImage ( const COLLADAFW::Image* image ) 913 { 914 // The file must already exist. 915 if ( mFile == 0 ) 916 { 917 std::cerr << "DocumentImporter::writeImage(): Cant't import, no maya file exist!" << std::endl; 918 return false; 919 } 920 921 // We first should copy the images, about it's possible, that we have to create an 922 // image for more than one time. This happens if: 923 // a) one image is referenced from multiple effects 924 // b) one image is referenced in multiple samplers in one effect 925 // c) one effect uses the same sampler multiple times. 926 // We have to dublicate the image, about the possibility to create multiple uv-sets on it. 927 if ( mParseStep <= COPY_ELEMENTS ) 928 { 929 // Make a copy of the material element and push it into the list. 930 mParseStep = COPY_ELEMENTS; 931 mImageImporter->storeImage ( image ); 932 } 933 934 return true; 935 } 936 937 //----------------------------- importImages()938 void DocumentImporter::importImages () 939 { 940 // The file must already exist. 941 if ( mFile == 0 ) 942 { 943 std::cerr << "DocumentImporter::importImages(): Cant't import, no maya file exist!" << std::endl; 944 return; 945 } 946 947 // Import the images data. 948 if ( mParseStep >= ELEMENTS_COPIED ) 949 { 950 mImageImporter->importImages (); 951 } 952 } 953 954 //----------------------------- writeGeometry(const COLLADAFW::Geometry * geometry)955 bool DocumentImporter::writeGeometry ( const COLLADAFW::Geometry* geometry ) 956 { 957 // The file must already exist. 958 if ( mFile == 0 ) 959 { 960 std::cerr << "DocumentImporter::writeGeometry(): Cant't import, no maya file exist!" << std::endl; 961 return false; 962 } 963 964 if ( mParseStep >= SECOND_PARSING ) 965 { 966 // Import the data. 967 mGeometryImporter->importGeometry ( geometry ); 968 } 969 970 return true; 971 } 972 973 //----------------------------- writeCamera(const COLLADAFW::Camera * camera)974 bool DocumentImporter::writeCamera ( const COLLADAFW::Camera* camera ) 975 { 976 // The file must already exist. 977 if ( mFile == 0 ) 978 { 979 std::cerr << "DocumentImporter::writeCamera(): Cant't import, no maya file exist!" << std::endl; 980 return false; 981 } 982 983 if ( mParseStep >= SECOND_PARSING ) 984 { 985 // Import the data. 986 mCameraImporter->importCamera ( camera ); 987 } 988 989 return true; 990 } 991 992 //----------------------------- writeLight(const COLLADAFW::Light * light)993 bool DocumentImporter::writeLight ( const COLLADAFW::Light* light ) 994 { 995 // The file must already exist. 996 if ( mFile == 0 ) 997 { 998 std::cerr << "DocumentImporter::writeLight(): Cant't import, no maya file exist!" << std::endl; 999 return false; 1000 } 1001 1002 if ( mParseStep >= SECOND_PARSING ) 1003 { 1004 // Import the data. 1005 mLightImporter->importLight ( light ); 1006 } 1007 1008 return true; 1009 } 1010 1011 //----------------------------- writeAnimation(const COLLADAFW::Animation * animation)1012 bool DocumentImporter::writeAnimation ( const COLLADAFW::Animation* animation ) 1013 { 1014 // The file must already exist. 1015 if ( mFile == 0 ) 1016 { 1017 std::cerr << "DocumentImporter::writeAnimation(): Cant't import, no maya file exist!" << std::endl; 1018 return false; 1019 } 1020 1021 if ( mParseStep >= SECOND_PARSING ) 1022 { 1023 getAnimationImporter ()->importAnimation ( animation ); 1024 mParseStep = ANIMATIONS_IMPORTED; 1025 } 1026 1027 return true; 1028 } 1029 1030 //----------------------------- writeAnimationList(const COLLADAFW::AnimationList * animationList)1031 bool DocumentImporter::writeAnimationList ( const COLLADAFW::AnimationList* animationList ) 1032 { 1033 // The file must already exist. 1034 if ( mFile == 0 ) 1035 { 1036 std::cerr << "DocumentImporter::writeAnimationList(): Cant't import, no maya file exist!" << std::endl; 1037 return false; 1038 } 1039 1040 // We need the information about scale animations to adjust the physical dimension of a 1041 // scale animation. To get this info, we have to get the transformations of the transform 1042 // animations and have to check for scale animations. Scale animations must have a physical 1043 // dimension number (double) instead of length (distance)! 1044 // The transformations exist after the first parsing, after the visual scene is imported. 1045 // So we have to store the animation lists in the first parsing. After the visual scene 1046 // import we can iterate over the animation lists and determine the scale animations. After 1047 // we know the scale animations, we can import the animations with the correct physical 1048 // dimension. After we have imported all animations, we can write the animation connections 1049 // from the stored animation lists. 1050 // Order of the parse steps: 1051 // COPY_ELEMENTS 1052 // VISUAL_SCENE_IMPORTED 1053 // SECOND_PARSING 1054 // ANIMATIONS_IMPORTED 1055 // MAKE_CONNECTIONS 1056 1057 1058 // On first parsing, we have to store the animation lists. 1059 if ( mParseStep <= COPY_ELEMENTS ) 1060 { 1061 // Make a copy of the visual scene element and push it into the list of visual scenes. 1062 mParseStep = COPY_ELEMENTS; 1063 mAnimationListsList.push_back ( new COLLADAFW::AnimationList ( *animationList ) ); 1064 } 1065 1066 return true; 1067 } 1068 1069 //----------------------------- importAnimationLists()1070 void DocumentImporter::importAnimationLists () 1071 { 1072 // After we have imported the visual scene, we can detect the scale animations. 1073 if ( mParseStep == MAKE_CONNECTIONS ) 1074 { 1075 std::vector<COLLADAFW::AnimationList*>::const_iterator it = mAnimationListsList.begin (); 1076 while ( it != mAnimationListsList.end () ) 1077 { 1078 const COLLADAFW::AnimationList* animationList = *it; 1079 getAnimationImporter ()->writeConnections ( animationList ); 1080 ++it; 1081 } 1082 } 1083 } 1084 1085 //----------------------------- detectScaleAnimations()1086 void DocumentImporter::detectScaleAnimations () 1087 { 1088 // After we have imported the visual scene, we can detect the scale animations. 1089 if ( mParseStep >= VISUAL_SCENE_IMPORTED ) 1090 { 1091 std::vector<COLLADAFW::AnimationList*>::const_iterator it = mAnimationListsList.begin (); 1092 while ( it != mAnimationListsList.end () ) 1093 { 1094 const COLLADAFW::AnimationList* animationList = *it; 1095 getAnimationImporter ()->detectScaleAnimations ( animationList ); 1096 ++it; 1097 } 1098 } 1099 } 1100 1101 //----------------------------- importPlaybackOptions()1102 void DocumentImporter::importPlaybackOptions () 1103 { 1104 // The file must already exist. 1105 if ( mFile == 0 ) 1106 { 1107 std::cerr << "DocumentImporter::writePlaybackOptions(): Cant't import, no maya file exist!" << std::endl; 1108 return; 1109 } 1110 1111 if ( mParseStep >= ANIMATIONS_IMPORTED ) 1112 { 1113 mAnimationImporter->importPlaybackOptions (); 1114 } 1115 1116 } 1117 1118 //----------------------------- writeSkinControllerData(const COLLADAFW::SkinControllerData * skinControllerData)1119 bool DocumentImporter::writeSkinControllerData ( 1120 const COLLADAFW::SkinControllerData* skinControllerData ) 1121 { 1122 // The file must already exist. 1123 if ( mFile == 0 ) 1124 { 1125 std::cerr << "DocumentImporter::writeSkinControllerData(): Cant't import, no maya file exist!" << std::endl; 1126 return false; 1127 } 1128 1129 if ( mParseStep >= SECOND_PARSING ) 1130 { 1131 mControllerImporter->importSkinControllerData ( skinControllerData ); 1132 } 1133 1134 return true; 1135 } 1136 1137 //----------------------------- writeController(const COLLADAFW::Controller * controller)1138 bool DocumentImporter::writeController ( 1139 const COLLADAFW::Controller* controller ) 1140 { 1141 // The file must already exist. 1142 if ( mFile == 0 ) 1143 { 1144 std::cerr << "DocumentImporter::writeController(): Cant't import, no maya file exist!" << std::endl; 1145 return false; 1146 } 1147 1148 if ( mParseStep <= COPY_ELEMENTS ) 1149 { 1150 // Make a copy of the controller element and push it into the list. 1151 mParseStep = COPY_ELEMENTS; 1152 mControllerImporter->storeController ( controller ); 1153 } 1154 1155 return true; 1156 } 1157 1158 //----------------------------- importMorphControllers()1159 void DocumentImporter::importMorphControllers () 1160 { 1161 if ( mParseStep >= ELEMENTS_COPIED ) 1162 { 1163 // The file must already exist. 1164 if ( mFile == 0 ) 1165 { 1166 std::cerr << "DocumentImporter::importMorphControllers(): Cant't import, no maya file exist!" << std::endl; 1167 return; 1168 } 1169 1170 // Import the morph controllers. 1171 mControllerImporter->importMorphControllers (); 1172 } 1173 } 1174 1175 //----------------------------- writeFormulas(const COLLADAFW::Formulas * formulas)1176 bool DocumentImporter::writeFormulas ( const COLLADAFW::Formulas* formulas ) 1177 { 1178 return true; 1179 } 1180 1181 //----------------------------- writeKinematicsScene(const COLLADAFW::KinematicsScene * kinematicsScene)1182 bool DocumentImporter::writeKinematicsScene( const COLLADAFW::KinematicsScene* kinematicsScene ) 1183 { 1184 return true; 1185 } 1186 1187 //----------------------------- findNode(const COLLADAFW::UniqueId & nodeId,const COLLADAFW::NodePointerArray & nodes)1188 const COLLADAFW::Node* DocumentImporter::findNode ( 1189 const COLLADAFW::UniqueId& nodeId, 1190 const COLLADAFW::NodePointerArray& nodes ) 1191 { 1192 size_t numNodes = nodes.getCount (); 1193 for ( size_t i=0; i<numNodes; ++i ) 1194 { 1195 const COLLADAFW::Node* node = nodes [i]; 1196 if ( nodeId != node->getUniqueId () ) 1197 { 1198 // Recursive call 1199 const COLLADAFW::NodePointerArray& childNodes = node->getChildNodes (); 1200 const COLLADAFW::Node* searchedNode = findNode ( nodeId, childNodes ); 1201 if ( searchedNode ) return searchedNode; 1202 } 1203 else return node; 1204 } 1205 return 0; 1206 } 1207 1208 //----------------------------- addGlobalNodeId(const String & newId,bool returnConverted,bool alwaysAddNumberSuffix)1209 String DocumentImporter::addGlobalNodeId ( 1210 const String& newId, 1211 bool returnConverted /*= true*/, 1212 bool alwaysAddNumberSuffix /*= false */ ) 1213 { 1214 return mGlobalNodeIdList.addId ( newId, returnConverted, alwaysAddNumberSuffix ); 1215 } 1216 1217 //----------------------------- containsGlobalNodeId(const String & id)1218 bool DocumentImporter::containsGlobalNodeId ( const String& id ) 1219 { 1220 return mGlobalNodeIdList.containsId ( id ); 1221 } 1222 1223 //----------------------------- addDependNodeId(const String & newId,bool returnConverted,bool alwaysAddNumberSuffix)1224 String DocumentImporter::addDependNodeId ( 1225 const String& newId, 1226 bool returnConverted /*= true*/, 1227 bool alwaysAddNumberSuffix /*= false */ ) 1228 { 1229 return mDependNodeIdList.addId ( newId, returnConverted, alwaysAddNumberSuffix ); 1230 } 1231 1232 //----------------------------- containsDependNodeId(const String & id)1233 bool DocumentImporter::containsDependNodeId ( const String& id ) 1234 { 1235 return mDependNodeIdList.containsId ( id ); 1236 } 1237 1238 //----------------------------- addDagNodeId(const String & newId)1239 void DocumentImporter::addDagNodeId ( const String& newId ) 1240 { 1241 mDagNodeIdSet.insert ( newId ); 1242 } 1243 1244 //----------------------------- containsDagNodeId(const String & id)1245 bool DocumentImporter::containsDagNodeId ( const String& id ) 1246 { 1247 std::set<String>::const_iterator it = mDagNodeIdSet.find ( id ); 1248 if ( it != mDagNodeIdSet.end () ) return true; 1249 return false; 1250 } 1251 1252 //----------------------------- getMaterialById(const COLLADAFW::UniqueId & materialId)1253 const COLLADAFW::Material* DocumentImporter::getMaterialById ( const COLLADAFW::UniqueId& materialId ) 1254 { 1255 std::vector<COLLADAFW::Material*>::const_iterator it = mMaterialsList.begin (); 1256 while ( it != mMaterialsList.end () ) 1257 { 1258 if ( materialId == (*it)->getUniqueId () ) 1259 return (*it); 1260 ++it; 1261 } 1262 return 0; 1263 } 1264 1265 //------------------------------ start()1266 void DocumentImporter::start() 1267 { 1268 1269 } 1270 1271 }