From 79b5afdd717576c2cce8f62cb977ef3f964d88d6 Mon Sep 17 00:00:00 2001 From: fallenoak Date: Wed, 24 Dec 2025 21:43:56 -0600 Subject: [PATCH] feat(model): set up texture transforms in CM2Model::InitializeLoaded --- src/model/CM2Model.cpp | 13 ++++++++++++- src/model/CM2Model.hpp | 2 ++ src/model/M2Model.hpp | 3 +++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/model/CM2Model.cpp b/src/model/CM2Model.cpp index 59b25bb..a3f772e 100644 --- a/src/model/CM2Model.cpp +++ b/src/model/CM2Model.cpp @@ -1237,7 +1237,18 @@ int32_t CM2Model::InitializeLoaded() { } } - // TODO texture transforms + if (this->m_shared->m_data->textureTransforms.Count()) { + buffer = ALIGN_BUFFER(buffer, start, M2ModelTextureTransform); + this->m_textureTransforms = reinterpret_cast(buffer); + buffer += sizeof(M2ModelTextureTransform) * this->m_shared->m_data->textureTransforms.Count(); + + for (int32_t i = 0; i < this->m_shared->m_data->textureWeights.Count(); i++) { + new (&this->m_textureTransforms[i]) M2ModelTextureTransform(); + } + + // TODO use A16 allocator + this->m_textureMatrices = static_cast(SMemAlloc(sizeof(C44Matrix) * this->m_shared->m_data->textureTransforms.Count(), __FILE__, __LINE__, 0x0)); + } if (this->m_shared->m_data->attachments.Count()) { buffer = ALIGN_BUFFER(buffer, start, M2ModelAttachment); diff --git a/src/model/CM2Model.hpp b/src/model/CM2Model.hpp index 92e795c..3346718 100644 --- a/src/model/CM2Model.hpp +++ b/src/model/CM2Model.hpp @@ -19,6 +19,7 @@ struct M2ModelBoneSeq; struct M2ModelCamera; struct M2ModelColor; struct M2ModelLight; +struct M2ModelTextureTransform; struct M2ModelTextureWeight; struct M2SequenceFallback; struct M2TrackBase; @@ -105,6 +106,7 @@ class CM2Model { uint32_t* m_skinSections = nullptr; HTEXTURE* m_textures = nullptr; M2ModelTextureWeight* m_textureWeights = nullptr; + M2ModelTextureTransform* m_textureTransforms = nullptr; C44Matrix* m_textureMatrices = nullptr; C44Matrix matrixB4; C44Matrix matrixF4; diff --git a/src/model/M2Model.hpp b/src/model/M2Model.hpp index ab2f98a..03dd05f 100644 --- a/src/model/M2Model.hpp +++ b/src/model/M2Model.hpp @@ -76,6 +76,9 @@ struct M2ModelLight { }; struct M2ModelTextureTransform { + M2ModelTrack translationTrack; + M2ModelTrack rotationTrack; + M2ModelTrack scaleTrack; }; struct M2ModelTextureWeight {