diff --git a/src/model/CM2Model.cpp b/src/model/CM2Model.cpp index f905df4..0619f49 100644 --- a/src/model/CM2Model.cpp +++ b/src/model/CM2Model.cpp @@ -970,7 +970,19 @@ int32_t CM2Model::InitializeLoaded() { } } - // TODO + // TODO texture transforms + + if (this->m_shared->m_data->attachments.Count()) { + this->m_attachments = reinterpret_cast(&data[0]); + data += (sizeof(M2ModelAttachment) * this->m_shared->m_data->attachments.Count()); + + for (int32_t i = 0; i < this->m_shared->m_data->attachments.Count(); i++) { + new (&this->m_attachments[i]) M2ModelAttachment(); + + auto& modelAttachment = this->m_attachments[i]; + modelAttachment.visible = true; + } + } if (this->m_shared->m_data->lights.Count()) { this->m_lights = reinterpret_cast(&data[0]); diff --git a/src/model/CM2Model.hpp b/src/model/CM2Model.hpp index 23b1e82..59b2890 100644 --- a/src/model/CM2Model.hpp +++ b/src/model/CM2Model.hpp @@ -13,6 +13,7 @@ class CM2Scene; class CM2Shared; struct M2Batch; struct M2Data; +struct M2ModelAttachment; struct M2ModelBone; struct M2ModelBoneSeq; struct M2ModelCamera; @@ -82,7 +83,7 @@ class CM2Model { CM2Model** m_animatePrev = nullptr; CM2Model* m_animateNext = nullptr; CM2Model* m_attachParent = nullptr; - // TODO m_attachments; (presumably M2ModelAttachment) + M2ModelAttachment* m_attachments = nullptr; uint32_t m_attachId = -1; uint32_t m_attachIndex = 0xFFFF; CM2Model* m_attachList = nullptr; diff --git a/src/model/M2Model.hpp b/src/model/M2Model.hpp index abca706..f99d1b9 100644 --- a/src/model/M2Model.hpp +++ b/src/model/M2Model.hpp @@ -10,6 +10,8 @@ template class M2Track; +class CM2Model; + template struct M2ModelTrack { uint32_t currentKey = 0; @@ -18,6 +20,9 @@ struct M2ModelTrack { }; struct M2ModelAttachment { + CM2Model* model = nullptr; + int32_t linkPoint = 0; + bool visible = false; }; struct M2ModelBoneSeq {