mirror of
https://github.com/whoahq/whoa.git
synced 2026-02-01 08:12:44 +03:00
feat(model): add CM2Model::ReplaceTexture
This commit is contained in:
parent
ce0576b40d
commit
5e6bdc78f6
@ -1343,6 +1343,56 @@ void CM2Model::Release() {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void CM2Model::ReplaceTexture(uint32_t textureId, HTEXTURE texture) {
|
||||
// Waiting for load
|
||||
|
||||
if (!this->m_loaded) {
|
||||
auto modelCall = STORM_NEW(CM2ModelCall);
|
||||
|
||||
modelCall->type = 0;
|
||||
modelCall->modelCallNext = nullptr;
|
||||
modelCall->time = this->m_scene->m_time;
|
||||
modelCall->args[0] = textureId;
|
||||
*reinterpret_cast<HTEXTURE*>(&modelCall->args[1]) = texture ? HandleDuplicate(texture) : nullptr;
|
||||
|
||||
*this->m_modelCallTail = modelCall;
|
||||
this->m_modelCallTail = &modelCall->modelCallNext;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Replace textures
|
||||
|
||||
for (int32_t i = 0; i < this->m_shared->m_data->textures.Count(); i++) {
|
||||
// Only replace if texture IDs match
|
||||
if (this->m_shared->m_data->textures[i].textureId != textureId) {
|
||||
continue;
|
||||
};
|
||||
|
||||
auto currentTexture = this->m_textures[i];
|
||||
|
||||
if (currentTexture) {
|
||||
HandleClose(currentTexture);
|
||||
}
|
||||
|
||||
if (texture) {
|
||||
this->m_textures[i] = HandleDuplicate(texture);
|
||||
|
||||
auto gxTexture = TextureGetGxTex(this->m_textures[i], 0, nullptr);
|
||||
|
||||
if (!gxTexture) {
|
||||
this->m_flag2 = 0;
|
||||
}
|
||||
} else {
|
||||
this->m_textures[i] = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO replace ribbon textures
|
||||
|
||||
// TODO replace particle textures
|
||||
}
|
||||
|
||||
void CM2Model::SetAnimating(int32_t animating) {
|
||||
if (!animating) {
|
||||
if (this->m_animatePrev) {
|
||||
|
||||
@ -169,6 +169,7 @@ class CM2Model {
|
||||
int32_t ProcessCallbacks();
|
||||
void ProcessCallbacksRecursive();
|
||||
void Release();
|
||||
void ReplaceTexture(uint32_t textureId, HTEXTURE texture);
|
||||
void SetAnimating(int32_t animating);
|
||||
void SetBoneSequence(uint32_t boneId, uint32_t sequenceId, uint32_t a4, uint32_t time, float a6, int32_t a7, int32_t a8);
|
||||
void SetBoneSequenceDeferred(uint16_t a2, M2Data* data, uint16_t boneIndex, uint32_t time, float a6, M2SequenceFallback fallback, int32_t a8, int32_t a9, int32_t a10);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user