MCPcopy Create free account
hub / github.com/assimp/assimp / LoadLWO2Surface

Method LoadLWO2Surface

code/AssetLib/LWO/LWOMaterial.cpp:934–1084  ·  view source on GitHub ↗

------------------------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

932
933// ------------------------------------------------------------------------------------------------
934void LWOImporter::LoadLWO2Surface(unsigned int size) {
935 LE_NCONST uint8_t *const end = mFileBuffer + size;
936
937 mSurfaces->push_back(LWO::Surface());
938 LWO::Surface &surf = mSurfaces->back();
939
940 GetS0(surf.mName, size);
941
942 // check whether this surface was derived from any other surface
943 std::string derived;
944 GetS0(derived, (unsigned int)(end - mFileBuffer));
945 if (derived.length()) {
946 // yes, find this surface
947 for (SurfaceList::iterator it = mSurfaces->begin(), itEnd = mSurfaces->end() - 1; it != itEnd; ++it) {
948 if ((*it).mName == derived) {
949 // we have it ...
950 surf = *it;
951 derived.clear();
952 break;
953 }
954 }
955 if (derived.size()) {
956 ASSIMP_LOG_WARN("LWO2: Unable to find source surface: ", derived);
957 }
958 }
959
960 while (true) {
961 if (mFileBuffer + 6 >= end)
962 break;
963 const IFF::SubChunkHeader head = IFF::LoadSubChunk(mFileBuffer);
964
965 if (mFileBuffer + head.length > end)
966 throw DeadlyImportError("LWO2: Invalid surface chunk length");
967
968 uint8_t *const next = mFileBuffer + head.length;
969 switch (head.type) {
970 // diffuse color
971 case AI_LWO_COLR: {
972 AI_LWO_VALIDATE_CHUNK_LENGTH(head.length, COLR, 12);
973 surf.mColor.r = GetF4();
974 surf.mColor.g = GetF4();
975 surf.mColor.b = GetF4();
976 break;
977 }
978 // diffuse strength ... hopefully
979 case AI_LWO_DIFF: {
980 AI_LWO_VALIDATE_CHUNK_LENGTH(head.length, DIFF, 4);
981 surf.mDiffuseValue = GetF4();
982 break;
983 }
984 // specular strength ... hopefully
985 case AI_LWO_SPEC: {
986 AI_LWO_VALIDATE_CHUNK_LENGTH(head.length, SPEC, 4);
987 surf.mSpecularValue = GetF4();
988 break;
989 }
990 // transparency
991 case AI_LWO_TRAN: {

Callers

nothing calls this directly

Calls 8

LoadSubChunkFunction · 0.85
DeadlyImportErrorFunction · 0.85
SurfaceClass · 0.70
push_backMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
clearMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected