mirror of
https://github.com/whoahq/whoa.git
synced 2026-02-01 00:02:45 +03:00
feat(model): add CM2Model::AnimateTextureTransformsMT
This commit is contained in:
parent
9915295835
commit
fb0641b133
@ -431,7 +431,9 @@ void CM2Model::AnimateMT(const C44Matrix* view, const C3Vector& a3, const C3Vect
|
||||
}
|
||||
}
|
||||
|
||||
// TODO
|
||||
if (this->m_shared->m_data->textureTransforms.count) {
|
||||
this->AnimateTextureTransformsMT();
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < this->m_shared->m_data->lights.Count(); i++) {
|
||||
auto& light = this->m_shared->m_data->lights[i];
|
||||
@ -686,6 +688,61 @@ void CM2Model::AnimateST() {
|
||||
}
|
||||
}
|
||||
|
||||
void CM2Model::AnimateTextureTransformsMT() {
|
||||
for (int32_t i = 0; i < this->m_shared->m_data->textureTransforms.Count(); i++) {
|
||||
static C3Vector center = { 0.5f, 0.5f, 0.0f };
|
||||
|
||||
auto& textureTransform = this->m_shared->m_data->textureTransforms[i];
|
||||
auto& modelTextureTransform = this->m_textureTransforms[i];
|
||||
auto& textureMatrix = this->m_textureMatrices[i];
|
||||
|
||||
textureMatrix.Identity();
|
||||
|
||||
// Rotation
|
||||
|
||||
auto& rotationTrack = textureTransform.rotationTrack;
|
||||
auto& modelRotationTrack = modelTextureTransform.rotationTrack;
|
||||
|
||||
if (rotationTrack.sequenceTimes.Count() > 0) {
|
||||
C4Quaternion defaultValue = { 0.0f, 0.0f, 0.0f, 1.0f };
|
||||
|
||||
M2AnimateTrack(this, this->m_bones, rotationTrack, modelRotationTrack, defaultValue);
|
||||
|
||||
textureMatrix.Translate(center);
|
||||
textureMatrix.Rotate(modelRotationTrack.currentValue);
|
||||
textureMatrix.Translate(-center);
|
||||
}
|
||||
|
||||
// Scale
|
||||
|
||||
auto& scaleTrack = textureTransform.scaleTrack;
|
||||
auto& modelScaleTrack = modelTextureTransform.scaleTrack;
|
||||
|
||||
if (scaleTrack.sequenceTimes.Count() > 0) {
|
||||
C3Vector defaultValue = { 1.0f, 1.0f, 1.0f };
|
||||
|
||||
M2AnimateTrack(this, this->m_bones, scaleTrack, modelScaleTrack, defaultValue);
|
||||
|
||||
textureMatrix.Translate(center);
|
||||
textureMatrix.Scale(modelScaleTrack.currentValue);
|
||||
textureMatrix.Translate(-center);
|
||||
}
|
||||
|
||||
// Translation
|
||||
|
||||
auto& translationTrack = textureTransform.translationTrack;
|
||||
auto& modelTranslationTrack = modelTextureTransform.translationTrack;
|
||||
|
||||
if (translationTrack.sequenceTimes.Count() > 0) {
|
||||
C3Vector defaultValue = { 0.0f, 0.0f, 0.0f };
|
||||
|
||||
M2AnimateTrack(this, this->m_bones, translationTrack, modelTranslationTrack, defaultValue);
|
||||
|
||||
textureMatrix.Translate(modelTranslationTrack.currentValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CM2Model::AttachToParent(CM2Model* parent, uint32_t id, const C3Vector* position, int32_t a5) {
|
||||
if (this->m_attachParent) {
|
||||
this->DetachFromParent();
|
||||
|
||||
@ -157,6 +157,7 @@ class CM2Model {
|
||||
void AnimateMT(const C44Matrix* view, const C3Vector& a3, const C3Vector& a4, float a5, float a6);
|
||||
void AnimateMTSimple(const C44Matrix* view, const C3Vector& a3, const C3Vector& a4, float a5, float a6);
|
||||
void AnimateST();
|
||||
void AnimateTextureTransformsMT();
|
||||
void AttachToParent(CM2Model* parent, uint32_t id, const C3Vector* position, int32_t a5);
|
||||
void AttachToScene(CM2Scene* scene);
|
||||
void CancelDeferredSequences(uint32_t boneIndex, bool a3);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user