MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / loadColladaShape

Function loadColladaShape

Engine/source/ts/collada/colladaShapeLoader.cpp:646–750  ·  view source on GitHub ↗

----------------------------------------------------------------------------- This function is invoked by the resource manager based on file extension.

Source from the content-addressed store, hash-verified

644//-----------------------------------------------------------------------------
645/// This function is invoked by the resource manager based on file extension.
646TSShape* 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

Callers 1

createMethod · 0.85

Calls 15

printfFunction · 0.85
warnfFunction · 0.85
IsFileFunction · 0.85
GetFileSystemFunction · 0.85
errorfFunction · 0.85
updateMaterialsScriptFunction · 0.85
UnmountFunction · 0.85
generateShapeMethod · 0.80
dStrcmpFunction · 0.50
setExtensionMethod · 0.45
openMethod · 0.45
getStatusMethod · 0.45

Tested by

no test coverage detected