Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/studiomodelpp/structs/MDL.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::vector<short>> skins;

//int bodyPartCount;
//int bodyPartOffset;
Expand Down
15 changes: 13 additions & 2 deletions src/studiomodelpp/structs/MDL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ bool MDL::open(const std::byte* data, std::size_t size) {
int materialDirCount = stream.read<int>();
int materialDirOffset = stream.read<int>();

// todo: skins
stream.skip<int>(3);
int skinReferenceCount = stream.read<int>();
int skinReferenceFamilyCount = stream.read<int>();
int skinReferenceOffset = stream.read<int>();

int bodyPartCount = stream.read<int>();
int bodyPartOffset = stream.read<int>();
Expand Down Expand Up @@ -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<int>();
hitbox.name = "";

// _unused0
Expand Down Expand Up @@ -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<short> skinFamily;
for (int j = 0; j < skinReferenceCount; j++) {
skinFamily.push_back(stream.read<short>());
}
this->skins.push_back(std::move(skinFamily));
}

for (int i = 0; i < bodyPartCount; i++) {
auto bodyPartPos = bodyPartOffset + i * (sizeof(int) * 4);
stream.seek(bodyPartPos);
Expand Down