diff --git a/include/studiomodelpp/structs/MDL.h b/include/studiomodelpp/structs/MDL.h index eb845f889..16ed0e3ce 100644 --- a/include/studiomodelpp/structs/MDL.h +++ b/include/studiomodelpp/structs/MDL.h @@ -333,6 +333,8 @@ struct MDL { //int skinReferenceCount; //int skinReferenceFamilyCount; //int skinReferenceIndex; + // Each vector is an individual skin, which holds indices into the materials vector + std::vector> skins; //int bodyPartCount; //int bodyPartOffset; diff --git a/src/studiomodelpp/structs/MDL.cpp b/src/studiomodelpp/structs/MDL.cpp index c529441f3..b2ce10618 100644 --- a/src/studiomodelpp/structs/MDL.cpp +++ b/src/studiomodelpp/structs/MDL.cpp @@ -62,8 +62,9 @@ bool MDL::open(const std::byte* data, std::size_t size) { int materialDirCount = stream.read(); int materialDirOffset = stream.read(); - // todo: skins - stream.skip(3); + int skinReferenceCount = stream.read(); + int skinReferenceFamilyCount = stream.read(); + int skinReferenceOffset = stream.read(); int bodyPartCount = stream.read(); int bodyPartOffset = stream.read(); @@ -127,6 +128,7 @@ bool MDL::open(const std::byte* data, std::size_t size) { // note: we don't know what model versions use absolute vs. relative offsets here // and this is unimportant, so skip parsing the bbox name here //readStringAtOffset(stream, hitbox.name, std::ios::cur, sizeof(int) * 3 + sizeof(Vector3) * 2); + stream.skip(); hitbox.name = ""; // _unused0 @@ -167,6 +169,15 @@ bool MDL::open(const std::byte* data, std::size_t size) { readStringAtOffset(stream, materialDir, std::ios::beg, 0); } + stream.seek(skinReferenceOffset); + for (int i = 0; i < skinReferenceFamilyCount; i++) { + std::vector skinFamily; + for (int j = 0; j < skinReferenceCount; j++) { + skinFamily.push_back(stream.read()); + } + this->skins.push_back(std::move(skinFamily)); + } + for (int i = 0; i < bodyPartCount; i++) { auto bodyPartPos = bodyPartOffset + i * (sizeof(int) * 4); stream.seek(bodyPartPos);