------------------------------------------------------------------------------------------------
| 641 | |
| 642 | // ------------------------------------------------------------------------------------------------ |
| 643 | void LWOImporter::LoadLWO2ShaderBlock(LE_NCONST IFF::SubChunkHeader * /*head*/, unsigned int size) { |
| 644 | LE_NCONST uint8_t *const end = mFileBuffer + size; |
| 645 | |
| 646 | ai_assert(!mSurfaces->empty()); |
| 647 | LWO::Surface &surf = mSurfaces->back(); |
| 648 | LWO::Shader shader; |
| 649 | |
| 650 | // get the ordinal string |
| 651 | GetS0(shader.ordinal, size); |
| 652 | |
| 653 | // we could crash later if this is an empty string ... |
| 654 | if (!shader.ordinal.length()) { |
| 655 | ASSIMP_LOG_ERROR("LWO2: Ill-formed SURF.BLOK ordinal string"); |
| 656 | shader.ordinal = "\x00"; |
| 657 | } |
| 658 | |
| 659 | // read the header |
| 660 | while (true) { |
| 661 | if (mFileBuffer + 6 >= end) break; |
| 662 | const IFF::SubChunkHeader head = IFF::LoadSubChunk(mFileBuffer); |
| 663 | |
| 664 | if (mFileBuffer + head.length > end) |
| 665 | throw DeadlyImportError("LWO2: Invalid shader header chunk length"); |
| 666 | |
| 667 | uint8_t *const next = mFileBuffer + head.length; |
| 668 | switch (head.type) { |
| 669 | case AI_LWO_ENAB: |
| 670 | shader.enabled = GetU2() ? true : false; |
| 671 | break; |
| 672 | |
| 673 | case AI_LWO_FUNC: |
| 674 | GetS0(shader.functionName, head.length); |
| 675 | } |
| 676 | mFileBuffer = next; |
| 677 | } |
| 678 | |
| 679 | // now attach the shader to the parent surface - sort by ordinal string |
| 680 | for (ShaderList::iterator it = surf.mShaders.begin(); it != surf.mShaders.end(); ++it) { |
| 681 | if (::strcmp(shader.ordinal.c_str(), (*it).ordinal.c_str()) < 0) { |
| 682 | surf.mShaders.insert(it, shader); |
| 683 | return; |
| 684 | } |
| 685 | } |
| 686 | surf.mShaders.push_back(shader); |
| 687 | } |
| 688 | |
| 689 | // ------------------------------------------------------------------------------------------------ |
| 690 | void LWOImporter::LoadNodalBlocks(unsigned int size) { |
nothing calls this directly
no test coverage detected