------------------------------------------------------------------------------------------------ Constructor to be privately used by Importer
| 412 | // ------------------------------------------------------------------------------------------------ |
| 413 | // Constructor to be privately used by Importer |
| 414 | ColladaParser::ColladaParser(IOSystem *pIOHandler, const std::string &pFile) : |
| 415 | mFileName(pFile), |
| 416 | mRootNode(nullptr), |
| 417 | mUnitSize(1.0f), |
| 418 | mUpDirection(UP_Y), |
| 419 | mFormat(FV_1_5_n) { |
| 420 | if (nullptr == pIOHandler) { |
| 421 | throw DeadlyImportError("IOSystem is nullptr."); |
| 422 | } |
| 423 | |
| 424 | std::unique_ptr<IOStream> daeFile; |
| 425 | std::unique_ptr<ZipArchiveIOSystem> zip_archive; |
| 426 | |
| 427 | // Determine type |
| 428 | const std::string extension = BaseImporter::GetExtension(pFile); |
| 429 | if (extension != "dae") { |
| 430 | zip_archive = std::make_unique<ZipArchiveIOSystem>(pIOHandler, pFile); |
| 431 | } |
| 432 | |
| 433 | if (zip_archive && zip_archive->isOpen()) { |
| 434 | std::string dae_filename = ReadZaeManifest(*zip_archive); |
| 435 | |
| 436 | if (dae_filename.empty()) { |
| 437 | throw DeadlyImportError("Invalid ZAE"); |
| 438 | } |
| 439 | |
| 440 | daeFile.reset(zip_archive->Open(dae_filename.c_str())); |
| 441 | if (daeFile == nullptr) { |
| 442 | throw DeadlyImportError("Invalid ZAE manifest: '", dae_filename, "' is missing"); |
| 443 | } |
| 444 | } else { |
| 445 | // attempt to open the file directly |
| 446 | daeFile.reset(pIOHandler->Open(pFile)); |
| 447 | if (daeFile == nullptr) { |
| 448 | throw DeadlyImportError("Failed to open file '", pFile, "'."); |
| 449 | } |
| 450 | } |
| 451 | |
| 452 | // generate a XML reader for it |
| 453 | if (!mXmlParser.parse(daeFile.get())) { |
| 454 | throw DeadlyImportError("Unable to read file, malformed XML"); |
| 455 | } |
| 456 | // start reading |
| 457 | const XmlNode node = mXmlParser.getRootNode(); |
| 458 | XmlNode colladaNode = node.child("COLLADA"); |
| 459 | if (colladaNode.empty()) { |
| 460 | return; |
| 461 | } |
| 462 | |
| 463 | // Read content and embedded textures |
| 464 | ReadContents(colladaNode); |
| 465 | if (zip_archive && zip_archive->isOpen()) { |
| 466 | ReadEmbeddedTextures(*zip_archive); |
| 467 | } |
| 468 | } |
| 469 | |
| 470 | // ------------------------------------------------------------------------------------------------ |
| 471 | // Destructor, private as well |
nothing calls this directly
no test coverage detected