| 614 | } |
| 615 | |
| 616 | domCOLLADA* ColladaShapeLoader::readColladaFile(const String& path) |
| 617 | { |
| 618 | // Check if this file is already loaded into the database |
| 619 | domCOLLADA* root = sDAE.getRoot(path.c_str()); |
| 620 | if (root) |
| 621 | return root; |
| 622 | |
| 623 | // Load the Collada file into memory |
| 624 | FileObject fo; |
| 625 | if (!fo.readMemory(path)) |
| 626 | { |
| 627 | daeErrorHandler::get()->handleError(avar("Could not read %s into memory", path.c_str())); |
| 628 | return NULL; |
| 629 | } |
| 630 | |
| 631 | root = sDAE.openFromMemory(path.c_str(), (const char*)fo.buffer()); |
| 632 | if (!root || !root->getLibrary_visual_scenes_array().getCount()) { |
| 633 | daeErrorHandler::get()->handleError(avar("Could not parse %s", path.c_str())); |
| 634 | return NULL; |
| 635 | } |
| 636 | |
| 637 | // Fixup issues in the model |
| 638 | ColladaUtils::applyConditioners(root); |
| 639 | |
| 640 | // Recursively load external DAE references |
| 641 | TSShapeLoader::updateProgress(TSShapeLoader::Load_ExternalRefs, "Loading external references..."); |
| 642 | for (S32 iRef = 0; iRef < root->getDocument()->getReferencedDocuments().getCount(); iRef++) { |
| 643 | String refPath = (daeString)root->getDocument()->getReferencedDocuments()[iRef]; |
| 644 | if (refPath.endsWith(".dae") && !readColladaFile(refPath)) |
| 645 | daeErrorHandler::get()->handleError(avar("Failed to load external reference: %s", refPath.c_str())); |
| 646 | } |
| 647 | return root; |
| 648 | } |
| 649 | |
| 650 | //----------------------------------------------------------------------------- |
| 651 | /// This function is invoked by the resource manager based on file extension. |
nothing calls this directly
no test coverage detected