----------------------------------------------------------------------------- This function is invoked by the resource manager based on file extension.
| 644 | //----------------------------------------------------------------------------- |
| 645 | /// This function is invoked by the resource manager based on file extension. |
| 646 | TSShape* loadColladaShape(const Torque::Path &path) |
| 647 | { |
| 648 | #ifndef DAE2DTS_TOOL |
| 649 | // Generate the cached filename |
| 650 | Torque::Path cachedPath(path); |
| 651 | cachedPath.setExtension("cached.dts"); |
| 652 | |
| 653 | // Check if an up-to-date cached DTS version of this file exists, and |
| 654 | // if so, use that instead. |
| 655 | if (ColladaShapeLoader::canLoadCachedDTS(path)) |
| 656 | { |
| 657 | FileStream cachedStream; |
| 658 | cachedStream.open(cachedPath.getFullPath(), Torque::FS::File::Read); |
| 659 | if (cachedStream.getStatus() == Stream::Ok) |
| 660 | { |
| 661 | TSShape *shape = new TSShape; |
| 662 | bool readSuccess = shape->read(&cachedStream); |
| 663 | cachedStream.close(); |
| 664 | |
| 665 | if (readSuccess) |
| 666 | { |
| 667 | #ifdef TORQUE_DEBUG |
| 668 | Con::printf("Loaded cached Collada shape from %s", cachedPath.getFullPath().c_str()); |
| 669 | #endif |
| 670 | return shape; |
| 671 | } |
| 672 | else |
| 673 | delete shape; |
| 674 | } |
| 675 | |
| 676 | Con::warnf("Failed to load cached COLLADA shape from %s", cachedPath.getFullPath().c_str()); |
| 677 | } |
| 678 | #endif // DAE2DTS_TOOL |
| 679 | |
| 680 | if (!Torque::FS::IsFile(path)) |
| 681 | { |
| 682 | // DAE file does not exist, bail. |
| 683 | return NULL; |
| 684 | } |
| 685 | |
| 686 | #ifdef DAE2DTS_TOOL |
| 687 | ColladaUtils::ImportOptions cmdLineOptions = ColladaUtils::getOptions(); |
| 688 | #endif |
| 689 | |
| 690 | // Allow TSShapeConstructor object to override properties |
| 691 | ColladaUtils::getOptions().reset(); |
| 692 | TSShapeConstructor* tscon = TSShapeConstructor::findShapeConstructor(path.getFullPath()); |
| 693 | if (tscon) |
| 694 | { |
| 695 | ColladaUtils::getOptions() = tscon->mOptions; |
| 696 | |
| 697 | #ifdef DAE2DTS_TOOL |
| 698 | // Command line overrides certain options |
| 699 | ColladaUtils::getOptions().forceUpdateMaterials = cmdLineOptions.forceUpdateMaterials; |
| 700 | ColladaUtils::getOptions().useDiffuseNames = cmdLineOptions.useDiffuseNames; |
| 701 | #endif |
| 702 | } |
| 703 |
no test coverage detected